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)
Fri, Sep 27, 4:30 PM
Unknown Object (File)
Fri, Sep 20, 6:23 AM
Unknown Object (File)
Tue, Sep 17, 11:46 AM
Unknown Object (File)
Thu, Sep 5, 1:00 AM
Unknown Object (File)
Aug 23 2024, 1:01 PM
Unknown Object (File)
Aug 23 2024, 1:00 PM
Unknown Object (File)
Aug 23 2024, 12:26 PM
Unknown Object (File)
Aug 14 2024, 6:53 PM
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