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): dkclose must handle a dying wedge too...



details:   https://anonhg.NetBSD.org/src/rev/21360d29d748
branches:  trunk
changeset: 374648:21360d29d748
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue May 09 12:03:55 2023 +0000

description:
dk(4): dkclose must handle a dying wedge too to close the parent.

Otherwise the parent open leaks on detach (or revoke) when the wedge
was open and had to be forcibly closed.

Reported-by: syzbot+e46f31fe56e04f567d88%syzkaller.appspotmail.com@localhost
https://syzkaller.appspot.com/bug?id=8a00fd7f2e7459748d7a274098180a4708ff0f61

Fixes assertion sc->sc_dk.dk_openmask == 0.

diffstat:

 sys/dev/dkwedge/dk.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r a0b7b2c3e9a6 -r 21360d29d748 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Tue May 09 10:49:46 2023 +0000
+++ b/sys/dev/dkwedge/dk.c      Tue May 09 12:03:55 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.152 2023/04/29 13:00:17 riastradh Exp $       */
+/*     $NetBSD: dk.c,v 1.153 2023/05/09 12:03:55 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.152 2023/04/29 13:00:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.153 2023/05/09 12:03:55 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1385,7 +1385,8 @@ dkclose(dev_t dev, int flags, int fmt, s
 
        if (sc == NULL)
                return ENXIO;
-       if (sc->sc_state != DKW_STATE_RUNNING)
+       if (sc->sc_state != DKW_STATE_RUNNING &&
+           sc->sc_satte != DKW_STATE_DYING)
                return ENXIO;
 
        mutex_enter(&sc->sc_dk.dk_openlock);



Home | Main Index | Thread Index | Old Index