mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Data race in net/mptcp/pm_netlink.c
@ 2024-11-22  7:34 clingfei
  2024-11-22 11:50 ` Matthieu Baerts
  0 siblings, 1 reply; 2+ messages in thread
From: clingfei @ 2024-11-22  7:34 UTC (permalink / raw)
  To: Matthieu Baerts, Mat Martineau, Geliang Tang, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, netdev,
	mptcp, linux-kernel

linux-next weekly scan reports that there might be data race in
net/mptcp/pm_netlink.c, when mptcp_pm_nl_flush_addrs_doit
bitmap_zeroing pernet->id_bit_map at line 1748, there might be a
concurrent read at line 1864.
Should we add a lock to protect pernet->id_bit_map?

The report is listed below.
** CID 1601938:  Concurrent data access violations  (MISSING_LOCK)
/net/mptcp/pm_netlink.c: 1864 in mptcp_pm_nl_dump_addr()


________________________________________________________________________________________________________
*** CID 1601938:  Concurrent data access violations  (MISSING_LOCK)
/net/mptcp/pm_netlink.c: 1864 in mptcp_pm_nl_dump_addr()
1858     int i;
1859
1860     pernet = pm_nl_get_pernet(net);
1861
1862     rcu_read_lock();
1863     for (i = id; i < MPTCP_PM_MAX_ADDR_ID + 1; i++) {
>>>     CID 1601938:  Concurrent data access violations  (MISSING_LOCK)
>>>     Accessing "pernet->id_bitmap" without holding lock "pm_nl_pernet.lock". Elsewhere, "pm_nl_pernet.id_bitmap" is written to with "pm_nl_pernet.lock" held 1 out of 1 times.
1864     if (test_bit(i, pernet->id_bitmap)) {
1865     entry = __lookup_addr_by_id(pernet, i);
1866     if (!entry)
1867     break;
1868
1869     if (entry->addr.id <= id)

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

* Re: Data race in net/mptcp/pm_netlink.c
  2024-11-22  7:34 Data race in net/mptcp/pm_netlink.c clingfei
@ 2024-11-22 11:50 ` Matthieu Baerts
  0 siblings, 0 replies; 2+ messages in thread
From: Matthieu Baerts @ 2024-11-22 11:50 UTC (permalink / raw)
  To: clingfei, Mat Martineau, Geliang Tang, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, netdev,
	mptcp, linux-kernel

Hello,

On 22/11/2024 08:34, clingfei wrote:
> linux-next weekly scan reports that there might be data race in
> net/mptcp/pm_netlink.c, when mptcp_pm_nl_flush_addrs_doit
> bitmap_zeroing pernet->id_bit_map at line 1748, there might be a
> concurrent read at line 1864.
> Should we add a lock to protect pernet->id_bit_map?

I don't think there is an issue here: if the flush is being done in
parallel to an in progress dump (max 255 addresses), I don't know what
the userspace can really expect. What's important is not to access freed
data, which should be prevented by the 'rcu_read_lock()'.

So it looks like no lock or id_bitmap duplication is needed here. Even
if there was a need for a certain consistency there, these 2 operations
should not happen in parallel, because the MPTCP generic NL family
doesn't have ".parallel_ops = true".

So I think this report is a false positive, no?

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


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

end of thread, other threads:[~2024-11-22 11:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-22  7:34 Data race in net/mptcp/pm_netlink.c clingfei
2024-11-22 11:50 ` Matthieu Baerts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®