fs/vfs: allow NULL iov_base in KERNEL build with zero-based text
Build Documentation / build-html (push) Has been cancelled

This commit fixes a regression introduced by
89df084b0e. 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 commit is contained in:
Lwazi Dube
2026-05-01 18:51:20 -04:00
committed by Xiang Xiao
parent 20c38d050b
commit 7e0f282718
+2
View File
@@ -178,6 +178,7 @@ ssize_t file_readv(FAR struct file *filep,
/* Are all iov_base accessible? */
#if !defined(CONFIG_BUILD_KERNEL) || CONFIG_ARCH_TEXT_VBASE != 0
for (ret = 0; ret < iovcnt; ret++)
{
if (iov[ret].iov_base == NULL && iov[ret].iov_len != 0)
@@ -185,6 +186,7 @@ ssize_t file_readv(FAR struct file *filep,
return -EFAULT;
}
}
#endif
ret = -EBADF;