Lock vmobjlock then check u_flags & UVM_VNODE_VALID in uvn_attach
authorgnezdo <gnezdo@openbsd.org>
Wed, 31 Aug 2022 09:07:35 +0000 (09:07 +0000)
committergnezdo <gnezdo@openbsd.org>
Wed, 31 Aug 2022 09:07:35 +0000 (09:07 +0000)
commitce1ab8dd6b189cef03d158b4f8bc01c47d968db8
tree882554e1a4a336f07b4de9d23eda94849d4388c0
parent8bec302fece083ba8874200277fecc2a824422c3
Lock vmobjlock then check u_flags & UVM_VNODE_VALID in uvn_attach

This is a continuation of this commit:
"Always acquire the `vmobjlock' before incrementing an object's reference."

Unfortuantely this created a race found by syzkaller manifesting as:

panic: kernel diagnostic assertion "uvn->u_obj.uo_refs == 0" failed:
file "sys/uvm/uvm_vnode.c", line 234

ok mpi@

Reported-by: syzbot+dd2d2684ad2818c927da@syzkaller.appspotmail.com
sys/uvm/uvm_vnode.c