Skip to content
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

sys/net/grnc/netreg: avoid creating an infinite loop #19238

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Feb 2, 2023

Contribution description

If a socket is registered twice, it's next pointer will point to itself, creating an infinite loop in _netreg_lookup() when a packet is received.

Especially when this only happens sporadically (code path that would normally close the socket is not taken) it creates a very hard to debug issue where the system is just locked up.

Instead, fail early and loud.
This would be an infinite loop on RX before, now it's a crash right at the place where the error condition occurs.

Testing procedure

Call gnrc_sock_create() on the same socket twice.
On master this will not fail, but as soon as you receive a packet on the socket, the system locks up in an infinite loop.

With this patch, the assertion will trigger on the 2nd call to gnrc_sock_create().

Issues/PRs references

@benpicco benpicco requested review from fabian18 and maribu February 2, 2023 17:01
@github-actions github-actions bot added Area: network Area: Networking Area: sys Area: System labels Feb 2, 2023
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Feb 2, 2023
@riot-ci
Copy link

riot-ci commented Feb 2, 2023

Murdock results

✔️ PASSED

b7a5261 sys/net/grnc/netreg: avoid creating an infinite loop

Success Failures Total Runtime
6819 0 6819 09m:34s

Artifacts

@benpicco
Copy link
Contributor Author

benpicco commented Feb 2, 2023

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 2, 2023

Build succeeded:

@bors bors bot merged commit 247b8d0 into RIOT-OS:master Feb 2, 2023
@benpicco benpicco deleted the grnc_netreg-loop branch February 2, 2023 20:37
@MrKevinWeiss MrKevinWeiss added this to the Release 2023.04 milestone Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants