Acquire rlock when reading link address from the bridge.

It happens along with the other issue when the veth device buffer is full,
then the task is stuck and still have the bridge's lock (RLock) via
DeliverNetworkPacket. When the second task reads the bridge's MAC address,
it waits forever for the first task to release the rlock. Using RLock can
allow the concurrent access to the MAC address, it dones't have to be
blocked until the messages are sent.

Reported-by: syzbot+1d6d1d8f47eae4e308dc@syzkaller.appspotmail.com
PiperOrigin-RevId: 704163976
This commit is contained in:
Jing Chen
2024-12-08 23:47:51 -08:00
committed by gVisor bot
parent 22b95a87ac
commit 54eb79b6e8
+2 -2
View File
@@ -223,8 +223,8 @@ func (b *BridgeEndpoint) MaxHeaderLength() uint16 {
// LinkAddress implements stack.LinkEndpoint.LinkAddress.
func (b *BridgeEndpoint) LinkAddress() tcpip.LinkAddress {
b.mu.Lock()
defer b.mu.Unlock()
b.mu.RLock()
defer b.mu.RUnlock()
return b.addr
}