Page MenuHomeFreeBSD

Improve handling of detached inps
AbandonedPublic

Authored by tuexen on Oct 5 2023, 9:04 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jan 27, 4:54 PM
Unknown Object (File)
Dec 29 2024, 9:28 AM
Unknown Object (File)
Dec 2 2024, 8:32 AM
Unknown Object (File)
Nov 25 2024, 9:09 AM
Unknown Object (File)
Nov 23 2024, 10:00 PM
Unknown Object (File)
Nov 23 2024, 5:31 AM
Unknown Object (File)
Nov 7 2024, 11:32 PM
Unknown Object (File)
Oct 17 2024, 5:03 PM

Details

Summary

The inp returned by in_pcblookup_local() can be detached. So check if inp_socket is not NULL before dereferencing it.
This issue was reported by syzkaller and introduced in e3ba0d6adde3.

Test Plan

Run the reproducer found by syzkaller.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

tuexen requested review of this revision.Oct 5 2023, 9:04 AM
rscheff added a subscriber: rscheff.

looks reasonable!

This revision is now accepted and ready to land.Oct 5 2023, 9:51 AM
sys/netinet/in_pcb.c
957

We don't hold t's lock here, so what prevents inp_socket from being set to NULL after this check?

sys/netinet/in_pcb.c
957

Good point. @glebius: Should we take the inp lock here?

I missed one check. The locking issue is not resolved.

This revision now requires review to proceed.Oct 7 2023, 4:31 PM

Adding just an INP_RLOCK(t)/INP_UNLOCK(t) does not resolve the issue. First, it introduces an LOR, since we own the inp hash lock, second the system panics elsewhere when testing with reproducer. The current patch (with the missing locks) mitigates the issue found by syzkaller, but is conceptually not correct due to missing locks. Gleb?