Page MenuHomeFreeBSD

[loader] fix file name cut causing hang when a "." is found in paths like "boot/kernel.elfv2/kernel"
ClosedPublic

Authored by alfredo on Mar 20 2019, 2:06 PM.
Tags
None
Referenced Files
F172987343: D19658.id55287.diff
Tue, Sep 22, 4:14 PM
F172987324: D19658.diff
Tue, Sep 22, 4:14 PM
F172985362: D19658.id55283.diff
Tue, Sep 22, 3:52 PM
F172980698: D19658.id55283.diff
Tue, Sep 22, 3:00 PM
F172980579: D19658.id55288.diff
Tue, Sep 22, 2:59 PM
Unknown Object (File)
Mon, Sep 21, 1:43 PM
Unknown Object (File)
Sun, Sep 20, 2:30 PM
Unknown Object (File)
Fri, Sep 18, 8:43 PM

Details

Summary

function fake_modname is prepared to read a full path to a file and retrieve its name, without and extension (".").
As example, in a path like "boot/kernel.elfv2", the substring "kernel" is extracted.

However, in paths like "boot/test.elfv2/kernel", the dot (".") is being misidentified, causes incorrect string length being calculated. It should look for a "dot" only in the last part of the file name, after the last slash character.

Note: the kernel used in this test doesn't contain any valid module, so it falls in " if (modcnt == 0)" in "__elfN(parse_modmetadata)" functions, causing fake_modname being called.

Test Plan

fix verified in QEMU VM (slof loader)

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23211
Build 22254: arc lint + arc unit

Event Timeline

stand/common/load_elf.c
873

should this be ep == sp now? I'm not sure what exactly the intent of this check is though.

stand/common/load_elf.c
873

Right, this is supposed to be weeding out boot/kernel.elfv2/.elf type stuff where there's no 'name' component. name is the beginning of string, still, and wrong in any case where there's a path separator.

878

This could be changed to s/name/sp/, but it's effectively the same - perhaps just as little more consistent with the other branch.

addresses comments from reviewers and also translates paths such as "boot/kernel/", /boot/kernel/.", ".", "/.", "/.elf", ".elf" as: "bad" (invalid_name variable)

This revision is now accepted and ready to land.Mar 20 2019, 4:16 PM
This revision was automatically updated to reflect the committed changes.