Page MenuHomeFreeBSD

in_pcb: don't leak credential refcounts on error
ClosedPublic

Authored by rscheff on Tue, Apr 30, 9:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 4, 6:29 PM
Unknown Object (File)
Thu, May 2, 6:48 PM
Unknown Object (File)
Thu, May 2, 1:35 PM
Unknown Object (File)
Wed, May 1, 11:14 PM
Unknown Object (File)
Wed, May 1, 10:26 PM
Unknown Object (File)
Wed, May 1, 10:26 PM
Unknown Object (File)
Wed, May 1, 9:15 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.Tue, Apr 30, 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.Wed, May 1, 8:10 PM
This revision is now accepted and ready to land.Thu, May 2, 5:33 AM