Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp484358imn; Wed, 27 Jul 2022 11:29:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t31IG9fLGVPNS1PLlcEwG4UtXE5ih2FI6sHlCQn4jd7Qi8PXO4lNbSmr23p5mEp6RKBWUD X-Received: by 2002:a05:6a00:1386:b0:52a:d5f9:2837 with SMTP id t6-20020a056a00138600b0052ad5f92837mr23659919pfg.5.1658946568892; Wed, 27 Jul 2022 11:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946568; cv=none; d=google.com; s=arc-20160816; b=uvcW4h3TZUCkrMUazk+4RfNbWDjEtw6yc2dBoItE7Q4gnZg2gC+eguCxk0GtByWXK4 GFgO5mDN9fcmDn+ue1dMMGjxZrNKoiNgqOVze362IpnqBPMH1YNw3GbYvQMb/NKS2ESs 0eDBVDoSLZDuyvFPs0VjRejIjwvhoZFdIgZ8/zl7Bm3+aNu27wYNCt6IKRwT2d8P9e1x KAw7hCoo+i37vMeDSi7Be4qmB62ngUrBb1f4pqLfQo12llOTogNXjY1ugGrkqeFkLyeL PTORks7yq/xstcLiYDKha7EPBw+VF2h2Yk05fAPIFhWu1/yPqLGteraJ2k4oN7RBLR/b Y16A== 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=KIbNIhgwZ+mzY3DZTVhmklN+Wo+d2RQeo2y9hO3OEq8=; b=KySBpaVZx0SPII7Vp9X7Og5WS50zooZCer3fVFqB23hgb1MBiSitkm84reV/7zsQpO zM6SlL9yw8Egs6NeOohoJhWuVNte+1P7DXJp9dv/U9s0VVES6U/HbQhHEHHGGTbCqmnV RmYMAsVk0RXu9/TYBhVEk650c+V4rm4NSZEl5hve3LZY45xTrZKkvlk/FlbA2SQOdAX5 +0dasiKlRzLnHFCpsIwo20TMOX4oRKNEjETzcCRoqEr9I/Ady4SKM90D02xNAeu08qcc jfuBiVrkPiSiU9NCIgWAhXuNekZ0fsTHrtB9CqtanX0dgguDB7VvyQ2qU+H7Ur0ZKKnj 18Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QxtfUE4M; 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 w70-20020a638249000000b0041b2f36475esi4647587pgd.335.2022.07.27.11.29.13; Wed, 27 Jul 2022 11:29:28 -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=QxtfUE4M; 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 S236192AbiG0QZc (ORCPT + 99 others); Wed, 27 Jul 2022 12:25:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236318AbiG0QYU (ORCPT ); Wed, 27 Jul 2022 12:24:20 -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 1FB574C639; Wed, 27 Jul 2022 09:23:17 -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 8A366619BD; Wed, 27 Jul 2022 16:23:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90B3AC433D6; Wed, 27 Jul 2022 16:23:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658938995; bh=9hka7xncDkenzYMrAz5zM0tQbOOUr06N0IgPvwhQfWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QxtfUE4MKJ6O6XvGk/kLbJ1XitAPH9Z6+IUcbn0tRTWatLTYnYHrdaRNnug0SsEVH hfg4QdC76gvkY8TnYbUr0WbOnlDrpwbaQROUJpvRce4UyFZqfHEt2XAsHEVeX3bJSB fUS4zwEh8j30Rtl5xTgocr/Zc9+feH3DoDmOPvw8= 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.14 06/37] tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept. Date: Wed, 27 Jul 2022 18:10:32 +0200 Message-Id: <20220727161001.100070379@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220727161000.822869853@linuxfoundation.org> References: <20220727161000.822869853@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 16a1492a5bd3..f279d72273f6 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -110,7 +110,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