Commit Graph

490 Commits

Author SHA1 Message Date
maxv
382770f2eb 'result' -> 'error' 2014-07-25 16:28:12 +00:00
dholland
53d9b9366b typo in comment 2014-07-25 08:30:10 +00:00
dholland
738b7a54cf Add fdiscard and posix_fallocate syscalls. 2014-07-25 08:25:47 +00:00
maxv
374ecba24a This is weird; 'abort' already does all this, so simply use goto abort. 2014-06-30 17:51:31 +00:00
dholland
01e782f371 Revert the following changes:
src/sys/sys/quotactl.h 1.37
   src/sys/compat/netbsd32/netbsd32.h 1.101
   src/sys/compat/netbsd32/netbsd32_netbsd.c 1.188, 1.189
   src/sys/kern/vfs_quotactl.c 1.39
   src/sys/kern/vfs_syscalls.c 1.483
   src/sys/ufs/lfs/ulfs_quota.c 1.11
   src/sys/ufs/ufs/ufs_quota.c 1.116
   src/lib/libquota/quota_kernel.c 1.5

and do them correctly.

If you're going to change the name of something, you need to change
the name of *all* the things with the same name, not just a handful,
and you should change it to something similar so it still matches the
rest of the system rather than just picking an arbitrarily different
name.

Hi, Joerg.

To wit, rename the quotactl "delete" operation to "del", because
"delete" is a reserved word in C++ and for some reason Joerg wants to
run internal interfaces used only by C code through his C++ compiler.
Do not rename it to "remove" instead, because this doesn't match
libquota or the rest of the usage throughout the system; and rename
all the related identifiers, not just the ones that blew the mind of
Joerg's C++ compiler.

Because this is not a user-facing API (the only userland consumer
sys/quotactl.h is libquota) it is sort of ok to make arbitrary
source-incompatible changes; however, by the same token it's completely
unnecessary. If it *were* a user-facing API that someone might have a
semi-rational reason to want to run a C++ compiler on, it would be
incorrect to change it at this point.
2014-06-28 22:27:50 +00:00
christos
9ab46539af Don't initialize the fh pointer to NULL when the allocation functions fail
and allow NULL in the free functions. It just leads to writing sloppy code
for no good reason.
2014-06-26 01:46:03 +00:00
njoly
6b27a22c99 Follow OpenGroup online documents for truncate[1] and ftruncate[2].
Fail with EINVAL for length argument negative values.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html
[2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html
2014-06-14 11:37:35 +00:00
joerg
ef53e37514 Don't t use a C++ keyword as field name. 2014-06-12 21:39:45 +00:00
maxv
6547a55a59 This thing is totally buggy: 'data_len' is modified by the fs, so calling
kmem_free with it while its value has changed since the kmem_alloc is far
from being a good idea.

If the kernel figures out that something mismatches, it will panic
(typically with kernfs).
2014-04-20 21:26:51 +00:00
maxv
4a1b3781e1 Memory leak (only triggerable from root).
ok christos@
2014-04-18 05:22:13 +00:00
maxv
cf89d4e5af Some fs's - like kernfs - set their vfs_min_mount_data to zero. Add a check
to prevent an (un)privileged user from requesting a zero-sized allocation
(and thus a panic).
2014-04-16 19:25:28 +00:00
maxv
23f76b6d00 An (un)privileged user can easily make the kernel dereference a NULL
pointer.

The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).

ok christos@
2014-04-16 18:55:17 +00:00
maxv
18ff15fb2d Limit check for 'data_len'. Otherwise a (un)privileged user can easily
panic the system by passing a huge size.

ok christos@
2014-04-04 06:47:02 +00:00
maxv
2632b9d940 Fix a potential - but very unlikely - NULL pointer dereference.
(it does not introduce a new error code for open(), since
 pathbuf_copyin() is already there and can return ENOMEM)

Found by my code scanner.
2014-03-22 08:15:25 +00:00
njoly
9f120b8d09 Remove argument name from prototype. 2014-02-15 22:32:16 +00:00
christos
cee146c035 Add compat_10, open NULL == open "." 2014-01-25 17:24:45 +00:00
christos
1525b564a7 expose do_open 2014-01-25 02:28:31 +00:00
hannken
04c776e5c8 Change vnode operations create, mknod, mkdir and symlink to return
the resulting vnode *vpp unlocked.

Discussed on tech-kern@

