Page MenuHomeFreeBSD

ktrace: fix a race between writes and close
ClosedPublic

Authored by kib on May 22 2021, 1:40 PM.
Tags
None
Referenced Files
F103721207: D30400.diff
Thu, Nov 28, 12:11 PM
Unknown Object (File)
Fri, Nov 22, 1:26 PM
Unknown Object (File)
Fri, Nov 22, 2:21 AM
Unknown Object (File)
Fri, Nov 22, 2:21 AM
Unknown Object (File)
Fri, Nov 22, 2:21 AM
Unknown Object (File)
Fri, Nov 22, 2:03 AM
Unknown Object (File)
Thu, Nov 14, 4:22 PM
Unknown Object (File)
Thu, Nov 14, 5:48 AM
Subscribers
None

Details

Summary

It was possible that termination of ktrace session occured during some record write, in which case write occured after the close of the vnode. Use ktr_io_params refcounting to avoid this situation, by taking the reference on the structure instead of vnode.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.May 22 2021, 1:40 PM
kib created this revision.
markj added inline comments.
sys/kern/kern_ktrace.c
1360

So we disable tracing if the file is closed and re-opened, i.e., ABA-like race. I think that is ok.

This revision is now accepted and ready to land.May 22 2021, 3:56 PM
kib marked an inline comment as done.May 22 2021, 7:34 PM
kib added inline comments.
sys/kern/kern_ktrace.c
1360

Yes it is same as before ktr_io_params introduction, and I decided to keep it that way from that time.

This revision was automatically updated to reflect the committed changes.
kib marked an inline comment as done.