Repository navigation
fs/vfs: validate parameters and buffer alignment in signalfd - #21852
Merged
xiaoxiang781216 merged 1 commit intoNov 17, 2026
Merged
xiaoxiang781216 merged 1 commit into
xiaoxiang781216 merged 1 commit into
Conversation
Swatantra-66
requested review from
Donny9 and
xiaoxiang781216
as code owners
November 13, 2026 15:18
|
Contributor
|
ci fixed by #21771. |
Swatantra-66
force-pushed
the
fix/vfs-signalfd-posix-validation
branch
2 times, most recently
from
November 15, 2026 07:41
aa91969 to
7de77ef
Compare
xiaoxiang781216
approved these changes
Nov 15, 2026
Swatantra-66
force-pushed
the
fix/vfs-signalfd-posix-validation
branch
from
November 15, 2026 11:46
7de77ef to
1f64c11
Compare
1. signalfd():
- Validate that mask != NULL; return -EFAULT if NULL, matching
Linux signalfd(2) specification and preventing CWE-476 NULL
pointer dereference.
- Validate that filep->f_inode != NULL before inspecting ops,
preventing kernel panic when invoked on non-inode descriptors.
2. signalfd_file_read():
- Separate buffer validation: return -EFAULT if buffer == NULL,
and -EINVAL if len < sizeof(struct signalfd_siginfo), strictly
adhering to POSIX read(2) and signalfd(2).
3. signalfd_notify():
- Guard against group == NULL to prevent NULL pointer dereference.
Assisted-by: Google DeepMind:antigravity
Signed-off-by: Swatantra Yadav <[email protected]>
Swatantra-66
force-pushed
the
fix/vfs-signalfd-posix-validation
branch
from
November 16, 2026 07:30
1f64c11 to
a57bbfc
Compare
jerpelea
previously requested changes
Nov 16, 2026
GUIDINGLI
approved these changes
Nov 17, 2026
xiaoxiang781216
approved these changes
Nov 17, 2026
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 PR validates parameters and fixes error handling in
fs/vfs/fs_signalfd.c:signalfd():mask == NULLValidation: Added validation thatmask != NULL, returningEFAULT(-1witherrno = EFAULT) per Linuxsignalfd(2)/ POSIX specification. Previously, passing a NULLmaskdirectly dereferenced*mask, causing a kernel panic (CWE-476 NULL pointer dereference).filep->f_inode != NULLbefore accessingfilep->f_inode->u.i_ops. Ifsignalfd(fd, ...)is called on a valid non-inode descriptor (such as a socket or pseudo-descriptor without an inode), dereferencingf_inode->u.i_opscaused a NULL pointer dereference kernel panic. It now returnsEINVALas specified bysignalfd(2).signalfd_file_read():buffer == NULLand size check.buffer == NULLreturns-EFAULTper POSIXread(2)([EFAULT] buf is outside your accessible address space). A buffer size less thansizeof(struct signalfd_siginfo)returns-EINVALpersignalfd(2).(FAR struct signalfd_siginfo *)bufferto avoid allocating 128 bytes of temporary structure on the kernel stack and eliminatememcpyoverhead.signalfd_notify():group == NULLdefensive check to prevent NULL pointer dereference if invoked during early teardown.Comparison Table
signalfd(-1, NULL, 0)*mask)-1witherrno = EFAULTsignalfd(2)signalfd(sock_fd, &mask, 0)f_inode->u.i_opswhenf_inode == NULL)-1witherrno = EINVALsignalfd(2)read(sfd, NULL, len)-1witherrno = EINVAL-1witherrno = EFAULTread(2)read(sfd, buf, < sizeof(siginfo))-1witherrno = EINVAL-1witherrno = EINVALsignalfd(2)Impact
Testing
nuttx-builderLinux x86_64)sim:nshwithCONFIG_SIGNAL_FD=y1. Code Style Check (
nxstyle)$ ./tools/nxstyle fs/vfs/fs_signalfd.c # Exit code: 0 (0 errors, 0 warnings)2. Build Verification
3. Binary Size
4. Simulator Boot and Runtime Test