From a6e0e217b2f0f56ca79b81d2969a21d07a1d5039 Mon Sep 17 00:00:00 2001 From: pjd Date: Sun, 22 May 2005 21:52:30 +0000 Subject: If we need to hide fsid, kern_statfs()/kern_fstatfs() will do it for us, so do not duplicate the code in cvtstatfs(). Note, that we now need to clear fsid in freebsd4_getfsstat(). This moves all security related checks from functions like cvtstatfs() and will allow to add more security related stuff (like statfs(2), etc. protection for jails) a bit easier. --- sys/compat/linux/linux_stats.c | 9 ++------- sys/kern/vfs_extattr.c | 8 +++----- sys/kern/vfs_syscalls.c | 8 +++----- 3 files changed, 8 insertions(+), 17 deletions(-) (limited to 'sys') diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index 6a51b1c..f446ec6 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -237,13 +237,8 @@ bsd_to_linux_statfs(struct thread *td, struct statfs *bsd_statfs, linux_statfs->f_bavail = bsd_statfs->f_bavail; linux_statfs->f_ffree = bsd_statfs->f_ffree; linux_statfs->f_files = bsd_statfs->f_files; - 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_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; } diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index fc04e64..3e8c968 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -557,6 +557,8 @@ freebsd4_getfsstat(td, uap) } sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; cvtstatfs(td, sp, &osb); + if (suser(td)) + osb.f_fsid.val[0] = osb.f_fsid.val[1] = 0; error = copyout(&osb, sfsp, sizeof(osb)); if (error) { vfs_unbusy(mp, td); @@ -639,11 +641,7 @@ cvtstatfs(td, nsp, osp) MIN(MFSNAMELEN, OMNAMELEN)); bcopy(nsp->f_mntfromname, osp->f_mntfromname, MIN(MFSNAMELEN, OMNAMELEN)); - if (suser(td)) { - osp->f_fsid.val[0] = osp->f_fsid.val[1] = 0; - } else { - osp->f_fsid = nsp->f_fsid; - } + osp->f_fsid = nsp->f_fsid; } #endif /* COMPAT_FREEBSD4 */ diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index fc04e64..3e8c968 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -557,6 +557,8 @@ freebsd4_getfsstat(td, uap) } sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; cvtstatfs(td, sp, &osb); + if (suser(td)) + osb.f_fsid.val[0] = osb.f_fsid.val[1] = 0; error = copyout(&osb, sfsp, sizeof(osb)); if (error) { vfs_unbusy(mp, td); @@ -639,11 +641,7 @@ cvtstatfs(td, nsp, osp) MIN(MFSNAMELEN, OMNAMELEN)); bcopy(nsp->f_mntfromname, osp->f_mntfromname, MIN(MFSNAMELEN, OMNAMELEN)); - if (suser(td)) { - osp->f_fsid.val[0] = osp->f_fsid.val[1] = 0; - } else { - osp->f_fsid = nsp->f_fsid; - } + osp->f_fsid = nsp->f_fsid; } #endif /* COMPAT_FREEBSD4 */ -- cgit v1.1