Page MenuHomeFreeBSD

in_pcb: don't leak credential refcounts on error
ClosedPublic

Authored by rscheff on Apr 30 2024, 9:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Feb 22, 2:30 PM
Unknown Object (File)
Sat, Feb 22, 1:58 PM
Unknown Object (File)
Sat, Feb 22, 1:40 PM
Unknown Object (File)
Sat, Feb 8, 5:17 AM
Unknown Object (File)
Thu, Feb 6, 5:46 PM
Unknown Object (File)
Thu, Feb 6, 5:45 PM
Unknown Object (File)
Thu, Feb 6, 5:45 PM
Unknown Object (File)
Jan 27 2025, 4:51 PM
Subscribers

Details

Summary

In the error path during allocating an in_pcb, the credentials
associated with the new struct get their reference count
increased early on, but not decremented when the allocation
fails.

Reported-by: cmiller_netapp.com
MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Apr 30 2024, 9:59 PM

Good catch, thanks! Must also be merged to stable/14.

sys/netinet/in_pcb.c
659

Do we need this NULL-ification?

sys/netinet/in_pcb.c
659

It's done in in_pcbrele_[w/r]locked with #ifdef INVARIANTS also; likely to catch any use-after-free issues. Could bracket that into these #ifdefs too...

tuexen added inline comments.
sys/netinet/in_pcb.c
659

But we are freeing the inp anyway and it should be no way to reference the inp. So I think we don't need setting inp->inp_cred to NULL. But I leave it up to you.

  • bracket setting inp_cred to NULL with #ifdef invariants
This revision now requires review to proceed.May 1 2024, 8:10 PM
This revision is now accepted and ready to land.May 2 2024, 5:33 AM