NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

install/55378: sysinst assumes RAW_PART is 2 or 3



>Number:         55378
>Category:       install
>Synopsis:       sysinst assumes RAW_PART is 2 or 3
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    install-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 12 18:00:00 +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@localhost:/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



Home | Main Index | Thread Index | Old Index