Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Check INITED state by default for all ioctls but VND...
details: https://anonhg.NetBSD.org/src/rev/3159d5b577a8
branches: trunk
changeset: 364487:3159d5b577a8
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Mon Mar 28 11:16:59 2022 +0000
description:
Check INITED state by default for all ioctls but VNDIOCSET. Avoids crashes
with disk_ioctls on default unit, which is not INITED.
Fixes PR 56700.
diffstat:
sys/dev/vnd.c | 36 +++++++++++-------------------------
1 files changed, 11 insertions(+), 25 deletions(-)
diffs (69 lines):
diff -r f2422fe66ff4 -r 3159d5b577a8 sys/dev/vnd.c
--- a/sys/dev/vnd.c Mon Mar 28 11:09:24 2022 +0000
+++ b/sys/dev/vnd.c Mon Mar 28 11:16:59 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnd.c,v 1.283 2021/07/24 21:31:36 andvar Exp $ */
+/* $NetBSD: vnd.c,v 1.284 2022/03/28 11:16:59 mlelstv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008, 2020 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.283 2021/07/24 21:31:36 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.284 2022/03/28 11:16:59 mlelstv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_vnd.h"
@@ -1226,41 +1226,27 @@
return EBADF;
}
- /* Must be initialized for these... */
switch (cmd) {
- case VNDIOCCLR:
- case VNDIOCCLR50:
- case DIOCGDINFO:
- case DIOCSDINFO:
- case DIOCWDINFO:
- case DIOCGPARTINFO:
- case DIOCKLABEL:
- case DIOCWLABEL:
- case DIOCGDEFLABEL:
- case DIOCGCACHE:
- case DIOCGSTRATEGY:
- case DIOCCACHESYNC:
-#ifdef __HAVE_OLD_DISKLABEL
- case ODIOCGDINFO:
- case ODIOCSDINFO:
- case ODIOCWDINFO:
- case ODIOCGDEFLABEL:
-#endif
+ case VNDIOCSET50:
+ case VNDIOCSET:
+ /* Must not be initialized */
+ if (vnd->sc_flags & VNF_INITED)
+ return EBUSY;
+ break;
+ default:
+ /* Must be initialized */
if ((vnd->sc_flags & VNF_INITED) == 0)
return ENXIO;
+ break;
}
error = disk_ioctl(&vnd->sc_dkdev, dev, cmd, data, flag, l);
if (error != EPASSTHROUGH)
return error;
-
switch (cmd) {
case VNDIOCSET50:
case VNDIOCSET:
- if (vnd->sc_flags & VNF_INITED)
- return EBUSY;
-
if ((error = vndlock(vnd)) != 0)
return error;
Home |
Main Index |
Thread Index |
Old Index