fs/procfs: fix potential out-of-bounds read in mount_sprintf() - #20049
Open
hritikkumar07 wants to merge 1 commit into
Open
fs/procfs: fix potential out-of-bounds read in mount_sprintf()#20049hritikkumar07 wants to merge 1 commit into
hritikkumar07 wants to merge 1 commit into
Conversation
hritikkumar07
requested review from
jerpelea,
pkarashchenko and
xiaoxiang781216
as code owners
September 2, 2026 18:34
|
Contributor
|
Thank you- @hritikkumar07, before opening a PR, please take a look at https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md. The check is failing due to a missing signed commit message. Please fix it Logs: |
jerpelea
approved these changes
Sep 3, 2026
Contributor
|
@hritikkumar07 please fix: |
Author
|
Hey @Abhishekmishra2808 and @xiaoxiang781216 , |
vsnprintf() returns the total formatted string length even when truncated to info->line. Passing this untruncated length to procfs_memcpy causes a read beyond the 64-byte line staging buffer. Fixes apache#20011 Signed-off-by: Hritik Naik <hritiknaik16@gmail.com>
hritikkumar07
force-pushed
the
fix/mount-sprintf-buffer-overflow
branch
from
September 3, 2026 18:11
cc2df0b to
4ca7c59
Compare
xiaoxiang781216
approved these changes
Sep 4, 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
When formatting entries for
/proc/fs/mount,vsnprintf()returns the full string length even if output is truncated to fit the 64-byteinfo->linestaging buffer.mount_sprintf()was passing this untruncated length toprocfs_memcpy(), causing an out-of-bounds read pastinfo->linewhen a mountpoint path was long enough (e.g. >= 50 characters).This PR clamps
linesizetoinfo->linelen - 1before callingprocfs_memcpy(), limiting the copy to the actual bytes stored in the buffer.Fixes #20011
Impact
Testing
mount_sprintf()bounds logic when formatting long mount point paths (> 50 chars).info->line.