Skip to content

net/local: fix SCM_RIGHTS pointer and memory corruption - #19902

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Bogdan0759:fix-scm-rights
Aug 20, 2026
Merged

net/local: fix SCM_RIGHTS pointer and memory corruption#19902
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Bogdan0759:fix-scm-rights

Conversation

@Bogdan0759

Copy link
Copy Markdown
Contributor

Summary

Fix NULL pointer dereference and fix memory corruption by using file_put() instead of file_close() + kmm_free().
Add peer NULL check to local_freectl().

Impact

Fixes kernel panic and memory corruption after recvmsg(SCM_RIGHTS).

Testing

Board: qemu_intel64:nsh
Tested with program that exhausts fd table and call recvmsg(SCM_RIGHTS).

@github-actions github-actions Bot added Area: Networking Effects networking subsystem Size: XS The size of the change in this PR is very small labels Aug 20, 2026
@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@Bogdan0759 please fix ci error:

0c3e75cd0c Merge e8f9b3ba010cc1e6bc0e79cc6ec0bcc15c3edcab into 6ccb459e1a79c4a0de4e32353f98b72d2bc081e1
e8f9b3ba01 net/local: fix SCM_RIGHTS pointer and memory corruption
../nuttx/tools/checkpatch.sh -c -u -m -g  6ccb459e1a79c4a0de4e32353f98b72d2bc081e1..HEAD
❌ Missing Signed-off-by
Used config files:
    1: .codespellrc
Some checks failed. For contributing guidelines, see:
  https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

hifive1-revb

@Bogdan0759

Copy link
Copy Markdown
Contributor Author

@Bogdan0759 please fix ci error:

0c3e75cd0c Merge e8f9b3ba010cc1e6bc0e79cc6ec0bcc15c3edcab into 6ccb459e1a79c4a0de4e32353f98b72d2bc081e1
e8f9b3ba01 net/local: fix SCM_RIGHTS pointer and memory corruption
../nuttx/tools/checkpatch.sh -c -u -m -g  6ccb459e1a79c4a0de4e32353f98b72d2bc081e1..HEAD
❌ Missing Signed-off-by
Used config files:
    1: .codespellrc
Some checks failed. For contributing guidelines, see:
  https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md

Added

@jerpelea jerpelea left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a commit message describing the change

Fix NULL pointer dereference and memory corruption by using
file_put() instead of file_close() + kmm_free().
Add peer NULL check to local_freectl().

Signed-off-by: Bogdan <Bogdan4ik0759@gmail.com>
@Bogdan0759

Copy link
Copy Markdown
Contributor Author

please add a commit message describing the change

Done

@Bogdan0759
Bogdan0759 requested a review from jerpelea August 20, 2026 10:51
@acassis

acassis commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

@Bogdan0759 suggestion: is it possible to submit this testing program to apps/testing/nettest/ ?

@Bogdan0759

Copy link
Copy Markdown
Contributor Author

@Bogdan0759 suggestion: is it possible to submit this testing program to apps/testing/nettest/ ?

Done. I submitted the PR in apache/nuttx-apps#3740

@acassis

acassis commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Thank you so much @Bogdan0759 !

@xiaoxiang781216
xiaoxiang781216 merged commit 8142b7f into apache:master Aug 20, 2026
53 checks passed
@Bogdan0759
Bogdan0759 deleted the fix-scm-rights branch August 20, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Networking Effects networking subsystem Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants