From 7ee34a31fd24ad081aa2d49b37b599017bd13dc7 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 2 Jan 2017 18:59:23 +0000 Subject: [PATCH] There is no need to use temporary statfs buffer for fsid obliteration and prison enforcement. Do it on the caller buffer directly. Besides eliminating memory copies, this change also removes large structure from the kernel stack. Extracted from: ino64 work by gleb Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/kern/vfs_syscalls.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 9a1c7831b93..b51122aacc3 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -247,7 +247,7 @@ statfs_scale_blocks(struct statfs *sf, long max_size) static int kern_do_statfs(struct thread *td, struct mount *mp, struct statfs *buf) { - struct statfs *sp, sb; + struct statfs *sp; int error; if (mp == NULL) @@ -271,13 +271,11 @@ kern_do_statfs(struct thread *td, struct mount *mp, struct statfs *buf) error = VFS_STATFS(mp, sp); if (error != 0) goto out; - if (priv_check(td, PRIV_VFS_GENERATION)) { - bcopy(sp, &sb, sizeof(sb)); - sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0; - prison_enforce_statfs(td->td_ucred, mp, &sb); - sp = &sb; - } *buf = *sp; + if (priv_check(td, PRIV_VFS_GENERATION)) { + buf->f_fsid.val[0] = buf->f_fsid.val[1] = 0; + prison_enforce_statfs(td->td_ucred, mp, buf); + } out: vfs_unbusy(mp); return (error);