Home | History | Annotate | Download | only in kern
History log of /src/sys/kern/kern_ktrace_vfs.c
RevisionDateAuthorComments
 1.3  29-Jun-2021  dholland 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.)
 1.2  05-Sep-2014  matt branches: 1.2.36;
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
 1.1  09-Dec-2013  pooka branches: 1.1.4; 1.1.6; 1.1.10;
Put vfs bits of ktrace into kern_ktrace_vfs.c per convention.
 1.1.10.3  03-Dec-2017  jdolecek update from HEAD
 1.1.10.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1  09-Dec-2013  tls file kern_ktrace_vfs.c was added on branch tls-maxphys on 2014-08-20 00:04:29 +0000
 1.1.6.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.1  09-Dec-2013  yamt file kern_ktrace_vfs.c was added on branch yamt-pagecache on 2014-05-22 11:41:03 +0000
 1.1.4.2  18-May-2014  rmind sync with head
 1.1.4.1  09-Dec-2013  rmind file kern_ktrace_vfs.c was added on branch rmind-smpnet on 2014-05-18 17:46:07 +0000
 1.2.36.1  01-Aug-2021  thorpej Sync with HEAD.

RSS XML Feed