Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev It is not sufficient to have a comment /* Sanity che...
details: https://anonhg.NetBSD.org/src/rev/cad9a1eaf735
branches: trunk
changeset: 373015:cad9a1eaf735
user: hannken <hannken%NetBSD.org@localhost>
date: Fri Jan 13 15:46:40 2023 +0000
description:
It is not sufficient to have a comment /* Sanity check the size. */,
also check the size is greater than zero and a multiple of DEV_BSIZE.
Reported-by: syzbot+318187e5124846542f8d%syzkaller.appspotmail.com@localhost
diffstat:
sys/dev/md.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diffs (34 lines):
diff -r 5b16cac6049c -r cad9a1eaf735 sys/dev/md.c
--- a/sys/dev/md.c Thu Jan 12 19:17:11 2023 +0000
+++ b/sys/dev/md.c Fri Jan 13 15:46:40 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: md.c,v 1.86 2022/09/24 23:20:13 thorpej Exp $ */
+/* $NetBSD: md.c,v 1.87 2023/01/13 15:46:40 hannken Exp $ */
/*
* Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.86 2022/09/24 23:20:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.87 2023/01/13 15:46:40 hannken Exp $");
#ifdef _KERNEL_OPT
#include "opt_md.h"
@@ -589,10 +589,13 @@
vaddr_t addr;
vsize_t size;
+ /* Sanity check the size. */
+ size = umd->md_size;
+ if (size < DEV_BSIZE || (size % DEV_BSIZE) != 0)
+ return EINVAL;
+
mutex_exit(&sc->sc_lock);
- /* Sanity check the size. */
- size = umd->md_size;
addr = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
mutex_enter(&sc->sc_lock);
Home |
Main Index |
Thread Index |
Old Index