NetBSD Problem Report #21723

Received: (qmail 734 invoked by uid 605); 30 May 2003 21:14:43 -0000
Message-Id: <200305302114.h4ULEEJD015198@apb.cequrux.com>
Date: Fri, 30 May 2003 23:14:14 +0200 (SAST)
From: Alan Barrett <apb@cequrux.com>
Sender: gnats-bugs-owner@netbsd.org
Reply-To: apb@cequrux.com
To: gnats-bugs@gnats.netbsd.org
Subject: dk_size() fails with no disklabel - should special-case RAW_PART
X-Send-Pr-Version: 3.95

>Number:         21723
>Category:       kern
>Synopsis:       dk_size() fails with no disklabel - should special-case RAW_PART
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 30 21:15:00 +0000 2003
>Closed-Date:    
>Last-Modified:  
>Originator:     Alan Barrett
>Release:        NetBSD 1.6T
>Organization:
Not much
>Environment:
/* $NetBSD: dksubr.c,v 1.7 2003/05/12 00:19:00 atatat Exp $ */
>Description:
The dk_size() function in sys/dev/dksubr.c is apparently intended to
return the size of a disk partition.  It seems reasonable to expect it
to work when passed the raw partition of a disk without a label, but it
fails.

This failure makes it impossible to swap to the raw partition on a "cgd"
device that does not have a disklabel.  I assume that it will also
prevent similar operations on other kinds of devices.

>How-To-Repeat:
0. Decide to use /dev/wd0e as an encrypted swap partition
   via a cgd layer.

1. Create a cgd paramsfile as follows:

	# cgdconfig -g -k random -o /etc/cgd/wd0e aes-cbc 192

2. Configure a cgd layer (cgd0) on top of wd0e using the paramsfile:

	# cgdconfig /dev/cgd0 /dev/wd0e /etc/cgd/wd0e

3. Try to enable /dev/cgd0d as a swap partition.  
   (Note that "d" is teh raw partition in NetBSD/i386.)

	# swapctl -a /dev/cgd0d
	swapctl: /dev/cgd0d: Device not configured

>Fix:
Apply this patch:

--- sys/dev/dksubr.c	12 May 2003 00:19:00 -0000	1.7
+++ sys/dev/dksubr.c	27 May 2003 15:29:41 -0000
@@ -221,6 +221,9 @@
 		return -1;

 	part = DISKPART(dev);
+	if (part == RAW_PART)
+		return dksc->sc_size;
+
 	is_open = dksc->sc_dkdev.dk_openmask & (1 << part);

 	if (!is_open && di->di_open(dev, 0, S_IFBLK, curproc))
>Release-Note:
>Audit-Trail:
>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-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.