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)
Thu, Dec 19, 6:22 AM
Unknown Object (File)
Fri, Dec 13, 11:07 PM
Unknown Object (File)
Mon, Dec 9, 5:10 AM
Unknown Object (File)
Nov 19 2024, 12:58 AM
Unknown Object (File)
Sep 29 2024, 12:57 AM
Unknown Object (File)
Sep 25 2024, 3:00 PM
Unknown Object (File)
Sep 25 2024, 6:41 AM
Unknown Object (File)
Sep 25 2024, 3:25 AM

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.