Welcome to 6.99.30
2014-01-23 10:13:55 +00:00
hannken
1139274440 Change vnode operations create, mknod, mkdir and symlink to keep the
directory node dvp locked on return.

Discussed on tech-kern@

Welcome to 6.99.29
2014-01-17 10:55:01 +00:00
christos
9d605174d9 Change the queue.3 *_END(&head) macros to NULL. Since we don't have CIRCLEQ
anymore, all the macros expand to NULL anyway, so this improves readability.
Requested by rmind@
2013-11-27 17:24:43 +00:00
christos
0b725b63c7 change the mountlist CIRCLEQ into a TAILQ 2013-11-23 13:35:36 +00:00
chs
dc00ea6b1e expose various do_*at() functions for compat_linux. 2013-11-18 01:31:42 +00:00
njoly
349036b521 Change mknodat(2) device argument type from uint32_t to dev_t.
Adds needed extra PAD argument for 64bit alignment, and libc wrapper.
2013-10-17 18:01:11 +00:00
njoly
8d578817f8 Remove, in do_sys_renameat(), wrong KASSERTs that check for non NULL
from/to arguments. Such values are correctly handled by later
pathbuf_maybe_copyin() calls, that will fail with EFAULT.

ok from dholland@.
2013-07-20 15:55:57 +00:00
matt
ca47ca8a7a Make do_sys_utimensat public 2013-07-18 14:06:27 +00:00
matt
c537c2aa1b export do_sys_statat for netbsd32 2013-07-18 13:41:08 +00:00
christos
ed4feda3aa don't store random values in retval
http://m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html
2013-06-28 15:32:20 +00:00
dholland
ab137c90f7 Revert defective O_SEARCH implementation committed by manu@ along with
the *at system calls on November 18th of last year. Reasons to revert
it include:
   - it is incorrect in a whole variety of ways (but fortunately, one
     of them is that the missing and improper permission checks have
     no net effect);
   - it was committed without review or discussion;
   - core ruled that all the new O_* flags pertaining to the *at calls
     needed to wait until their semantics could be clarified.

manu was asked to revert it on these grounds but has ignored the request.

I have left O_SEARCH defined and visible and made open() explicitly
ignore it. This way, most code that tries to use it will continue to
build and run. I've also arranged lib/libc/c063/t_o_search.c so that
the tests that make use of the O_SEARCH semantics will disappear until
O_SEARCH comes back, and fixed some mistakes and/or incorrect hacks
that were causing some of these to succeed despite the broken O_SEARCH
implementation.
2013-01-13 08:15:02 +00:00
njoly
6be7ae0a4a Apply fix from hannken to ensure that VOP_ACCESS() is called on a
locked vnode for fd_nameiat(), fd_nameiat_simple() and do_sys_openat().
Fix both PR/47226 and PR/47255.
2012-11-30 13:26:37 +00:00
martin
daab85cca7 Use copyout to copy data from kernel out to userland!
Fixes PR kern/47217.
2012-11-19 15:01:17 +00:00
manu
a76c1cc17f Add most system calls for POSIX extended API set, part 2, with test cases:
faccessat(2), fchmodat(2), fchownat(2), fstatat(2), mkdirat(2), mkfifoat(2),
mknodat(2), linkat(2), readlinkat(2), symlinkat(2), renameat(2), unlinkat(2),
utimensat(2), openat(2).

Also implement O_SEARCH for openat(2)

Still missing:
- some flags for openat(2)
- fexecve(2) implementation
2012-11-18 17:41:51 +00:00
riastradh
8db30059ca No, we can't elide the fs-wide rename lock for same-directory rename.
rename("a/b", "a/c") and rename("a/c/x", "a/b/y") will deadlock.

Darn.
2012-10-19 02:07:22 +00:00
riastradh
a807072402 Disentangle do_sys_rename.
Elide the fs-wide rename lock for single-directory renames.  This
required changing the order of lookups, so that we know what the
directories are before we lock the nodes.

