netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* A data race between fanout_demux_rollover() and __fanout_unlink()
@ 2021-04-13 20:51 Gong, Sishuai
  2021-04-13 22:55 ` Xie He
  0 siblings, 1 reply; 5+ messages in thread
From: Gong, Sishuai @ 2021-04-13 20:51 UTC (permalink / raw)
  To: xie.he.0141@gmail.com, eyal.birger@gmail.com,
	yonatanlinik@gmail.com
  Cc: netdev@vger.kernel.org

Hi,

We found a data race in linux-5.12-rc3 between af_packet.c functions fanout_demux_rollover() and __fanout_unlink() and we are able to reproduce it under x86. 

When the two functions are running together, __fanout_unlink() will grab a lock and modify some attribute of packet_fanout variable, but fanout_demux_rollover() may or may not see this update depending on different interleavings, as shown in below.

Currently, we didn’t find any explicit errors due to this data race. But in fanout_demux_rollover(), we noticed that the data-racing variable is involved in the later operation, which might be a concern.

------------------------------------------
Execution interleaving

Thread 1							Thread 2

__fanout_unlink()						fanout_demux_rollover()
spin_lock(&f->lock);
									po = pkt_sk(f->arr[idx]);
									// po is a out-of-date value
f->arr[i] = f->arr[f->num_members - 1];
spin_unlock(&f->lock);



Thanks,
Sishuai


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-04-14 17:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-13 20:51 A data race between fanout_demux_rollover() and __fanout_unlink() Gong, Sishuai
2021-04-13 22:55 ` Xie He
2021-04-13 23:27   ` Willem de Bruijn
2021-04-14 16:52     ` Eric Dumazet
2021-04-14 17:52       ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).