summaryrefslogtreecommitdiff
path: root/sys/compat/linux/common/linux_misc.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_misc.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_misc.c')
-rw-r--r--sys/compat/linux/common/linux_misc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/compat/linux/common/linux_misc.c b/sys/compat/linux/common/linux_misc.c
index 4b94795bb21..bb05299d4c0 100644
--- a/sys/compat/linux/common/linux_misc.c
+++ b/sys/compat/linux/common/linux_misc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_misc.c,v 1.251 2020/06/11 22:21:05 ad Exp $ */
+/* $NetBSD: linux_misc.c,v 1.252 2021/09/07 11:43:04 riastradh Exp $ */
/*-
* Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.251 2020/06/11 22:21:05 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.252 2021/09/07 11:43:04 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -629,6 +629,8 @@ linux_sys_times(struct lwp *l, const struct linux_sys_times_args *uap, register_
struct linux_tms ltms;
struct rusage ru;
+ memset(&ltms, 0, sizeof(ltms));
+
mutex_enter(p->p_lock);
calcru(p, &ru.ru_utime, &ru.ru_stime, NULL, NULL);
ltms.ltms_utime = CONVTCK(ru.ru_utime);
@@ -1399,6 +1401,7 @@ linux_sys_getrlimit(struct lwp *l, const struct linux_sys_getrlimit_args *uap, r
if (which < 0)
return -which;
+ memset(&orl, 0, sizeof(orl));
bsd_to_linux_rlimit(&orl, &l->l_proc->p_rlimit[which]);
return copyout(&orl, SCARG(uap, rlp), sizeof(orl));