Clean up error branches, explain why various nonsense happens and
what it does and doesn't do, and note some of what needs to change.
2012-10-12 02:37:20 +00:00
cheusov
b6b59f4935 Add new action KAUTH_CRED_CHROOT for kauth(9)'s credential scope.
Reviewed and approved by elad@.
2012-06-27 12:28:28 +00:00
gson
425e23f1fe Move VFS_EXTATTRCTL to mount_domount(). This makes the
fs/puffs/t_fuzz:mountfuzz7, fs/puffs/t_fuzz:mountfuzz8,
and fs/zfs/t_zpool:create tests pass again.  Patch from
manu, discussed on tech-kern and committed at his request.
2012-05-08 08:44:49 +00:00
rmind
d9290bb010 do_open: move pathbuf destruction to the callers, thus simplify and fix a
memory leak on error path.
2012-05-02 20:48:29 +00:00
manu
8658637414 Fix the extattr start fix. Looking up the filesystemroot vnode again
does not seems to be reliable. Instead save it before mount_domount()
sets it to NULL.
2012-04-30 10:05:12 +00:00
manu
74a73d8b5c Fix mount -o extattr : previous patch fixed a panic but caused operation
to happen on the mount point instead of the mounted filesystem.
2012-04-30 03:51:10 +00:00
manu
57f4d08bde Do not use vp after mount_domount() call as it sets it to NULL on success.
This fixes a panic when starting extended attributes.
2012-04-28 17:30:19 +00:00
christos
ec252a38db it is not an error if the kernel needs to clear the setuid/
setgid bit on write/chown/chgrp
2012-04-17 19:15:15 +00:00
elad
0c9d8d15c9 Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

    http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
    http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
    http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
2012-03-13 18:40:26 +00:00
martin
0b454a86a3 fd_open(): fix confusion between userland and kernel encoding of open flags 2012-02-12 13:12:45 +00:00
martin
f8c7c04bbe Add a posix_spawn syscall, as discussed on tech-kern.
Based on the summer of code project by Charles Zhang, heavily reworked
later by me - all bugs are likely mine.
Ok: core, releng.
2012-02-11 23:16:15 +00:00
dholland
832d4ca72b Be consistent about whether idtype and objtype codes are signed or
unsigned. They are signed. (While unsigned might have been a better
choice, it doesn't really matter and the majority of preexisting uses
were signed. And consistency is good.)
2012-02-01 05:46:45 +00:00
dholland
d2d6fa0ae1 Improve the names of some members of struct quotactl_args. These are
effectively function parameter names, but since they need to be
described with the same names in the man page the choices do matter.
Some.
2012-02-01 05:43:53 +00:00
dholland
a90e43f7de Split out a do_sys_quotactl for compat_netbsd32. 2012-02-01 05:39:28 +00:00
dholland
59b296daa7 Change the syscall API for quotas over to the new non-proplib one.
- struct vfs_quotactl_args -> struct quotactl_args
   - add sys/stdint.h to sys/quotactl.h for clean userland build
   - install sys/quotactl.h in /usr/include
   - update set lists for same
   - add new marshalling code in libquota
   - add new unmarshalling code in vfs_syscalls.c
   - discard proplib interpreter code in vfs_quotactl.c
   - add dispatching code for the 14 quotactl ops in vfs_quotactl.c
   - mark the proplib quotactl syscall obsolete
   - add a new syscall number for the new quotactl syscall
   - change the name of the syscall to __quotactl()
   - remove the decl of the old quotactl from quota/quotaprop.h
   - add a decl of the new quotactl to sys/quotactl.h
   - update the libc build
   - update ktruss
   - remove proplib marshalling code from libquota
   - update copy of syscall table in gdb ppc sources
   - hack rumphijack to accomodate new quotactl name (as I recall,
     pooka wanted such a name change to simplify something, but I
     don't really see what/how)

This change appears to require a kernel version bump for rumpish
reasons.
2012-02-01 05:34:38 +00:00
dholland
b0d7bab70f Add vfs_quotactl() in between the syscall and VFS_QUOTACTL. Call it
from the COMPAT_50 code as well as the current sys_quotactl instead
of going directly to VFS_QUOTACTL. Doesn't actually do anything yet.
2012-01-29 06:29:04 +00:00
yamt
32dbfff8e1 fix an indent an unwarp a short line. 2011-12-02 12:30:14 +00:00
christos
953ea7db3e - collect the long (and sometimes incomplete) lists of basic flags into
the header file and use that.
- sort the list of basic flags
- add MNT_RELATIME, ST_RELATIME
- mask all the op flags, for symmetry.

The real bit difference is (which is harmless):
    - mount was missing MNT_EXTATTR
    - update sets MNT_RDONLY twice
    - ops also could or in MNT_GETARGS, but this is impossible because the
      code would have chosen to do getargs then.
2011-11-18 21:17:45 +00:00