Page MenuHomeFreeBSD

kboot: hostfs -- check for llseek failure correctly
ClosedPublic

Authored by imp on Mar 9 2024, 10:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jun 11, 9:28 PM
Unknown Object (File)
May 23 2024, 7:01 AM
Unknown Object (File)
May 23 2024, 7:01 AM
Unknown Object (File)
May 23 2024, 7:01 AM
Unknown Object (File)
May 18 2024, 7:18 PM
Unknown Object (File)
May 18 2024, 3:50 PM
Unknown Object (File)
May 14 2024, 11:32 PM
Unknown Object (File)
May 13 2024, 9:59 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 Not Applicable
Unit
Tests Not Applicable