Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/dkwedge dk(4): Explain why dk_rawopens can't overflo...
details: https://anonhg.NetBSD.org/src/rev/9d2e1cd905d8
branches: trunk
changeset: 374248:9d2e1cd905d8
user: riastradh <riastradh%NetBSD.org@localhost>
date: Thu Apr 13 08:30:40 2023 +0000
description:
dk(4): Explain why dk_rawopens can't overflow and assert it.
diffstat:
sys/dev/dkwedge/dk.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diffs (32 lines):
diff -r 95d3bb202231 -r 9d2e1cd905d8 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c Thu Apr 13 07:03:31 2023 +0000
+++ b/sys/dev/dkwedge/dk.c Thu Apr 13 08:30:40 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dk.c,v 1.124 2022/09/27 17:04:52 mlelstv Exp $ */
+/* $NetBSD: dk.c,v 1.125 2023/04/13 08:30:40 riastradh Exp $ */
/*-
* Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.124 2022/09/27 17:04:52 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.125 2023/04/13 08:30:40 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_dkwedge.h"
@@ -1200,7 +1200,13 @@ dkfirstopen(struct dkwedge_softc *sc, in
} else {
/*
* Retrieve mode from an already opened wedge.
+ *
+ * At this point, dk_rawopens is bounded by the number
+ * of dkwedge devices in the system, which is limited
+ * by autoconf device numbering to INT_MAX. Since
+ * dk_rawopens is unsigned, this can't overflow.
*/
+ KASSERT(sc->sc_parent->dk_rawopens < UINT_MAX);
mode = 0;
LIST_FOREACH(nsc, &sc->sc_parent->dk_wedges, sc_plink) {
if (nsc == sc || nsc->sc_dk.dk_openmask == 0)
Home |
Main Index |
Thread Index |
Old Index