Various unprotected accesses to buf and vnode

From: Alexander Lochmann <alexander.lochmann_at_tu-dortmund.de>
Date: Fri, 27 Aug 2021 13:48:38 UTC
Hi folks,

I'm still analyzing our LockDoc (lock analysis) data for FreeBSD. I came 
across accesses that do not adhere to the locking documentation. I 
cannot tell whether these accesses are made deliberately without locks 
or not.
I listed them below.

Can you please shed some light on those cases?

Thx and regards,
Alex

- Write to buf.b_error without buf.b_lock:
https://github.com/freebsd/freebsd-src/blob/main/sys/kern/vfs_vnops.c#L2846

- Read of buf.b_blkno in cluster_write():
According to the documentation b_lock is needed.
Is b_blkno maybe a read-only element of struct buf?

- Read of buf.b_flags, buf.b_xflags and buf.b_vp:
https://github.com/freebsd/freebsd-src/blob/main/sys/kern/vfs_subr.c#L2351
Are those reads innocent races?
According to our data, buf.b_lock is not acquired.

- Write to vnode.v_bufobj.bo_object:
https://github.com/freebsd/freebsd-src/blob/main/sys/vm/vnode_pager.c#L291
According to the documentation, '[...] the vnode lock which embeds the 
bufobj' is needed. However, interlock is taken in line 276.
Is the interlock equivalent to the vnode lock?
(I assume 'the vnode lock' refers to vnode.v_lock.)

- Is buf.b_bufobj a read-only element?

-- 
Technische Universität Dortmund
Alexander Lochmann                PGP key: 0xBC3EF6FD
Otto-Hahn-Str. 16                 phone:  +49.231.7556141
D-44227 Dortmund                  fax:    +49.231.7556116
http://ess.cs.tu-dortmund.de/Staff/al