-
Notifications
You must be signed in to change notification settings - Fork 8.3k
subsys/net/net_mgmt.c: Fix memory corruption in wait_on_iface #62302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subsys/net/net_mgmt.c: Fix memory corruption in wait_on_iface #62302
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minor nit about the commit subject, please change it to
net: mgmt: Fix memory corruption in wait_on_iface
81d63ed to
b07a835
Compare
|
Updated commit subject to the build test failing is not due to changes in this PR :) |
The issue was fixed by #62317, could you rebase and re-submit. |
subsys/net/ip/net_mgmt.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you rewrite the above as such:
if (ret < 0) {
if (ret == -EAGAIN) {
ret = -ETIMEDOUT;
}
net_mgmt_del_event_callback(&sync);
return ret;
}
it's shorter/clearer I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewritten as you have suggested :)
See last force-push
b07a835 to
f785192
Compare
The net_mgmt subsystem offers a function which waits (blocks) until a specified net event occurs. An event callback is pushed to the stack, then added to the net_mgmt_event_callback list. If the event occurs, the net_mgmt thread calls the callback and deletes the callback from the list. However, if the event does not occur within the timeout specified when invoking mgmt_event_wait_call() the function will return, corrupting the callback structure the stack is reused. This PR fixes the issue by deleting the callback before exiting in case the event does not occur. Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
4c65cbf
f785192 to
4c65cbf
Compare
|
@jukkar Rebased on main |
The net_mgmt subsystem offers a function which waits (blocks) until a specified net event occurs. An event callback is pushed to the stack, then added to the net_mgmt_event_callback list. If the event occurs, the net_mgmt thread calls the callback and deletes the callback from the list. However, if the event does not occur within the timeout specified when invoking mgmt_event_wait_call() the function will return, corrupting the callback structure when the stack is reused.
This PR fixes the issue by deleting the callback before exiting in case the event does not occur.
@rerickson1 I found it! #56692 (comment)