Pull up following revision(s) (requested by riastradh in ticket #1488):

sys/altq/altq_hfsc.c: revision 1.29
	sys/altq/altq_priq.c: revision 1.27

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:
martin 2022-08-03 11:01:51 +00:00
parent a1623e3d21
commit 7eb57b8476
2 changed files with 6 additions and 6 deletions

View File

@ -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.28.4.1 2022/08/03 11:01:51 martin 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.28.4.1 2022/08/03 11:01:51 martin 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++,

View File

@ -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.26.4.1 2022/08/03 11:01:51 martin 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.26.4.1 2022/08/03 11:01:51 martin 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);