mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthieu Baerts <matthieu.baerts@tessares.net>
To: Kuniyuki Iwashima <kuniyu@amazon.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Iurii Zaikin <yzaikin@google.com>
Cc: Kuniyuki Iwashima <kuni1840@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	MPTCP Upstream <mptcp@lists.linux.dev>
Subject: Re: [PATCH v2 net 09/12] net: Fix data-races around sysctl_mem.
Date: Sat, 9 Jul 2022 11:11:47 +0200	[thread overview]
Message-ID: <6dddf3f2-40c1-a08b-ec0e-c4feafcad118@tessares.net> (raw)
In-Reply-To: <20220706234003.66760-10-kuniyu@amazon.com>

[-- Attachment #1: Type: text/plain, Size: 782 bytes --]

Hello,

On 07/07/2022 01:40, Kuniyuki Iwashima wrote:
> While reading .sysctl_mem, it can be changed concurrently.
> So, we need to add READ_ONCE() to avoid data-races.

FYI, we got a small conflict when merging -net in net-next in the MPTCP
tree due to this patch applied in -net:

  310731e2f161 ("net: Fix data-races around sysctl_mem.")

and this one from net-next:

  e70f3c701276 ("Revert "net: set SK_MEM_QUANTUM to 4096"")

The conflict has been resolved on our side[1] and the resolution we
suggest is attached to this email.

I'm sharing this thinking it can help others but if it only creates
noise, please tell me! :)

Cheers,
Matt

[1] https://github.com/multipath-tcp/mptcp_net-next/commit/b01bda9d0fe6
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

[-- Attachment #2: b01bda9d0fe6.patch --]
[-- Type: text/x-patch, Size: 836 bytes --]

diff --cc include/net/sock.h
index 0dd43c3df49b,9fa54762e077..f7ad1a7705e9
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@@ -1541,10 -1521,22 +1541,10 @@@ void __sk_mem_reclaim(struct sock *sk, 
  #define SK_MEM_SEND	0
  #define SK_MEM_RECV	1
  
 -/* sysctl_mem values are in pages, we convert them in SK_MEM_QUANTUM units */
 +/* sysctl_mem values are in pages */
  static inline long sk_prot_mem_limits(const struct sock *sk, int index)
  {
- 	return sk->sk_prot->sysctl_mem[index];
 -	long val = READ_ONCE(sk->sk_prot->sysctl_mem[index]);
 -
 -#if PAGE_SIZE > SK_MEM_QUANTUM
 -	val <<= PAGE_SHIFT - SK_MEM_QUANTUM_SHIFT;
 -#elif PAGE_SIZE < SK_MEM_QUANTUM
 -	val >>= SK_MEM_QUANTUM_SHIFT - PAGE_SHIFT;
 -#endif
 -	return val;
++	return READ_ONCE(sk->sk_prot->sysctl_mem[index]);
  }
  
  static inline int sk_mem_pages(int amt)

  reply	other threads:[~2022-07-09  9:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-06 23:39 [PATCH v2 net 00/12] sysctl: Fix data-races around ipv4_table Kuniyuki Iwashima
2022-07-06 23:39 ` [PATCH v2 net 01/12] sysctl: Fix data races in proc_dointvec() Kuniyuki Iwashima
2022-07-06 23:39 ` [PATCH v2 net 02/12] sysctl: Fix data races in proc_douintvec() Kuniyuki Iwashima
2022-07-06 23:39 ` [PATCH v2 net 03/12] sysctl: Fix data races in proc_dointvec_minmax() Kuniyuki Iwashima
2022-07-06 23:39 ` [PATCH v2 net 04/12] sysctl: Fix data races in proc_douintvec_minmax() Kuniyuki Iwashima
2022-07-06 23:39 ` [PATCH v2 net 05/12] sysctl: Fix data races in proc_doulongvec_minmax() Kuniyuki Iwashima
2022-07-06 23:39 ` [PATCH v2 net 06/12] sysctl: Fix data races in proc_dointvec_jiffies() Kuniyuki Iwashima
2022-07-06 23:39 ` [PATCH v2 net 07/12] tcp: Fix a data-race around sysctl_tcp_max_orphans Kuniyuki Iwashima
2022-07-06 23:39 ` [PATCH v2 net 08/12] inetpeer: Fix data-races around sysctl Kuniyuki Iwashima
2022-07-06 23:40 ` [PATCH v2 net 09/12] net: Fix data-races around sysctl_mem Kuniyuki Iwashima
2022-07-09  9:11   ` Matthieu Baerts [this message]
2022-07-06 23:40 ` [PATCH v2 net 10/12] cipso: Fix data-races around sysctl Kuniyuki Iwashima
2022-07-07 19:15   ` Paul Moore
2022-07-07 22:15     ` Kuniyuki Iwashima
2022-07-08  0:24       ` Jakub Kicinski
2022-07-08  0:44         ` Kuniyuki Iwashima
2022-07-06 23:40 ` [PATCH v2 net 11/12] icmp: " Kuniyuki Iwashima
2022-07-06 23:40 ` [PATCH v2 net 12/12] ipv4: Fix a data-race around sysctl_fib_sync_mem Kuniyuki Iwashima
2022-07-08 11:50 ` [PATCH v2 net 00/12] sysctl: Fix data-races around ipv4_table patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6dddf3f2-40c1-a08b-ec0e-c4feafcad118@tessares.net \
    --to=matthieu.baerts@tessares.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=kuniyu@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=yzaikin@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®