]> asedeno.scripts.mit.edu Git - linux.git/commit
packet: fix bitfield update race
authorWillem de Bruijn <willemb@google.com>
Mon, 23 Apr 2018 21:37:03 +0000 (17:37 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Apr 2018 17:17:08 +0000 (13:17 -0400)
commita6361f0ca4b25460f2cdf3235ebe8115f622901e
treef57888c07419a06a85caa62d73717363d86b15b7
parent9cf2f437ca5b39828984064fad213e68fc17ef11
packet: fix bitfield update race

Updates to the bitfields in struct packet_sock are not atomic.
Serialize these read-modify-write cycles.

Move po->running into a separate variable. Its writes are protected by
po->bind_lock (except for one startup case at packet_create). Also
replace a textual precondition warning with lockdep annotation.

All others are set only in packet_setsockopt. Serialize these
updates by holding the socket lock. Analogous to other field updates,
also hold the lock when testing whether a ring is active (pg_vec).

Fixes: 8dc419447415 ("[PACKET]: Add optional checksum computation for recvmsg")
Reported-by: DaeRyong Jeong <threeearcat@gmail.com>
Reported-by: Byoungyoung Lee <byoungyoung@purdue.edu>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/packet/af_packet.c
net/packet/internal.h