summaryrefslogtreecommitdiff
path: root/sys/compat/linux/common/linux_fdio.c
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2021-09-07 11:43:02 +0000
committerriastradh <riastradh@NetBSD.org>2021-09-07 11:43:02 +0000
commitd50c96bb491810004b0fd3ea08acbff05abd6140 (patch)
treee16d154152093b1cf3e149fd08f9ae1198e78a9e /sys/compat/linux/common/linux_fdio.c
parent8c28c0027cf16b13c944b0927bedb3108488033d (diff)
sys/compat: Memset zero before copyout.
Just in case of uninitialized padding which would lead to kernel stack disclosure. If the compiler can prove the memset redundant then it can optimize it away; otherwise better safe than sorry.
Diffstat (limited to 'sys/compat/linux/common/linux_fdio.c')
-rw-r--r--sys/compat/linux/common/linux_fdio.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/compat/linux/common/linux_fdio.c b/sys/compat/linux/common/linux_fdio.c
index bf9b5be0590..01593f48f27 100644
--- a/sys/compat/linux/common/linux_fdio.c
+++ b/sys/compat/linux/common/linux_fdio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_fdio.c,v 1.13 2008/03/21 21:54:58 ad Exp $ */
+/* $NetBSD: linux_fdio.c,v 1.14 2021/09/07 11:43:04 riastradh Exp $ */
/*
* Copyright (c) 2000 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_fdio.c,v 1.13 2008/03/21 21:54:58 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_fdio.c,v 1.14 2021/09/07 11:43:04 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -107,6 +107,7 @@ linux_ioctl_fdio(struct lwp *l, const struct linux_sys_ioctl_args *uap,
error = ioctlf(fp, FDIOCGETFORMAT, &fparams);
if (error != 0)
break;
+ memset(&lflop, 0, sizeof(lflop));
lflop.size = fparams.ncyl * fparams.nspt * fparams.ntrk;
lflop.sect = fparams.nspt;
lflop.head = fparams.ntrk;