Page MenuHomeFreeBSD

ktrace: fix a race between writes and close
ClosedPublic

Authored by kib on May 22 2021, 1:40 PM.

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
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

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
1357

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
1357

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.