NetBSD Problem Report #55378

From tsutsui@ceres.dti.ne.jp  Fri Jun 12 17:56:13 2020
Return-Path: <tsutsui@ceres.dti.ne.jp>
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 "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 115791A9219
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 12 Jun 2020 17:56:13 +0000 (UTC)
Message-Id: <202006121756.05CHu4X5023958@ceres.dti.ne.jp>
Date: Sat, 13 Jun 2020 02:56:04 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: sysinst assumes RAW_PART is 2 or 3
X-Send-Pr-Version: 3.95

>Number:         55378
>Category:       install
>Synopsis:       sysinst assumes RAW_PART is 2 or 3
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    install-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 12 18:00:00 +0000 2020
>Closed-Date:    Tue Sep 29 15:58:11 +0000 2020
>Last-Modified:  Tue Sep 29 15:58:11 +0000 2020
>Originator:     Izumi Tsutsui
>Release:        NetBSD 9.0
>Organization:
>Environment:
System: NetBSD 9.0 (RAMDISK) #0: Fri Feb 14 00:06:28 UTC 2020
mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/cobalt/compile/RAMDISK
Architecture: maybe all
Machine: all
>Description:
src/usr.sbin/sysinst/disklabel.c and src/usr.sbin/sysinst/partitions.c
have the following lines:
---
#if RAW_PART > 2
	if (parts->dp.parent != NULL) {
		parts->l.d_partitions[RAW_PART-1].p_fstype = FS_UNUSED;
		parts->l.d_partitions[RAW_PART-1].p_offset = start;
		parts->l.d_partitions[RAW_PART-1].p_size = len;
		parts->dp.num_part++;
	}
#endif
	parts->l.d_partitions[RAW_PART].p_fstype = FS_UNUSED;
	parts->l.d_partitions[RAW_PART].p_offset = 0;
	parts->l.d_partitions[RAW_PART].p_size = total_size;
	parts->dp.num_part++;

	parts->l.d_npartitions = RAW_PART+1;

---

static const struct part_scheme_desc all_descs[] = {
#if RAW_PART == 2	/* only available as primary on some architectures */
		{ NULL, &disklabel_parts },
#endif
#ifdef HAVE_GPT
		{ gpt_parts_check, &gpt_parts },
#endif
#ifdef HAVE_MBR
		{ NULL, &mbr_parts },
#endif
#if RAW_PART != 2	/* "whole disk NetBSD" disklabel variant */
		{ NULL, &only_disklabel_parts },
#endif
	};

---

It looks these code assume the machines support MBR partition
(i.e. partition c is a "NetBSD partition" and partition d is
a raw partition) in "RAW_PART > 2" cases.

However this doesn't work as intended if RAW_PART is not 2 or 3.
Actually RAW_PART is 15 on ews4800mips.

>How-To-Repeat:
Code inspection.

>Fix:

Use explicitly "#if RAW_PART == 3" instead, as
src/sys/kern/subr_disk.c  and src/sys/kern/subr_disk_mbr.c etc?

---
Izumi Tsutsui

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->feedback
State-Changed-By: martin@NetBSD.org
State-Changed-When: Mon, 28 Sep 2020 18:41:22 +0000
State-Changed-Why:
Should be fixed, but can't easily test on cobalt (or anywhere it should
make a difference)


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55378 CVS commit: src/usr.sbin/sysinst
Date: Mon, 28 Sep 2020 18:40:24 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Sep 28 18:40:24 UTC 2020

 Modified Files:
 	src/usr.sbin/sysinst: README.md_defs disklabel.c partitions.c

 Log Message:
 PR 55378: do not assume RAW_PART to be either 2 or 3


 To generate a diff of this commit:
 cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sysinst/README.md_defs
 cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/sysinst/disklabel.c
 cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/sysinst/partitions.c

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

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: martin@NetBSD.org, tsutsui@ceres.dti.ne.jp
Subject: Re: install/55378 (sysinst assumes RAW_PART is 2 or 3)
Date: Wed, 30 Sep 2020 00:50:45 +0900

 <20200928184123.002E51A923F@mollari.NetBSD.org>の記事において
 martin@NetBSD.orgさんは書きました。

 > Synopsis: sysinst assumes RAW_PART is 2 or 3

 > Should be fixed, but can't easily test on cobalt (or anywhere it should
 > make a difference)

 (not for cobalt but ews4800mips where RAW_PART==15)

 I cannot dig the machine right now (my 4800/360AD was dead again
 and another 360SX is in closet) but the changes look okay for me.

 ---
 Izumi Tsutsui

State-Changed-From-To: feedback->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Tue, 29 Sep 2020 15:58:11 +0000
State-Changed-Why:
Feedback provided, close assuming fixed


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