Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp478802imn; Wed, 27 Jul 2022 11:20:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tgyPJxeTn8wQ1k2lbJ4xUmmrvGLTYhOJT3baReM2j1B2CatSsnlVQEkYYeRERuv33Y+SJU X-Received: by 2002:a17:902:e808:b0:16d:67a9:36b0 with SMTP id u8-20020a170902e80800b0016d67a936b0mr18432269plg.85.1658946005250; Wed, 27 Jul 2022 11:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946005; cv=none; d=google.com; s=arc-20160816; b=vaKGjoADlmq+gWWfMmTXxRAk0TV7C/zpKLIhzroWWISIe7Ka+SxSuYZByHGGG3M28x 4wsm7hqODKVCdslL53uXFenEnCXhHcQAtniS823qhTQlvtrKbvGJrlaM/OnG1C2C1IN7 gLDiVM/CpA6R40K+lMrCZ4zAfUqBtINdrJA9SR2MGZDqn9LUj0mM8L2IdeI45O8Fv4Az N/7mx8XffS61vdOmVvXBoMe+VzKw2WU2jtPSyR+bEZtDdFxahwV66A2a230KEkeDSsoF 8x433UQeKJFJoOgDQSNg0AZSy/5Pu7pRKood8nJnR1Fdh4uyXrv1PoFZP87LtHGEnYrG GPIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9ropv+1VQc96Je+uUFGpu16kehUDbRXvjw5ahRnFXbY=; b=QqgzPjGXHfXL8YeIbRV1J5jby3COQMer1wNp1CwZL0r5MOvN8hZcXj2YSn7ZbOL+qi m3FSS5asQJcflnvHO5ish+OJtFQVWwqWjN30mG17ltl06yOePWt9GZO/o4HFZqB6iwFA ekXn1v6SwD4W0FSaOF8X1yT5jzZIZODawAMmMbxZ1Qmm11KLtOsmUHQ731kOypomNhW4 euLqKm1Fe+deX1CmQEdb3gOJcVc9WqOQ5Y6oFk6MKlwJAUBvAlSmuKZPxsOcTs4xlzb2 kurPsoCJZv9s+qVz9xtfrhtGVjmnOQhoOZqv4If8eg4zQ6P7mszlMh0N2wg7UVVGxCvp 2NyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sfybvKxZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q22-20020a170902789600b0016bb9574bfesi21272346pll.256.2022.07.27.11.19.50; Wed, 27 Jul 2022 11:20:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sfybvKxZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239718AbiG0QmY (ORCPT + 99 others); Wed, 27 Jul 2022 12:42:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239240AbiG0Qlj (ORCPT ); Wed, 27 Jul 2022 12:41:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 231DC5B7A0; Wed, 27 Jul 2022 09:29:48 -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 ams.source.kernel.org (Postfix) with ESMTPS id AFB64B821BC; Wed, 27 Jul 2022 16:29:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19AF4C433C1; Wed, 27 Jul 2022 16:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939386; bh=V0ufKcihEuhpCTK1oLhFFDvtxYa5zEyVxGoDNHTiRSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sfybvKxZTw6fxNN1ESyAi4xzXmmEQlXU/LsCa9ySTW3dGESYR0Gp6nJzlo+BnByDJ jzsoF8fcO/FYNUJeqRNt5tOKNVq3SAK3mepR3mAnaxGueSUVyMcdAeiYXtlxlXbta7 Q0ACg+EkXaWbsK0xiYo/88USXYuRj72SBYU7Ofxg= 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 20/87] tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept. Date: Wed, 27 Jul 2022 18:10:13 +0200 Message-Id: <20220727161009.838154557@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161008.993711844@linuxfoundation.org> References: <20220727161008.993711844@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kuniyuki Iwashima [ Upstream commit 1a0008f9df59451d0a17806c1ee1a19857032fa8 ] While reading sysctl_tcp_fwmark_accept, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 84f39b08d786 ("net: support marking accepting TCP sockets") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- include/net/inet_sock.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index 40f92f5a3047..58db7c69c146 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -107,7 +107,8 @@ static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk) static inline u32 inet_request_mark(const struct sock *sk, struct sk_buff *skb) { - if (!sk->sk_mark && sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept) + if (!sk->sk_mark && + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept)) return skb->mark; return sk->sk_mark; -- 2.35.1