Page MenuHomeFreeBSD

loader: Fix md device name parsing
AbandonedPublic

Authored by manu on Jan 26 2023, 11:33 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 4, 9:25 AM
Unknown Object (File)
Fri, Oct 18, 8:07 PM
Unknown Object (File)
Fri, Oct 18, 8:07 PM
Unknown Object (File)
Fri, Oct 18, 7:41 PM
Unknown Object (File)
Oct 1 2024, 8:55 AM
Unknown Object (File)
Sep 27 2024, 4:30 PM
Unknown Object (File)
Sep 20 2024, 6:23 AM
Unknown Object (File)
Sep 17 2024, 11:46 AM
Subscribers

Details

Reviewers
imp
Group Reviewers
Loader
Summary

MD device is using the disk interface for name parsing so we need
to check if we're parsing a disk or md device.

Fixes: 33bbe5ddcbbc ("stand: parsedev API change: devspec now points to start of full device name")

Sponsored by: Beckhoff Automation GmbH & Co. KG
MFC after: now

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 49243
Build 46133: arc lint + arc unit

Event Timeline

manu requested review of this revision.Jan 26 2023, 11:33 AM

I'll hit approve, but if you don't make the change I suggest, then I'll likely do it in the near future.

stand/common/disk.c
423

Uggg

This breaks uboot.

I think it would be better to do

while (isalpha(*devspec)) devspec++;

which also breaks uboot, but lets me fix the ugly kludge in uboot that's the reason this breaks there

This revision is now accepted and ready to land.Jan 26 2023, 5:00 PM

My local workaround to fix this was to add md_parsedev() and md_formatdev() and have it only understand md0.

stand/common/disk.c
423

How does it break u-boot ?

stand/common/disk.c
423

It would break it, but only for md disks.... It's this kludge I'm worried about, but maybe it's OK.

disk_parsedev((struct devdesc **)&dev, p - 4, NULL) == 0) { /* Hack */

but p might point outside of an array giving UB behavior. If we add 4 to it always, then it's fine. so the strcmp adds a dereference to that. And if there's an 'm' before the diskX string, then we'd get a false positive.

But having said that, it's edge-case-y enough that we can likely just commit this change and I'll fix it and uboot/main.c at the same time later.

After a second look, perhaps md's devsw shouldn't even define dv_fmtdev or dv_parsedev and use the defaults instead.

offhand, it looks likes devformat() and default_parsedev() will suffice for md's.

In D38211#868478, @rew wrote:

After a second look, perhaps md's devsw shouldn't even define dv_fmtdev or dv_parsedev and use the defaults instead.

offhand, it looks likes devformat() and default_parsedev() will suffice for md's.

Indeed.
See https://reviews.freebsd.org/D38218