fs/vfs: allow NULL iov_base in KERNEL build with zero-based text#18830
Open
ldube wants to merge 1 commit intoapache:masterfrom
Open
fs/vfs: allow NULL iov_base in KERNEL build with zero-based text#18830ldube wants to merge 1 commit intoapache:masterfrom
ldube wants to merge 1 commit intoapache:masterfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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