Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src



Module Name:    src
Committed By:   dholland
Date:           Tue Jun 29 22:40:54 UTC 2021

Modified Files:
        src/external/cddl/osnet/sys/sys: vnode.h
        src/share/man/man9: errno.9 vnsubr.9
        src/sys/dev: firmload.c fss.c kloader.c vnd.c
        src/sys/kern: kern_acct.c kern_core.c kern_descrip.c kern_ktrace_vfs.c
            kern_module_vfs.c subr_exec_fd.c subr_kobj_vfs.c tty_ptm.c
            vfs_syscalls.c vfs_vnops.c
        src/sys/miscfs/fdesc: fdesc_vnops.c
        src/sys/modules/lua: lua.c
        src/sys/sys: filedesc.h vnode.h
        src/sys/ufs/lfs: ulfs_extattr.c ulfs_quota1.c
        src/sys/ufs/ufs: ufs_extattr.c ufs_quota1.c

Log Message:
Add containment for the cloning devices hack in vn_open.

Cloning devices (and also things like /dev/stderr) work by allocating
a struct file, stuffing it in the file table (which is a layer
violation), stuffing the file descriptor number for it in a magic
field of struct lwp (which is gross), and then "failing" with one of
two magic errnos, EDUPFD or EMOVEFD.

Before this commit, all callers of vn_open in the kernel (there are
quite a few) were expected to check for these errors and handle the
situation. Needless to say, none of them except for open() itself did,
resulting in internal negative errnos being returned to userspace.

This hack is fairly deeply rooted and cannot be eliminated all at
once. This commit adds logic to handle the magic errnos inside
vn_open; now on success vn_open returns either a vnode or an integer
file descriptor, along with a flag that says whether the underlying
code requested EDUPFD or EMOVEFD. Callers not prepared to cope with
file descriptors can pass NULL for the extra return values, in which
case if a file descriptor would be produced vn_open fails with
EOPNOTSUPP.

Since I'm rearranging vn_open's signature anyway, stop exposing struct
nameidata. Instead, take three arguments: an optional vnode to use as
the starting point (like openat()), the path, and additional namei
flags to use, restricted to NOCHROOT and TRYEMULROOT. (Other namei
behavior, e.g. NOFOLLOW, can be requested via the open flags.)

This change requires a kernel bump. Ride the one an hour ago.
(That was supposed to be coordinated; did not intend to let an hour
slip by. My fault.)


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/external/cddl/osnet/sys/sys/vnode.h
cvs rdiff -u -r1.5 -r1.6 src/share/man/man9/errno.9
cvs rdiff -u -r1.47 -r1.48 src/share/man/man9/vnsubr.9
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/firmload.c
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/fss.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/kloader.c
cvs rdiff -u -r1.281 -r1.282 src/sys/dev/vnd.c
cvs rdiff -u -r1.97 -r1.98 src/sys/kern/kern_acct.c
cvs rdiff -u -r1.34 -r1.35 src/sys/kern/kern_core.c
cvs rdiff -u -r1.250 -r1.251 src/sys/kern/kern_descrip.c
cvs rdiff -u -r1.2 -r1.3 src/sys/kern/kern_ktrace_vfs.c
cvs rdiff -u -r1.17 -r1.18 src/sys/kern/kern_module_vfs.c
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/subr_exec_fd.c \
    src/sys/kern/subr_kobj_vfs.c
cvs rdiff -u -r1.42 -r1.43 src/sys/kern/tty_ptm.c
cvs rdiff -u -r1.549 -r1.550 src/sys/kern/vfs_syscalls.c
cvs rdiff -u -r1.215 -r1.216 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.137 -r1.138 src/sys/miscfs/fdesc/fdesc_vnops.c
cvs rdiff -u -r1.24 -r1.25 src/sys/modules/lua/lua.c
cvs rdiff -u -r1.68 -r1.69 src/sys/sys/filedesc.h
cvs rdiff -u -r1.296 -r1.297 src/sys/sys/vnode.h
cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/lfs/ulfs_extattr.c
cvs rdiff -u -r1.11 -r1.12 src/sys/ufs/lfs/ulfs_quota1.c
cvs rdiff -u -r1.52 -r1.53 src/sys/ufs/ufs/ufs_extattr.c
cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/ufs/ufs_quota1.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index