Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp476126imn; Wed, 27 Jul 2022 11:15:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uE772d7AkGMwB3EcPpVGOxNXYy2kvVzkBDVXMjp5rGHC3GiDJYqHEt1sW8ZOu445tNK5di X-Received: by 2002:a17:906:9bc2:b0:72b:2e40:25e1 with SMTP id de2-20020a1709069bc200b0072b2e4025e1mr18222433ejc.158.1658945739634; Wed, 27 Jul 2022 11:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658945739; cv=none; d=google.com; s=arc-20160816; b=Yh5aNnuZtU5JdRbHDB6Y6pqwfOD/jicH197QgwZOKYN3VymKTzNvsYDagiUqv6Gfv6 cqLBTY3ZmtbCzrs6yQy3aOFr0zOK+PR5CSAqPGSrcRBfFb+NvFF4PbiALzf+nFypS8BF lYbw3RRqy7DFRNMWPYTFj6h+xthh/RYaa4NHeTH3BHcVtl78Z71riaLcX47ZS9R9Moch iB1OCUbTz32chvbyF76MEP5tZ/KNvvn1WyOt3RfmQzmv4H0kMzOwb+p/ZfyI0bdNx7ue tjtMxMcpvIW/E7dYPDnihNFc487664V6/fcWQeOkN0L5Hdlx4gJ1852j5J859/vtUoJW 0d+g== 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=RsPcAPGc+KV4OP4aarJ+ljtu/OCMBBAhpC1KtIuiRh0=; b=EESd/FmZgONwpYkL0p4B1tLJ9+lEdXnnHU2fNsLk6Ex8YGI+HG2bzjLwhsazRqo/0r z9TbLsz048NTK9f5M/a7PEiJe+wcvOS222O90x7vNJ3xRnEQFzOheHTDQsD3cyj1G/2M hzbRODQ0j6Z0ImSjdeQhv7KF2YQxSsPUAqpmHjiVT13SZc5RxF+KybUKu3XWcUVJ2+DG Hixt/9oRFB+oYBT628bxQLu2iSwrHCI7O6nn+MPFVZMfljIhScoXdIySiGmNxQc4Fv// Sd9BvEn5pwo1yIDP3SfIQm1ONEhk4iTaV0eqMEhSIFOGJ6+ZkMhgFIUn9TfOKJtdDaNK 7dPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RprgFDRE; 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 ej27-20020a056402369b00b0043bcafe41c9si17114716edb.2.2022.07.27.11.15.13; Wed, 27 Jul 2022 11:15:39 -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=RprgFDRE; 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 S237427AbiG0QaC (ORCPT + 99 others); Wed, 27 Jul 2022 12:30:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237705AbiG0Q3U (ORCPT ); Wed, 27 Jul 2022 12:29:20 -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 6FE4C51413; Wed, 27 Jul 2022 09:24:56 -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 AB0FBB821C3; Wed, 27 Jul 2022 16:24:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13217C43470; Wed, 27 Jul 2022 16:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658939091; bh=KBgj1OBe0JaxOawd5I4mNB9N4o8Hfa8jfOhoRmlyiUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RprgFDREQ4vU2fXJSG69UCaNQ0iijvrUQX4Ch3100tUrQoQkEKA20mU5myYx4I5fo HMT7wqKexTZKVfB7VPKJzpQRjbjjN+pr0ieAZ70Qx/vD2r/pgfDNNDsGxLbI71i79+ R+mGLLVrYGgedNLfcAbzM+TJRghIiRZu3QP7kvPc= 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 4.19 10/62] tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept. Date: Wed, 27 Jul 2022 18:10:19 +0200 Message-Id: <20220727161004.580313911@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161004.175638564@linuxfoundation.org> References: <20220727161004.175638564@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 e3d943813ff8..d5552ff1d361 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -111,7 +111,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