Page MenuHomeFreeBSD

lib9p: fix mem leaks and use-after-free in socket.c
AcceptedPublic

Authored by njain15_protonmail.com on Tue, Aug 4, 1:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Aug 27, 10:08 PM
Unknown Object (File)
Thu, Aug 27, 10:04 PM
Unknown Object (File)
Tue, Aug 25, 10:32 PM
Unknown Object (File)
Mon, Aug 24, 10:47 PM
Unknown Object (File)
Sun, Aug 23, 7:45 AM
Unknown Object (File)
Sat, Aug 22, 11:01 PM
Unknown Object (File)
Fri, Aug 21, 12:04 PM
Unknown Object (File)
Fri, Aug 21, 12:01 PM
Subscribers

Details

Reviewers
markj
Summary

Currently, the socket receiving thread hands the request off to the threadpool and prematurely frees the request payload. Anyone using it later (ex. TWRITE), reads garbage data. Suggested fix is to free the request buffer only when we're sending a response for that request, since it will not be used after that.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

contrib/lib9p/transport/socket.c
319

Does this function need to free the request buffer too?

usr.sbin/bhyve/pci_virtio_9p.c
216
njain15_protonmail.com marked 2 inline comments as done.

Yes, sorry about that.

This technically requires a version bump for lib9p.so.1, since the library ABI changed. In practice I think it is not worth bothering: lib9p was added to FreeBSD specifically for bhyve and probably doesn't have any other consumers. It should have been added as a private library. I'll write a patch for that and request an exp-run.

This revision is now accepted and ready to land.Thu, Aug 13, 3:55 PM

Ideally an exp-run completes successfully and we can land D58828 first, and then don't need to worry about shlib bump.