NetBSD Problem Report #43032

From www@NetBSD.org  Sun Mar 21 11:09:42 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 66CB663C49B
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 21 Mar 2010 11:09:42 +0000 (UTC)
Message-Id: <20100321110942.11D8463B86C@www.NetBSD.org>
Date: Sun, 21 Mar 2010 11:09:42 +0000 (UTC)
From: ad@netbsd.org
Reply-To: ad@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: dtrace module load/unload is broken
X-Send-Pr-Version: www-1.0

>Number:         43032
>Category:       kern
>Synopsis:       dtrace module load/unload is broken
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pgoyette
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 21 11:10:06 +0000 2010
>Closed-Date:    Sat Nov 28 22:47:23 +0000 2015
>Last-Modified:  Sat Nov 28 22:47:23 +0000 2015
>Originator:     Andrew Doran
>Release:        -current
>Organization:
The NetBSD Project
>Environment:
>Description:
     33 	switch (cmd) {
     34 	case MODULE_CMD_INIT:
     35 		dtrace_load(NULL);
     36 		return devsw_attach("dtrace", NULL, &bmajor,
     37 		    &dtrace_cdevsw, &cmajor);

If devsw_attach() fails, we should be calling dtrace_unload() before
returning error to user.  panic() if dtrace_unload() fails.

     38 	case MODULE_CMD_FINI:
     39 		dtrace_unload();
     40 		return devsw_detach(NULL, &dtrace_cdevsw);

This would typically be in reverse order.  So devsw_detach() first to
lock out new access, and bail out early with an error if that fails.

The return value of dtrace_unload() is not being checked.  So we can
remove the module from memory if dtrace is still in use.  To fix:

If dtrace_unload() fails, device switch vector should be re-instated
using devsw_attach() before returning error from dtrace_unload().
panic() if devsw_attach() fails.


>How-To-Repeat:
Code inspection.
>Fix:
See above.

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->pgoyette
Responsible-Changed-By: pgoyette@NetBSD.org
Responsible-Changed-When: Sat, 28 Nov 2015 04:24:55 +0000
Responsible-Changed-Why:
I will investigate.


From: "Paul Goyette" <pgoyette@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/43032 CVS commit: src/external/cddl/osnet/dev/dtrace
Date: Sat, 28 Nov 2015 22:41:36 +0000

 Module Name:	src
 Committed By:	pgoyette
 Date:		Sat Nov 28 22:41:36 UTC 2015

 Modified Files:
 	src/external/cddl/osnet/dev/dtrace: dtrace_modevent.c

 Log Message:
 When loading the module, if devsw_attach() fails, call dtrace_unload()
 to undo the effects of dtrace_load().  And if dtrace_unload() fails,
 panic (since we can't get the system back to its earlier stable state).

 When unloading the module, call devsw_detach() first, to lock out any
 new access.  Then call dtrace_unload().  If dgtrace_unload() fails,
 reattach the devsw, and if that fails, panic.

 Implements fixes described in PR kern/43032


 To generate a diff of this commit:
 cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: pgoyette@NetBSD.org
State-Changed-When: Sat, 28 Nov 2015 22:47:23 +0000
State-Changed-Why:
Suggested changes were committed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.