Prevent leaking of fsid to non-root users in linux_statfs and linux_fstatfs.
Matches native syscalls now. PR: kern/58793 Submitted by: David P. Reese Jr. <daver@gomerbud.com> MFC after: 1 week
This commit is contained in:
parent
0927f68a45
commit
b48d224277
@ -268,8 +268,13 @@ linux_statfs(struct thread *td, struct linux_statfs_args *args)
|
||||
linux_statfs.f_bavail = bsd_statfs->f_bavail;
|
||||
linux_statfs.f_ffree = bsd_statfs->f_ffree;
|
||||
linux_statfs.f_files = bsd_statfs->f_files;
|
||||
linux_statfs.f_fsid.val[0] = bsd_statfs->f_fsid.val[0];
|
||||
linux_statfs.f_fsid.val[1] = bsd_statfs->f_fsid.val[1];
|
||||
if (suser(td)) {
|
||||
linux_statfs.f_fsid.val[0] = 0;
|
||||
linux_statfs.f_fsid.val[1] = 0;
|
||||
} else {
|
||||
linux_statfs.f_fsid.val[0] = bsd_statfs->f_fsid.val[0];
|
||||
linux_statfs.f_fsid.val[1] = bsd_statfs->f_fsid.val[1];
|
||||
}
|
||||
linux_statfs.f_namelen = MAXNAMLEN;
|
||||
return copyout(&linux_statfs, args->buf, sizeof(linux_statfs));
|
||||
}
|
||||
@ -312,8 +317,13 @@ linux_fstatfs(struct thread *td, struct linux_fstatfs_args *args)
|
||||
linux_statfs.f_bavail = bsd_statfs->f_bavail;
|
||||
linux_statfs.f_ffree = bsd_statfs->f_ffree;
|
||||
linux_statfs.f_files = bsd_statfs->f_files;
|
||||
linux_statfs.f_fsid.val[0] = bsd_statfs->f_fsid.val[0];
|
||||
linux_statfs.f_fsid.val[1] = bsd_statfs->f_fsid.val[1];
|
||||
if (suser(td)) {
|
||||
linux_statfs.f_fsid.val[0] = 0;
|
||||
linux_statfs.f_fsid.val[1] = 0;
|
||||
} else {
|
||||
linux_statfs.f_fsid.val[0] = bsd_statfs->f_fsid.val[0];
|
||||
linux_statfs.f_fsid.val[1] = bsd_statfs->f_fsid.val[1];
|
||||
}
|
||||
linux_statfs.f_namelen = MAXNAMLEN;
|
||||
error = copyout(&linux_statfs, args->buf, sizeof(linux_statfs));
|
||||
fdrop(fp, td);
|
||||
|
Loading…
Reference in New Issue
Block a user