Page MenuHomeFreeBSD

kboot: hostfs -- check for llseek failure correctly
ClosedPublic

Authored by imp on Mar 9 2024, 10:50 PM.
Tags
None
Referenced Files
F87365342: D44286.id135620.diff
Tue, Jul 2, 3:37 AM
Unknown Object (File)
Mon, Jul 1, 1:07 AM
Unknown Object (File)
Mon, Jul 1, 1:06 AM
Unknown Object (File)
Mon, Jul 1, 1:06 AM
Unknown Object (File)
Mon, Jul 1, 12:27 AM
Unknown Object (File)
Sun, Jun 30, 9:24 PM
Unknown Object (File)
Tue, Jun 11, 9:28 PM
Unknown Object (File)
May 23 2024, 7:01 AM
Subscribers

Details

Summary

The host_* syscalls are all raw Linux system calls, not the POSIX
wrappers that glibc / musl create. So we have to ranage change the
return value of host_llseek correctly to use the negative value hack
that all Linux system calls use.

This fixes a false positive error detection when we do something like
lseek(fd, 0xf1234567, ...); This returns 0xf1234567, which is a negative
value which used to trigger the error path. Instead, we check for the
range of -511 to -1 (inclusive) and that's the errno we return (libsa
just needs a negative return and throws away this value, so no
translation to FreeBSD errno name space needed). lseek can't otherwise
return a negative number, since it's the offset after seeking into the
file, which by definition is positive.

This kept the 'read the UEFI memory map out of physical memory' from
working on aarch64 (whose boot loader falls back to reading it since
there are restrictive kernel options that can also prevent it), since
the physical address the memory map was at on my platform was like
0xfa008018.

Sponsored by: Netflix

Diff Detail

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