From e32faab34f1dcce4e9ff8cf93d4ac87a8ecf5cee Mon Sep 17 00:00:00 2001 From: Lwazi Dube Date: Fri, 14 Aug 2026 22:19:15 -0400 Subject: [PATCH] fs/vfs/fs_read.c: Allow NULL iov_base when CONFIG_ARCH_TEXT_VBASE == 0 For kernel builds where CONFIG_ARCH_TEXT_VBASE is set to 0, allow a NULL buffer in file_readv() to prevent ELF binary loading failures for binaries located at address 0. This fix was originally introduced in #18830, but was inadvertently reverted by someone unaware that platforms with CONFIG_ARCH_TEXT_VBASE equal to 0 cannot function at all without it. This commit restores the necessary check to prevent regressions in zero-based text kernel configurations. Most platforms remain completely unaffected since only about 5 boards utilize a text virtual base of zero. Signed-off-by: Lwazi Dube --- fs/vfs/fs_read.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/vfs/fs_read.c b/fs/vfs/fs_read.c index a8e50e0a546..0ffc1e9715e 100644 --- a/fs/vfs/fs_read.c +++ b/fs/vfs/fs_read.c @@ -176,6 +176,14 @@ ssize_t file_readv(FAR struct file *filep, return -EFAULT; } + /* -------------------- DO NOT REMOVE -------------------- + * Only for kernel builds with CONFIG_ARCH_TEXT_VBASE == 0. + * In this case we have to allow the NULL buffer otherwise + * kernel builds will fail to load elf binaries found at 0. + */ + +#if !defined(CONFIG_BUILD_KERNEL) || CONFIG_ARCH_TEXT_VBASE != 0 + /* Are all iov_base accessible? */ for (ret = 0; ret < iovcnt; ret++) @@ -185,6 +193,7 @@ ssize_t file_readv(FAR struct file *filep, return -EFAULT; } } +#endif ret = -EBADF;