NetBSD Problem Report #41704

From bad@bsd.de  Sun Jul 12 13:34:45 2009
Return-Path: <bad@bsd.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id DF70863B913
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 12 Jul 2009 13:34:44 +0000 (UTC)
Message-Id: <20090712133437.D9ACE122A3@sanctioned-parts-list.k.bsd.de>
Date: Sun, 12 Jul 2009 13:34:37 +0000 (UTC)
From: bad@bsd.de
Reply-To: bad@bsd.de
To: gnats-bugs@gnats.NetBSD.org
Subject: configuring cgd1 makes bogus access on cgd0
X-Send-Pr-Version: 3.95

>Number:         41704
>Category:       kern
>Synopsis:       configuring cgd1 causes read to be attempted on cgd0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          feedback
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 12 13:35:00 +0000 2009
>Closed-Date:    
>Last-Modified:  Tue Apr 21 17:31:22 +0000 2020
>Originator:     Christoph Badura
>Release:        NetBSD 5.0_STABLE as of 2009-07-02
>Organization:
netbsd bozotic software test labs

>Environment:


System: NetBSD sanctioned-parts-list 5.0_STABLE NetBSD 5.0_STABLE (GENERIC) #0: Thu Jul 2 18:47:45 UTC 2009 root@arbitrary:/m/obj/m/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:

I have a system with 2 cgds configured on two raidframe RAID 1 devices on 2
9GB and two 50GB SCSI disks.
When going multi-user the kernel complains
cgd0: error 22
when configuring the cgds.

This can be trace to configuring cgd1.  E.g. boot single-user, configure the
raids and configure the cgds:

# cgdconfig cgd0 /dev/raid0e
# cgdconfig cgd1 /dev/raid1a
cgd0: error 22
# cgdconfig -u cgd1
# cgdconfig cgd1 /dev/raid1a
cgd0: error 22

etc. ad nauseam.

Running a kernel compiled with CGDDEBUG and cgddebug set to 3 reveals the
following bogus read:

cgd_cipher() dir=1
getcgd_softc(0x3): unit = 0
cgdstrategy(0xc32a9570): b_bcount = 512
cgdstart(0xc31bb400, 0xc32a9570)
getcgd_softc(0x3): unit = 0
cgdiodone(0xc3127ec8)
cgdiodone: bp 0xc32a9570 bcount 512 resid 512
 dev 0x1204, nbp 0xc3127ec8 bn 97693565 addr 0xcd73fc00 bcnt 512
cgd0: error 22

Note that the block number of the request is the last block of the raid1a
partition on which cgd1 is created.

For reference the relevant disktab entries:

hp9.1g|HP9.1G oemed IBM DDYS 9GB disk:\
	:ty=winchester:dt=SCSI:\
	:se#512:ns#392:nt#3:sc#1176:nc#15110:\
	:su#17773524:rm#10000:\
	:pd#17773524:od#0:
st150176|SEAGATE ST150176LC:\
	:ty=winchester:dt=SCSI:\
	:se#512:ns#369:nt#22:sc#8118:nc#12024:\
	:su#97693755:rm#7200:\
	:pd#97693755:od#0:
hp9.1g-boot|HP9.1G boot disk with large RAID partition:\
	:pc#17773461:oc#63:\
	:pa#17248329:oa#63:ta=RAID:\
	:pb#525132:ob#17248392:tb=swap:\
	:tc=hp9.1g:
hp9.1g-boot-raid|boot raid with root fs and large CGD partition:\
	:dt=RAID:se#512:ns#128:nt#8:sc#1024:nc#16845:\
	:su#17248256:rm#10000:\
	:pd#17248256:od#0:\
	:pc#17248256:oc#0:\
	:pa#262144:oa#0:ta=4.2BSD:ba#8192:fa#1024:\
	:pe#16986112:oe#262144:te=ccd:
hp9.1g-boot-cgd|cgd partiton on hp9.1g-boot-raid:\
	:dt=cgd:se#512:ns#2048:nt#1:sc#2048:nc#8294:\
	:su#16986112:rm#10000:\
	:pd#16986112:od#0:\
	:pc#16986112:oc#0:\
	:pa#2097152:oa#0:ta=4.2BSD:ba#8192:fa#1024:\
	:pe#1048576:oe#2097152:te=4.2BSD:be#8192:fe#1024:\
	:pf#13840384:of#3145728:tf=4.2BSD:bf#8192:ff#1024:
seagate50g-app|SEAGATE ST150176LC application disk:\
	:pc#97693755:oc#0:\
	:pa#97693755:oa#0:ta=RAID:\
	:tc=st150176:
seagate50g-app-raid|raid partition on seagate50g-app:\
	:dt=RAID:se#512:ns#128:nt#8:sc#1024:nc#95404:\
	:su#97693568:rm#7200:\
	:pd#97693568:od#0:\
	:pa#97693566:oa#2:ta=ccd:
seagate50g-app-cgd|cgd partition on seagate50g-app-raid:\
	:dt=cgd:se#512:ns#2048:nt#1:sc#2048:nc#47936:\
	:su#97693566:rm#7200:\
	:pd#97693566:od#0:\
	:pa#97693564:oa#2:ta=4.2BSD:ba#16384:fa#2048:

And example cgd config files:

/etc/cgd/cgd.conf:
cgd0 /dev/raid0e
cgd1 /dev/raid1a

/etc/cgd/raid0e:
algorithm aes-cbc;
iv-method encblkno1;
keylength 128;
verify_method disklabel;
keygen storedkey key hogehogehogehoge;

/etc/cgd/raid1a:
algorithm aes-cbc;
iv-method encblkno1;
keylength 128;
verify_method disklabel;
keygen storedkey key mogamogamogamoga;

>How-To-Repeat:


configure two cgds c.f. above and run
cgdconfig cgd0 /dev/raid0e
cgdconfig cgd1 /dev/raid1a

>Fix:

Unknown.

>Release-Note:

>Audit-Trail:
From: "Michael van Elst" <mlelstv@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/41704 CVS commit: src/sys/dev
Date: Sat, 28 Nov 2015 21:06:31 +0000

 Module Name:	src
 Committed By:	mlelstv
 Date:		Sat Nov 28 21:06:31 UTC 2015

 Modified Files:
 	src/sys/dev: cgd.c

 Log Message:
 Remove bogus dk_getdisklabel call.

 - there is no need to read the label in the attach routine
 - passing a (dev_t)0 may cause havoc.

 This fixes PR 41704.


 To generate a diff of this commit:
 cvs rdiff -u -r1.105 -r1.106 src/sys/dev/cgd.c

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

From: "Jaromir Dolecek" <jdolecek@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/41704 CVS commit: src/sys/arch/xen/xen
Date: Wed, 16 Oct 2019 19:38:13 +0000

 Module Name:	src
 Committed By:	jdolecek
 Date:		Wed Oct 16 19:38:13 UTC 2019

 Modified Files:
 	src/sys/arch/xen/xen: xbd_xenbus.c

 Log Message:
 don't try to read disklabel for attached xbd* disk from (effectively) always
 xbd0a device, there is no need for it and it is just wrong

 same problem as PR kern/41704 for cgd

 XXX perhaps xbd should use native block size passed from dom0 rather then
 XXX recomputing in DEV_BSIZE


 To generate a diff of this commit:
 cvs rdiff -u -r1.92 -r1.93 src/sys/arch/xen/xen/xbd_xenbus.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->feedback
State-Changed-By: maya@NetBSD.org
State-Changed-When: Tue, 21 Apr 2020 17:31:22 +0000
State-Changed-Why:
Does the commit resolve your issue? thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.