This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 7e0f282718c fs/vfs: allow NULL iov_base in KERNEL build with
zero-based text
7e0f282718c is described below
commit 7e0f282718ccd45f393c199acf91a22e1e183069
Author: Lwazi Dube <[email protected]>
AuthorDate: Fri May 1 18:51:20 2026 -0400
fs/vfs: allow NULL iov_base in KERNEL build with zero-based text
This commit fixes a regression introduced by
89df084b0e51593643ccc2f6427ac11c99243295. 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 <[email protected]>
---
fs/vfs/fs_read.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/vfs/fs_read.c b/fs/vfs/fs_read.c
index 270196be84c..70bbaa8e8a5 100644
--- a/fs/vfs/fs_read.c
+++ b/fs/vfs/fs_read.c
@@ -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;