netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>,
	Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH v1 net 08/15] net: Fix data-races around netdev_tstamp_prequeue.
Date: Mon, 15 Aug 2022 22:23:40 -0700	[thread overview]
Message-ID: <20220816052347.70042-9-kuniyu@amazon.com> (raw)
In-Reply-To: <20220816052347.70042-1-kuniyu@amazon.com>

While reading netdev_tstamp_prequeue, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its readers.

Fixes: 3b098e2d7c69 ("net: Consistent skb timestamping")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/core/dev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 07da69c1ac0a..4705e6630efa 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4928,7 +4928,7 @@ static int netif_rx_internal(struct sk_buff *skb)
 {
 	int ret;
 
-	net_timestamp_check(netdev_tstamp_prequeue, skb);
+	net_timestamp_check(READ_ONCE(netdev_tstamp_prequeue), skb);
 
 	trace_netif_rx(skb);
 
@@ -5281,7 +5281,7 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,
 	int ret = NET_RX_DROP;
 	__be16 type;
 
-	net_timestamp_check(!netdev_tstamp_prequeue, skb);
+	net_timestamp_check(!READ_ONCE(netdev_tstamp_prequeue), skb);
 
 	trace_netif_receive_skb(skb);
 
@@ -5664,7 +5664,7 @@ static int netif_receive_skb_internal(struct sk_buff *skb)
 {
 	int ret;
 
-	net_timestamp_check(netdev_tstamp_prequeue, skb);
+	net_timestamp_check(READ_ONCE(netdev_tstamp_prequeue), skb);
 
 	if (skb_defer_rx_timestamp(skb))
 		return NET_RX_SUCCESS;
@@ -5694,7 +5694,7 @@ void netif_receive_skb_list_internal(struct list_head *head)
 
 	INIT_LIST_HEAD(&sublist);
 	list_for_each_entry_safe(skb, next, head, list) {
-		net_timestamp_check(netdev_tstamp_prequeue, skb);
+		net_timestamp_check(READ_ONCE(netdev_tstamp_prequeue), skb);
 		skb_list_del_init(skb);
 		if (!skb_defer_rx_timestamp(skb))
 			list_add_tail(&skb->list, &sublist);
-- 
2.30.2


  parent reply	other threads:[~2022-08-16  8:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16  5:23 [PATCH v1 net 00/15] sysctl: Fix data-races around net.core.XXX (Round 1) Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 01/15] net: Fix data-races around sysctl_[rw]mem_(max|default) Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 02/15] net: Fix data-races around weight_p and dev_weight_[rt]x_bias Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 03/15] net: Fix data-races around netdev_max_backlog Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 04/15] bpf: Fix data-races around bpf_jit_enable Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 05/15] bpf: Fix data-races around bpf_jit_harden Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 06/15] bpf: Fix data-races around bpf_jit_kallsyms Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 07/15] bpf: Fix a data-race around bpf_jit_limit Kuniyuki Iwashima
2022-08-16  5:23 ` Kuniyuki Iwashima [this message]
2022-08-16  5:23 ` [PATCH v1 net 09/15] ratelimit: Fix data-races in ___ratelimit() Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 10/15] net: Fix data-races around sysctl_optmem_max Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 11/15] net: Fix a data-race around sysctl_tstamp_allow_data Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 12/15] net: Fix a data-race around sysctl_net_busy_poll Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 13/15] net: Fix a data-race around sysctl_net_busy_read Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 14/15] net: Fix a data-race around netdev_budget Kuniyuki Iwashima
2022-08-16  5:23 ` [PATCH v1 net 15/15] net: Fix data-races around sysctl_max_skb_frags Kuniyuki Iwashima
2022-08-16 16:27 ` [PATCH v1 net 00/15] sysctl: Fix data-races around net.core.XXX (Round 1) Jakub Kicinski
2022-08-16 16:58   ` Kuniyuki Iwashima
2022-08-17 15:58     ` Jakub Kicinski
2022-08-17 16:04       ` Kuniyuki Iwashima

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=20220816052347.70042-9-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).