Skip to content

fs/vfs: allow NULL iov_base in KERNEL build with zero-based text#18830

Open
ldube wants to merge 1 commit intoapache:masterfrom
ldube:panda
Open

fs/vfs: allow NULL iov_base in KERNEL build with zero-based text#18830
ldube wants to merge 1 commit intoapache:masterfrom
ldube:panda

Conversation

@ldube
Copy link
Copy Markdown
Contributor

@ldube ldube commented May 1, 2026

Summary

This commit fixes a regression introduced by
89df084. That commit added a check to ensure iov_base is not NULL, assuming NULL always represents an inaccessible address.

However, in CONFIG_BUILD_KERNEL mode where CONFIG_ARCH_TEXT_VBASE is set to 0, address zero is a valid virtual address for the user-space text segment. The previous check caused libelf to fail with -EFAULT when attempting to load ELF program headers into the base of the user address space.

This patch wraps the safety check in a conditional to ensure it is only executed when address zero is not considered a valid executable base.

Impact

Make kernel builds work on armv7a again

Testing

Successfully reached the NuttShell prompt

NuttShell (NSH) NuttX-12.13.0
knsh> /bin/hello
Hello, World!!
knsh>

Without this change this change the machine does not run NuttShell.

[ 0.000000] libelf_loadfile: Loading sections - text: 0.b530 data: 0x80101000.7a8
[ 0.000000] libelf_read: ERROR: Read from offset 56 failed: 14
[ 0.010000] libelf_loadfile: ERROR: Failed to read section 1: -14
[ 0.020000] libelf_load_with_addrenv: ERROR: libelf_loadfile failed: -14
[ 0.020000] elf_loadbinary: Failed to load ELF program binary: -14
[ 0.030000] exec_internal: ERROR: Failed to load program '/bin/init': -14

@ldube ldube requested review from Donny9, anchao, jerpelea and yamt as code owners May 1, 2026 23:08
@github-actions github-actions Bot added Area: File System File System issues Size: XS The size of the change in this PR is very small labels May 1, 2026
This commit fixes a regression introduced by
89df084. That commit
added a check to ensure iov_base is not NULL, assuming NULL
always represents an inaccessible address.

However, in CONFIG_BUILD_KERNEL mode where CONFIG_ARCH_TEXT_VBASE
is set to 0, address zero is a valid virtual address for the
user-space text segment. The previous check caused libelf to
fail with -EFAULT when attempting to load ELF program headers
into the base of the user address space.

This patch wraps the safety check in a conditional to ensure it is
only executed when address zero is not considered a valid
executable base.

Signed-off-by: Lwazi Dube <lwazeh@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: File System File System issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant