NetBSD Problem Report #51731

From www@NetBSD.org  Tue Dec 20 21:15:10 2016
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id A4BFC7A314
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 20 Dec 2016 21:15:10 +0000 (UTC)
Message-Id: <20161220211509.875C97A342@mollari.NetBSD.org>
Date: Tue, 20 Dec 2016 21:15:09 +0000 (UTC)
From: coypu@sdf.org
Reply-To: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Subject: {mustek,scanjet}_read insufficient locking
X-Send-Pr-Version: www-1.0

>Number:         51731
>Category:       kern
>Synopsis:       {mustek,scanjet}_read insufficient locking
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 20 21:20:00 +0000 2016
>Closed-Date:    Sun Feb 26 10:59:17 +0000 2017
>Last-Modified:  Sun Feb 26 11:00:01 +0000 2017
>Originator:     coypu
>Release:        NetBSD 7.99.51
>Organization:
>Environment:
NetBSD box 7.99.51 NetBSD 7.99.51 (GENERIC) #0: Sun Dec 18 07:53:19 IST 2016  fly@box:/usr/amd64/sys/arch/amd64/compile/GENERIC amd64

>Description:
This is not the most critical bug right now (the code seems to be for extremely old hardware), but it's subtle and hard to spot in the current code, so I report this bug as a reminder for its existence.

mustek_read calls scsipi_make_xs_locked with XS_CTL_NOSLEEP, apparently without holding chan_mtx.

this means scsipi_make_xs_locked will not attempt to lock and assumes that the lock is already held.
>How-To-Repeat:

>Fix:
Please add assertions for mutex_owned.
It may not trigger 100% of the times, but it's likely enough to happen that the problem will be spotted.

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Sun, 26 Feb 2017 10:59:17 +0000
State-Changed-Why:
added KDASSERT which is a better reminder.


From: "Maya Rashish" <maya@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51731 CVS commit: src/sys/dev/scsipi
Date: Sun, 26 Feb 2017 10:58:47 +0000

 Module Name:	src
 Committed By:	maya
 Date:		Sun Feb 26 10:58:47 UTC 2017

 Modified Files:
 	src/sys/dev/scsipi: scsipi_base.h

 Log Message:
 Add a DEBUG assert for the problem noted in PR kern/51731
 of some drivers not sufficiently locking.

 The relevant drivers might not work, but if someone gets around to them
 then the problem could be visible.

 sd doesn't trip the assert.


 To generate a diff of this commit:
 cvs rdiff -u -r1.23 -r1.24 src/sys/dev/scsipi/scsipi_base.h

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

>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.