From nobody Sun Sep 7 12:18:20 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78F76C38145 for ; Fri, 2 Sep 2022 12:40:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236420AbiIBMk0 (ORCPT ); Fri, 2 Sep 2022 08:40:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236274AbiIBMi1 (ORCPT ); Fri, 2 Sep 2022 08:38:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C2C713DC1; Fri, 2 Sep 2022 05:30:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DC43B62175; Fri, 2 Sep 2022 12:29:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0A0BC433D6; Fri, 2 Sep 2022 12:29:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662121767; bh=9NWEiSryDCA9PIKWIcExTflup0XRLRkcGw2V8ePGtIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=guereO6JVavvwR5KAE+ln0vN0JQJfg9TD05HSONDZvNjPAlvm3JZOkNQwVMZ9ElkY BI1p4bcMOz1QUB1KC+FmPVdn2T78cg1UTgpAkRK0e6wlD6Ihg8j4OLLPsm3of+iKqT kFlB330EENnoDTFhvDOBcQzv9TG9YOeLzIMjImi0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 27/77] net: Fix data-races around netdev_tstamp_prequeue. Date: Fri, 2 Sep 2022 14:18:36 +0200 Message-Id: <20220902121404.544964153@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121403.569927325@linuxfoundation.org> References: <20220902121403.569927325@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima [ Upstream commit 61adf447e38664447526698872e21c04623afb8e ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 517fb03a0bb89..99b0025864984 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4411,7 +4411,7 @@ static int netif_rx_internal(struct sk_buff *skb) { int ret; =20 - net_timestamp_check(netdev_tstamp_prequeue, skb); + net_timestamp_check(READ_ONCE(netdev_tstamp_prequeue), skb); =20 trace_netif_rx(skb); =20 @@ -4753,7 +4753,7 @@ static int __netif_receive_skb_core(struct sk_buff **= pskb, bool pfmemalloc, int ret =3D NET_RX_DROP; __be16 type; =20 - net_timestamp_check(!netdev_tstamp_prequeue, skb); + net_timestamp_check(!READ_ONCE(netdev_tstamp_prequeue), skb); =20 trace_netif_receive_skb(skb); =20 @@ -5135,7 +5135,7 @@ static int netif_receive_skb_internal(struct sk_buff = *skb) { int ret; =20 - net_timestamp_check(netdev_tstamp_prequeue, skb); + net_timestamp_check(READ_ONCE(netdev_tstamp_prequeue), skb); =20 if (skb_defer_rx_timestamp(skb)) return NET_RX_SUCCESS; @@ -5165,7 +5165,7 @@ static void netif_receive_skb_list_internal(struct li= st_head *head) =20 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); --=20 2.35.1