sys/altq: 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.
This commit is contained in:
parent
702ca037aa
commit
30f7ac7ccf
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: altq_hfsc.c,v 1.28 2018/11/15 10:23:55 maxv Exp $ */
|
||||
/* $NetBSD: altq_hfsc.c,v 1.29 2021/08/30 08:40:31 riastradh Exp $ */
|
||||
/* $KAME: altq_hfsc.c,v 1.26 2005/04/13 03:44:24 suz Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -43,7 +43,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: altq_hfsc.c,v 1.28 2018/11/15 10:23:55 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: altq_hfsc.c,v 1.29 2021/08/30 08:40:31 riastradh Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_altq.h"
|
||||
|
@ -2182,6 +2182,7 @@ hfsccmd_class_stats(struct hfsc_class_stats *ap)
|
|||
usp = ap->stats;
|
||||
for (n = 0; cl != NULL && n < nclasses; cl = hfsc_nextclass(cl), n++) {
|
||||
|
||||
memset(&stats, 0, sizeof(stats));
|
||||
get_class_stats(&stats, cl);
|
||||
|
||||
if ((error = copyout((void *)&stats, (void *)usp++,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: altq_priq.c,v 1.26 2018/11/15 10:23:55 maxv Exp $ */
|
||||
/* $NetBSD: altq_priq.c,v 1.27 2021/08/30 08:40:31 riastradh Exp $ */
|
||||
/* $KAME: altq_priq.c,v 1.13 2005/04/13 03:44:25 suz Exp $ */
|
||||
/*
|
||||
* Copyright (C) 2000-2003
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.26 2018/11/15 10:23:55 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.27 2021/08/30 08:40:31 riastradh Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_altq.h"
|
||||
|
@ -958,10 +958,9 @@ priqcmd_class_stats(struct priq_class_stats *ap)
|
|||
usp = ap->stats;
|
||||
for (pri = 0; pri <= pif->pif_maxpri; pri++) {
|
||||
cl = pif->pif_classes[pri];
|
||||
memset(&stats, 0, sizeof(stats));
|
||||
if (cl != NULL)
|
||||
get_class_stats(&stats, cl);
|
||||
else
|
||||
memset(&stats, 0, sizeof(stats));
|
||||
if ((error = copyout((void *)&stats, (void *)usp++,
|
||||
sizeof(stats))) != 0)
|
||||
return (error);
|
||||
|
|
Loading…
Reference in New Issue