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
Unknown Object (File)
Mar 17 2024, 9:25 AM
Unknown Object (File)
Jan 6 2024, 10:45 AM
Unknown Object (File)
Dec 20 2023, 7:19 AM
Unknown Object (File)
Jul 11 2023, 4:41 PM
Unknown Object (File)
Jun 3 2023, 7:54 AM
Unknown Object (File)
May 14 2023, 6:28 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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

stand/common/load_elf.c
873 ↗(On Diff #55283)

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 ↗(On Diff #55283)

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 ↗(On Diff #55283)

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.