diff options
| author | riastradh <riastradh@NetBSD.org> | 2021-09-07 11:43:02 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2021-09-07 11:43:02 +0000 |
| commit | d50c96bb491810004b0fd3ea08acbff05abd6140 (patch) | |
| tree | e16d154152093b1cf3e149fd08f9ae1198e78a9e /sys/compat/linux | |
| parent | 8c28c0027cf16b13c944b0927bedb3108488033d (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')
24 files changed, 106 insertions, 51 deletions
diff --git a/sys/compat/linux/arch/alpha/linux_machdep.c b/sys/compat/linux/arch/alpha/linux_machdep.c index e9ee45107fe..6f86c29dba1 100644 --- a/sys/compat/linux/arch/alpha/linux_machdep.c +++ b/sys/compat/linux/arch/alpha/linux_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_machdep.c,v 1.51 2020/09/03 14:26:31 thorpej Exp $ */ +/* $NetBSD: linux_machdep.c,v 1.52 2021/09/07 11:43:03 riastradh Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.51 2020/09/03 14:26:31 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.52 2021/09/07 11:43:03 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -139,6 +139,8 @@ setup_linux_rt_sigframe(struct trapframe *tf, const ksiginfo_t *ksi, sig, &onstack, sfp); #endif /* DEBUG */ + memset(&sigframe, 0, sizeof(sigframe)); + /* * Build the signal context to be used by sigreturn. */ @@ -232,6 +234,8 @@ void setup_linux_sigframe(struct trapframe *tf, const ksiginfo_t *ksi, sig, &onstack, sfp); #endif /* DEBUG */ + memset(&sigframe, 0, sizeof(sigframe)); + /* * Build the signal context to be used by sigreturn. */ diff --git a/sys/compat/linux/arch/alpha/linux_osf1.c b/sys/compat/linux/arch/alpha/linux_osf1.c index 3575281d1d6..da2cc164906 100644 --- a/sys/compat/linux/arch/alpha/linux_osf1.c +++ b/sys/compat/linux/arch/alpha/linux_osf1.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_osf1.c,v 1.4 2020/10/06 13:38:49 christos Exp $ */ +/* $NetBSD: linux_osf1.c,v 1.5 2021/09/07 11:43:03 riastradh Exp $ */ /* * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_osf1.c,v 1.4 2020/10/06 13:38:49 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_osf1.c,v 1.5 2021/09/07 11:43:03 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -109,6 +109,8 @@ static void osf1_cvt_rusage_from_native(const struct rusage *ru, struct osf1_rusage *oru) { + memset(oru, 0, sizeof(*oru)); + oru->ru_utime.tv_sec = ru->ru_utime.tv_sec; oru->ru_utime.tv_usec = ru->ru_utime.tv_usec; @@ -135,7 +137,7 @@ static void osf1_cvt_statfs_from_native(const struct statvfs *bsfs, struct osf1_statfs *osfs) { - memset(osfs, 0, sizeof (struct osf1_statfs)); + memset(osfs, 0, sizeof(*osfs)); if (!strncmp(MOUNT_FFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename))) osfs->f_type = OSF1_MOUNT_UFS; else if (!strncmp(MOUNT_NFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename))) @@ -665,6 +667,7 @@ linux_sys_osf1_usleep_thread(struct lwp *l, const struct linux_sys_osf1_usleep_t if (endtv.tv_sec < 0 || endtv.tv_usec < 0) endtv.tv_sec = endtv.tv_usec = 0; + memset(&endotv, 0, sizeof(endotv)); endotv.tv_sec = endtv.tv_sec; endotv.tv_usec = endtv.tv_usec; error = copyout(&endotv, SCARG(uap, slept), sizeof endotv); diff --git a/sys/compat/linux/arch/amd64/linux_machdep.c b/sys/compat/linux/arch/amd64/linux_machdep.c index b962a8b0f49..1e9724664df 100644 --- a/sys/compat/linux/arch/amd64/linux_machdep.c +++ b/sys/compat/linux/arch/amd64/linux_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_machdep.c,v 1.59 2019/08/23 10:31:14 maxv Exp $ */ +/* $NetBSD: linux_machdep.c,v 1.60 2021/09/07 11:43:03 riastradh Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -33,7 +33,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.59 2019/08/23 10:31:14 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.60 2021/09/07 11:43:03 riastradh Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -227,6 +227,7 @@ linux_sendsig(const ksiginfo_t *ksi, const sigset_t *mask) if (fpsp != NULL) { size_t fp_size = sizeof fpregs; /* The netbsd and linux structures both match the fxsave data */ + memset(&fpregs, 0, sizeof(fpregs)); (void)process_read_fpregs(l, &fpregs, &fp_size); error = copyout(&fpregs, fpsp, sizeof(*fpsp)); } diff --git a/sys/compat/linux/arch/arm/linux_machdep.c b/sys/compat/linux/arch/arm/linux_machdep.c index 6fca38b74df..a6b2eb83e68 100644 --- a/sys/compat/linux/arch/arm/linux_machdep.c +++ b/sys/compat/linux/arch/arm/linux_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_machdep.c,v 1.33 2021/02/01 19:31:34 skrll Exp $ */ +/* $NetBSD: linux_machdep.c,v 1.34 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1995, 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.33 2021/02/01 19:31:34 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.34 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -107,6 +107,8 @@ linux_sendsig(const ksiginfo_t *ksi, const sigset_t *mask) /* Build stack frame for signal trampoline. */ + memset(&frame, 0, sizeof(frame)); + /* Save register context. */ frame.sf_sc.sc_r0 = tf->tf_r0; frame.sf_sc.sc_r1 = tf->tf_r1; diff --git a/sys/compat/linux/arch/arm/linux_ptrace.c b/sys/compat/linux/arch/arm/linux_ptrace.c index a8e14eab33b..eb17b9d4206 100644 --- a/sys/compat/linux/arch/arm/linux_ptrace.c +++ b/sys/compat/linux/arch/arm/linux_ptrace.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ptrace.c,v 1.22 2020/05/23 23:42:41 ad Exp $ */ +/* $NetBSD: linux_ptrace.c,v 1.23 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.22 2020/05/23 23:42:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.23 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/mount.h> @@ -180,6 +180,7 @@ linux_sys_ptrace_arch(struct lwp *l, const struct linux_sys_ptrace_args *uap, if (error) { break; } + memset(linux_regs, 0, sizeof(*linux_regs)); memcpy(linux_regs->uregs, regs->r, 13 * sizeof(register_t)); linux_regs->uregs[LINUX_REG_SP] = regs->r_sp; linux_regs->uregs[LINUX_REG_LR] = regs->r_lr; diff --git a/sys/compat/linux/arch/i386/linux_machdep.c b/sys/compat/linux/arch/i386/linux_machdep.c index 56349a262b3..e128ef75749 100644 --- a/sys/compat/linux/arch/i386/linux_machdep.c +++ b/sys/compat/linux/arch/i386/linux_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_machdep.c,v 1.167 2021/08/09 19:57:57 andvar Exp $ */ +/* $NetBSD: linux_machdep.c,v 1.168 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1995, 2000, 2008, 2009 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.167 2021/08/09 19:57:57 andvar Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.168 2021/09/07 11:43:04 riastradh Exp $"); #if defined(_KERNEL_OPT) #include "opt_user_ldt.h" @@ -252,6 +252,8 @@ linux_rt_sendsig(const ksiginfo_t *ksi, const sigset_t *mask) onstack, fp, sig, tf->tf_eip, ((struct pcb *)lwp_getpcb(l))->pcb_cr2)); + memset(&frame, 0, sizeof(frame)); + /* Build stack frame for signal trampoline. */ frame.sf_handler = catcher; frame.sf_sig = native_to_linux_signo[sig]; @@ -329,6 +331,8 @@ linux_old_sendsig(const ksiginfo_t *ksi, const sigset_t *mask) onstack, fp, sig, tf->tf_eip, ((struct pcb *)lwp_getpcb(l))->pcb_cr2)); + memset(&frame, 0, sizeof(frame)); + /* Build stack frame for signal trampoline. */ frame.sf_handler = catcher; frame.sf_sig = native_to_linux_signo[sig]; @@ -837,6 +841,7 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist com = VT_OPENQRY; break; case LINUX_VT_GETMODE: + memset(&lvt, 0, sizeof(lvt)); error = fp->f_ops->fo_ioctl(fp, VT_GETMODE, &lvt); if (error != 0) goto out; @@ -932,6 +937,7 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist sectors = label.d_nsectors; } if (com == LINUX_HDIO_GETGEO) { + memset(&hdg, 0, sizeof(hdg)); hdg.start = start; hdg.heads = heads; hdg.cylinders = cylinders; @@ -939,6 +945,7 @@ linux_machdepioctl(struct lwp *l, const struct linux_sys_ioctl_args *uap, regist error = copyout(&hdg, SCARG(uap, data), sizeof hdg); goto out; } else { + memset(&hdg_big, 0, sizeof(hdg_big)); hdg_big.start = start; hdg_big.heads = heads; hdg_big.cylinders = cylinders; diff --git a/sys/compat/linux/arch/i386/linux_ptrace.c b/sys/compat/linux/arch/i386/linux_ptrace.c index 5f41bce017c..3be8ba3b04f 100644 --- a/sys/compat/linux/arch/i386/linux_ptrace.c +++ b/sys/compat/linux/arch/i386/linux_ptrace.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ptrace.c,v 1.34 2020/05/23 23:42:41 ad Exp $ */ +/* $NetBSD: linux_ptrace.c,v 1.35 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.34 2020/05/23 23:42:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.35 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/mount.h> @@ -223,6 +223,7 @@ linux_sys_ptrace_arch(struct lwp *l, const struct linux_sys_ptrace_args *uap, if (error) { break; } + memset(linux_regs, 0, sizeof(*linux_regs)); linux_regs->ebx = regs->r_ebx; linux_regs->ecx = regs->r_ecx; linux_regs->edx = regs->r_edx; diff --git a/sys/compat/linux/arch/m68k/linux_machdep.c b/sys/compat/linux/arch/m68k/linux_machdep.c index 115f9f2e7c1..9c4a2d443ac 100644 --- a/sys/compat/linux/arch/m68k/linux_machdep.c +++ b/sys/compat/linux/arch/m68k/linux_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_machdep.c,v 1.42 2010/07/07 01:30:34 chs Exp $ */ +/* $NetBSD: linux_machdep.c,v 1.43 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.42 2010/07/07 01:30:34 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.43 2021/09/07 11:43:04 riastradh Exp $"); #define COMPAT_LINUX 1 @@ -118,6 +118,8 @@ setup_linux_sigframe(struct frame *frame, int sig, const sigset_t *mask, void *u p->p_pid, sig, &ft, fp, &fp->sf_c.c_sc, ft); #endif + memset(&kf, 0, sizeof(kf)); + /* Build stack frame. */ kf.sf_psigtramp = fp->sf_sigtramp; /* return addr for handler */ kf.sf_signum = native_to_linux_signo[sig]; @@ -280,6 +282,8 @@ setup_linux_rt_sigframe(struct frame *frame, int sig, const sigset_t *mask, void p->p_pid, sig, &ft, fp, &fp->sf_uc, ft); #endif + memset(&kf, 0, sizeof(kf)); + /* Build stack frame. */ kf.sf_psigtramp = fp->sf_sigtramp; /* return addr for handler */ kf.sf_signum = native_to_linux_signo[sig]; diff --git a/sys/compat/linux/arch/mips/linux_machdep.c b/sys/compat/linux/arch/mips/linux_machdep.c index 872d509c734..1fa027e97a4 100644 --- a/sys/compat/linux/arch/mips/linux_machdep.c +++ b/sys/compat/linux/arch/mips/linux_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_machdep.c,v 1.43 2014/11/09 17:48:07 maxv Exp $ */ +/* $NetBSD: linux_machdep.c,v 1.44 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1995, 2000, 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.43 2014/11/09 17:48:07 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.44 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -401,6 +401,7 @@ linux_sys_new_uname(struct lwp *l, const struct linux_sys_new_uname_args *uap, r } */ *uap = v; struct linux_utsname luts; + memset(&luts, 0, sizeof(luts)); strlcpy(luts.l_sysname, linux_sysname, sizeof(luts.l_sysname)); strlcpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); strlcpy(luts.l_release, "2.4.0", sizeof(luts.l_release)); diff --git a/sys/compat/linux/arch/powerpc/linux_exec_powerpc.c b/sys/compat/linux/arch/powerpc/linux_exec_powerpc.c index 4509ccc2eda..3886ea8ea84 100644 --- a/sys/compat/linux/arch/powerpc/linux_exec_powerpc.c +++ b/sys/compat/linux/arch/powerpc/linux_exec_powerpc.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec_powerpc.c,v 1.24 2012/02/21 18:10:00 rjs Exp $ */ +/* $NetBSD: linux_exec_powerpc.c,v 1.25 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_exec_powerpc.c,v 1.24 2012/02/21 18:10:00 rjs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_exec_powerpc.c,v 1.25 2021/09/07 11:43:04 riastradh Exp $"); #define ELFSIZE 32 @@ -93,7 +93,7 @@ ELFNAME2(linux,copyargs)(struct lwp *l, struct exec_package *pack, & ~LINUX_SHIFT); #endif - memset(ai, 0, sizeof(AuxInfo) * LINUX_ELF_AUX_ENTRIES); + memset(ai, 0, sizeof(ai)); a = ai; diff --git a/sys/compat/linux/arch/powerpc/linux_machdep.c b/sys/compat/linux/arch/powerpc/linux_machdep.c index da282bbb84a..de68c1a61b7 100644 --- a/sys/compat/linux/arch/powerpc/linux_machdep.c +++ b/sys/compat/linux/arch/powerpc/linux_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_machdep.c,v 1.50 2017/05/03 00:23:42 chs Exp $ */ +/* $NetBSD: linux_machdep.c,v 1.51 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1995, 2000, 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.50 2017/05/03 00:23:42 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.51 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -162,6 +162,7 @@ linux_sendsig(const ksiginfo_t *ksi, const sigset_t *mask) * * Save register context. */ + memset(&linux_regs, 0, sizeof(linux_regs)); for (i = 0; i < 32; i++) linux_regs.lgpr[i] = tf->tf_fixreg[i]; linux_regs.lnip = tf->tf_srr0; diff --git a/sys/compat/linux/arch/powerpc/linux_ptrace.c b/sys/compat/linux/arch/powerpc/linux_ptrace.c index ca59816a8de..79ac1cc6f8a 100644 --- a/sys/compat/linux/arch/powerpc/linux_ptrace.c +++ b/sys/compat/linux/arch/powerpc/linux_ptrace.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ptrace.c,v 1.32 2020/05/23 23:42:41 ad Exp $ */ +/* $NetBSD: linux_ptrace.c,v 1.33 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.32 2020/05/23 23:42:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_ptrace.c,v 1.33 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/mount.h> @@ -200,6 +200,7 @@ linux_sys_ptrace_arch(struct lwp *l, const struct linux_sys_ptrace_args *uap, if (error) { break; } + memset(linux_regs, 0, sizeof(*linux_regs)); for (i = 0; i <= 31; i++) { linux_regs->lgpr[i] = regs->fixreg[i]; } @@ -309,7 +310,7 @@ linux_sys_ptrace_arch(struct lwp *l, const struct linux_sys_ptrace_args *uap, break; } error = copyout (retval, (void *)SCARG(uap, data), - sizeof(retval)); + sizeof(*retval)); *retval = SCARG(uap, data); break; diff --git a/sys/compat/linux/common/linux_cdrom.c b/sys/compat/linux/common/linux_cdrom.c index 07d84540c02..dbc9b1c45af 100644 --- a/sys/compat/linux/common/linux_cdrom.c +++ b/sys/compat/linux/common/linux_cdrom.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_cdrom.c,v 1.27 2008/04/28 20:23:43 martin Exp $ */ +/* $NetBSD: linux_cdrom.c,v 1.28 2021/09/07 11:43:04 riastradh Exp $ */ /* * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_cdrom.c,v 1.27 2008/04/28 20:23:43 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_cdrom.c,v 1.28 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -186,6 +186,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe if (error) break; + memset(&l_tochdr, 0, sizeof(l_tochdr)); l_tochdr.cdth_trk0 = t_header.starting_track; l_tochdr.cdth_trk1 = t_header.ending_track; @@ -238,6 +239,7 @@ linux_ioctl_cdrom(struct lwp *l, const struct linux_sys_ioctl_args *uap, registe if (error) break; + memset(&l_volctrl, 0, sizeof(l_volctrl)); l_volctrl.channel0 = t_vol.vol[0]; l_volctrl.channel1 = t_vol.vol[1]; l_volctrl.channel2 = t_vol.vol[2]; 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; diff --git a/sys/compat/linux/common/linux_file.c b/sys/compat/linux/common/linux_file.c index e1ca8eff968..36ae0e429b1 100644 --- a/sys/compat/linux/common/linux_file.c +++ b/sys/compat/linux/common/linux_file.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file.c,v 1.118 2020/05/23 23:42:41 ad Exp $ */ +/* $NetBSD: linux_file.c,v 1.119 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.118 2020/05/23 23:42:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.119 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -445,6 +445,7 @@ static void bsd_to_linux_stat(struct stat *bsp, struct linux_stat *lsp) { + memset(lsp, 0, sizeof(*lsp)); lsp->lst_dev = linux_fakedev(bsp->st_dev, 0); lsp->lst_ino = bsp->st_ino; lsp->lst_mode = (linux_mode_t)bsp->st_mode; diff --git a/sys/compat/linux/common/linux_hdio.c b/sys/compat/linux/common/linux_hdio.c index 79300d3ebd0..992f94da8eb 100644 --- a/sys/compat/linux/common/linux_hdio.c +++ b/sys/compat/linux/common/linux_hdio.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_hdio.c,v 1.18 2019/02/03 03:19:26 mrg Exp $ */ +/* $NetBSD: linux_hdio.c,v 1.19 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_hdio.c,v 1.18 2019/02/03 03:19:26 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_hdio.c,v 1.19 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -113,6 +113,7 @@ linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap, error = error1; break; } + memset(&hdg, 0, sizeof(hdg)); hdg.start = error1 != 0 ? pi.pi_offset : 0; hdg.heads = label.d_ntracks; hdg.cylinders = label.d_ncylinders; @@ -131,6 +132,7 @@ linux_ioctl_hdio(struct lwp *l, const struct linux_sys_ioctl_args *uap, error = error1; break; } + memset(&hdg_big, 0, sizeof(hdg_big)); hdg_big.start = error1 != 0 ? pi.pi_offset : 0; hdg_big.heads = label.d_ntracks; hdg_big.cylinders = label.d_ncylinders; 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(<ms, 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)); diff --git a/sys/compat/linux/common/linux_mtio.c b/sys/compat/linux/common/linux_mtio.c index b92051d65f2..8c54725d38d 100644 --- a/sys/compat/linux/common/linux_mtio.c +++ b/sys/compat/linux/common/linux_mtio.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_mtio.c,v 1.7 2008/03/21 21:54:58 ad Exp $ */ +/* $NetBSD: linux_mtio.c,v 1.8 2021/09/07 11:43:04 riastradh Exp $ */ /* * Copyright (c) 2005 Soren S. Jorvang. All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_mtio.c,v 1.7 2008/03/21 21:54:58 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_mtio.c,v 1.8 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -106,6 +106,7 @@ linux_ioctl_mtio(struct lwp *l, const struct linux_sys_ioctl_args *uap, error = ioctlf(fp, MTIOCTOP, &mt); break; case LINUX_MTIOCGET: + memset(&lmtget, 0, sizeof(lmtget)); lmtget.mt_type = LINUX_MT_ISUNKNOWN; lmtget.mt_resid = 0; lmtget.mt_dsreg = 0; diff --git a/sys/compat/linux/common/linux_oldolduname.c b/sys/compat/linux/common/linux_oldolduname.c index c48939d49e5..e356259c70d 100644 --- a/sys/compat/linux/common/linux_oldolduname.c +++ b/sys/compat/linux/common/linux_oldolduname.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldolduname.c,v 1.66 2008/04/28 20:23:43 martin Exp $ */ +/* $NetBSD: linux_oldolduname.c,v 1.67 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_oldolduname.c,v 1.66 2008/04/28 20:23:43 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_oldolduname.c,v 1.67 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -58,6 +58,8 @@ linux_sys_oldolduname(struct lwp *l, const struct linux_sys_oldolduname_args *ua } */ struct linux_oldoldutsname luts; + memset(&luts, 0, sizeof(luts)); + strlcpy(luts.l_sysname, linux_sysname, sizeof(luts.l_sysname)); strlcpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); strlcpy(luts.l_release, linux_release, sizeof(luts.l_release)); diff --git a/sys/compat/linux/common/linux_olduname.c b/sys/compat/linux/common/linux_olduname.c index 20f9cde0581..39dffeaa087 100644 --- a/sys/compat/linux/common/linux_olduname.c +++ b/sys/compat/linux/common/linux_olduname.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_olduname.c,v 1.66 2008/04/28 20:23:43 martin Exp $ */ +/* $NetBSD: linux_olduname.c,v 1.67 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_olduname.c,v 1.66 2008/04/28 20:23:43 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_olduname.c,v 1.67 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -61,6 +61,8 @@ linux_sys_olduname(struct lwp *l, const struct linux_sys_olduname_args *uap, reg } */ struct linux_oldutsname luts; + memset(&luts, 0, sizeof(luts)); + strlcpy(luts.l_sysname, linux_sysname, sizeof(luts.l_sysname)); strlcpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); strlcpy(luts.l_release, linux_release, sizeof(luts.l_release)); diff --git a/sys/compat/linux/common/linux_sched.c b/sys/compat/linux/common/linux_sched.c index ea301c19971..2e1b973d7c7 100644 --- a/sys/compat/linux/common/linux_sched.c +++ b/sys/compat/linux/common/linux_sched.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sched.c,v 1.78 2020/05/23 23:42:41 ad Exp $ */ +/* $NetBSD: linux_sched.c,v 1.79 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1999, 2019 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.78 2020/05/23 23:42:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.79 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/mount.h> @@ -346,6 +346,8 @@ sched_native2linux(int native_policy, struct sched_param *native_params, KASSERT(prio <= SCHED_PRI_MAX); KASSERT(linux_params != NULL); + memset(linux_params, 0, sizeof(*linux_params)); + DPRINTF(("%s: native: policy %d, priority %d\n", __func__, native_policy, prio)); diff --git a/sys/compat/linux/common/linux_signal.c b/sys/compat/linux/common/linux_signal.c index 92b44250ec0..4ab265fc42f 100644 --- a/sys/compat/linux/common/linux_signal.c +++ b/sys/compat/linux/common/linux_signal.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.c,v 1.83 2020/05/23 23:42:41 ad Exp $ */ +/* $NetBSD: linux_signal.c,v 1.84 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.83 2020/05/23 23:42:41 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.84 2021/09/07 11:43:04 riastradh Exp $"); #define COMPAT_LINUX 1 @@ -274,6 +274,8 @@ linux_to_native_sigflags(const unsigned long lsf) void linux_old_to_native_sigaction(struct sigaction *bsa, const struct linux_old_sigaction *lsa) { + + memset(bsa, 0, sizeof(*bsa)); bsa->sa_handler = lsa->linux_sa_handler; linux_old_to_native_sigset(&bsa->sa_mask, &lsa->linux_sa_mask); bsa->sa_flags = linux_to_native_sigflags(lsa->linux_sa_flags); @@ -282,6 +284,8 @@ linux_old_to_native_sigaction(struct sigaction *bsa, const struct linux_old_siga void native_to_linux_old_sigaction(struct linux_old_sigaction *lsa, const struct sigaction *bsa) { + + memset(lsa, 0, sizeof(*lsa)); lsa->linux_sa_handler = bsa->sa_handler; native_to_linux_old_sigset(&lsa->linux_sa_mask, &bsa->sa_mask); lsa->linux_sa_flags = native_to_linux_sigflags(bsa->sa_flags); @@ -294,6 +298,8 @@ native_to_linux_old_sigaction(struct linux_old_sigaction *lsa, const struct siga void linux_to_native_sigaction(struct sigaction *bsa, const struct linux_sigaction *lsa) { + + memset(bsa, 0, sizeof(*bsa)); bsa->sa_handler = lsa->linux_sa_handler; linux_to_native_sigset(&bsa->sa_mask, &lsa->linux_sa_mask); bsa->sa_flags = linux_to_native_sigflags(lsa->linux_sa_flags); @@ -302,6 +308,8 @@ linux_to_native_sigaction(struct sigaction *bsa, const struct linux_sigaction *l void native_to_linux_sigaction(struct linux_sigaction *lsa, const struct sigaction *bsa) { + + memset(lsa, 0, sizeof(*lsa)); lsa->linux_sa_handler = bsa->sa_handler; native_to_linux_sigset(&lsa->linux_sa_mask, &bsa->sa_mask); lsa->linux_sa_flags = native_to_linux_sigflags(bsa->sa_flags); diff --git a/sys/compat/linux/common/linux_socket.c b/sys/compat/linux/common/linux_socket.c index b6e3c637e47..90f1c9c4edf 100644 --- a/sys/compat/linux/common/linux_socket.c +++ b/sys/compat/linux/common/linux_socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.152 2020/11/03 22:08:44 christos Exp $ */ +/* $NetBSD: linux_socket.c,v 1.153 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.152 2020/11/03 22:08:44 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.153 2021/09/07 11:43:04 riastradh Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -440,6 +440,7 @@ linux_sys_sendto(struct lwp *l, const struct linux_sys_sendto_args *uap, registe static void linux_to_bsd_msghdr(const struct linux_msghdr *lmsg, struct msghdr *bmsg) { + memset(bmsg, 0, sizeof(*bmsg)); bmsg->msg_name = lmsg->msg_name; bmsg->msg_namelen = lmsg->msg_namelen; bmsg->msg_iov = lmsg->msg_iov; @@ -452,6 +453,7 @@ linux_to_bsd_msghdr(const struct linux_msghdr *lmsg, struct msghdr *bmsg) static void bsd_to_linux_msghdr(const struct msghdr *bmsg, struct linux_msghdr *lmsg) { + memset(lmsg, 0, sizeof(*lmsg)); lmsg->msg_name = bmsg->msg_name; lmsg->msg_namelen = bmsg->msg_namelen; lmsg->msg_iov = bmsg->msg_iov; @@ -699,6 +701,7 @@ linux_copyout_msg_control(struct lwp *l, struct msghdr *mp, struct mbuf *control * 1. different values for level/type on some archs * 2. different alignment of CMSG_DATA on some archs */ + memset(&linux_cmsg, 0, sizeof(linux_cmsg)); linux_cmsg.cmsg_len = cmsg->cmsg_len - LINUX_CMSG_ALIGN_DELTA; linux_cmsg.cmsg_level = cmsg->cmsg_level; linux_cmsg.cmsg_type = cmsg->cmsg_type; diff --git a/sys/compat/linux/common/linux_time.c b/sys/compat/linux/common/linux_time.c index 7d689ff76a9..62943defd2c 100644 --- a/sys/compat/linux/common/linux_time.c +++ b/sys/compat/linux/common/linux_time.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_time.c,v 1.39 2017/07/29 02:31:22 riastradh Exp $ */ +/* $NetBSD: linux_time.c,v 1.40 2021/09/07 11:43:04 riastradh Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.39 2017/07/29 02:31:22 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.40 2021/09/07 11:43:04 riastradh Exp $"); #include <sys/param.h> #include <sys/ucred.h> @@ -117,6 +117,7 @@ linux_sys_settimeofday(struct lwp *l, const struct linux_sys_settimeofday_args * void native_to_linux_timespec(struct linux_timespec *ltp, struct timespec *ntp) { + memset(ltp, 0, sizeof(*ltp)); ltp->tv_sec = ntp->tv_sec; ltp->tv_nsec = ntp->tv_nsec; } @@ -124,6 +125,7 @@ native_to_linux_timespec(struct linux_timespec *ltp, struct timespec *ntp) void linux_to_native_timespec(struct timespec *ntp, struct linux_timespec *ltp) { + memset(ntp, 0, sizeof(*ntp)); ntp->tv_sec = ltp->tv_sec; ntp->tv_nsec = ltp->tv_nsec; } |
