mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Merge back devfs changes from the mpsafetty branch.
In the mpsafetty branch, PTY's are allocated through the posix_openpt()
system call. The controller side of a PTY now uses its own file
descriptor type (just like sockets, vnodes, pipes, etc).
To remain compatible with existing FreeBSD and Linux C libraries, we can
still create PTY's by opening /dev/ptmx or /dev/ptyXX. These nodes
implement d_fdopen(). Devfs has been slightly changed here, to allow
finit() to be called from d_fdopen().
The routine grantpt() has also been moved into the kernel. This routine
is a little odd, because it needs to bypass standard UNIX permissions.
It needs to change the owner/group/mode of the slave device node, which
may often not be possible. The old implementation solved this by
spawning a setuid utility.
When VOP_SETATTR() is called with NOCRED, devfs_setattr() dereferences
ap->a_cred, causing a kernel panic. Change the de_{uid,gid,mode} code to
allow changes when a->a_cred is set to NOCRED.
Approved by: philip (mentor)
This commit is contained in:
parent
33626d7564
commit
34d1dcf0cc
1 changed files with 6 additions and 6 deletions
|
|
@ -891,9 +891,8 @@ devfs_open(struct vop_open_args *ap)
|
|||
if(fp == NULL)
|
||||
return (error);
|
||||
#endif
|
||||
KASSERT(fp->f_ops == &badfileops,
|
||||
("Could not vnode bypass device on fdops %p", fp->f_ops));
|
||||
finit(fp, fp->f_flag, DTYPE_VNODE, dev, &devfs_ops_f);
|
||||
if (fp->f_ops == &badfileops)
|
||||
finit(fp, fp->f_flag, DTYPE_VNODE, dev, &devfs_ops_f);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
|
@ -1265,8 +1264,9 @@ devfs_setattr(struct vop_setattr_args *ap)
|
|||
else
|
||||
gid = vap->va_gid;
|
||||
if (uid != de->de_uid || gid != de->de_gid) {
|
||||
if ((ap->a_cred->cr_uid != de->de_uid) || uid != de->de_uid ||
|
||||
(gid != de->de_gid && !groupmember(gid, ap->a_cred))) {
|
||||
if (ap->a_cred != NOCRED &&
|
||||
(ap->a_cred->cr_uid != de->de_uid || uid != de->de_uid ||
|
||||
(gid != de->de_gid && !groupmember(gid, ap->a_cred)))) {
|
||||
error = priv_check(ap->a_td, PRIV_VFS_CHOWN);
|
||||
if (error)
|
||||
return (error);
|
||||
|
|
@ -1277,7 +1277,7 @@ devfs_setattr(struct vop_setattr_args *ap)
|
|||
}
|
||||
|
||||
if (vap->va_mode != (mode_t)VNOVAL) {
|
||||
if (ap->a_cred->cr_uid != de->de_uid) {
|
||||
if (ap->a_cred != NOCRED && ap->a_cred->cr_uid != de->de_uid) {
|
||||
error = priv_check(ap->a_td, PRIV_VFS_ADMIN);
|
||||
if (error)
|
||||
return (error);
|
||||
|
|
|
|||
Loading…
Reference in a new issue