summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoranholt <anholt@FreeBSD.org>2003-11-05 23:52:54 +0000
committeranholt <anholt@FreeBSD.org>2003-11-05 23:52:54 +0000
commitb48d22427791719f0585210adb05f8a33eb55708 (patch)
tree1f95fe8b9273c36a25c88eea1b0b7fee57dfa63f /sys
parent0927f68a4503fa8ab92003e394032c483b3c32c5 (diff)
downloadFreeBSD-src-b48d22427791719f0585210adb05f8a33eb55708.zip
FreeBSD-src-b48d22427791719f0585210adb05f8a33eb55708.tar.gz
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
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/linux/linux_stats.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c
index 8d90b1f..ec6e067 100644
--- a/sys/compat/linux/linux_stats.c
+++ b/sys/compat/linux/linux_stats.c
@@ -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);
OpenPOWER on IntegriCloud