Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4373664imw; Tue, 19 Jul 2022 05:34:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sqCD+2GBs3Bs2bapsoKFxaOzxr1xl9c5IlNc4HR2D4ZeL0bRt7MIip0cJZGLJ2lgX0I5+j X-Received: by 2002:aa7:cd86:0:b0:43a:26e3:d333 with SMTP id x6-20020aa7cd86000000b0043a26e3d333mr43941266edv.178.1658234069641; Tue, 19 Jul 2022 05:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658234069; cv=none; d=google.com; s=arc-20160816; b=hZUDUrACSTMrw5X6R3nQ8lYa0Nfk7ReuzBSR6s9tPOBHKh3dKXcoy4d1lnXl6jSxVk eA5bUvXSv/nkbGxvPx7qDyqcrRB8D2HT7P+xqpy6lyOIMI8OBq1MH8+h9S3Gwe6yJiAU CaC752JbcnsNKQIU+2gBEIIch6BaeUT+uXrNH/oCwK9mddIEtVTKvN3xdw/rAT2dmJXV SYzD7besz9xEOluN2uTRqviZODwS6vufTohRnDVzT6fDMafwa0hmduLhbu6oBslyqWT5 qKl/ATGWsP0iypqOmitrT2jeRZJSna/QBCrEdKfs6RHYO9U5KWaVdeFq9qmI0zwv6Iso sz9Q== 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=PfcE7uHFop5S508IFmSzXkIqpUtPHTpswz17MSG5aRc=; b=dI6WN7NWhpwl2KWT7ew8u+0R2zX1v36qdq5QvgdpZ9pmTFauLj4EGjxNHu5FZczADm fC0Honw3OK0gxbYYGLSK8yKVVYhGNu8AjSx0an2F0U+sPeHbOuPuvHwNnVXCvF0C6Jl9 FQQf/wMWDxcddKufG7Q15df8nBkawQYtvkW/F5YPA45S3rWo/guQTg73uXbVosT3GdjA PK4vg1F+SsFM02qGxw95jFAHSdtsWB6Q2PKhAQ6giXRW4fvDXnG5156Ocs3v0N7pFvmC ZoXw1T3GVt01Huak/EvGERgxrZKRoRclI3IVLSLPHXNVXTqS9C+yqxrycb7kiY/QQ35Q HvIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dIMlu07Q; 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 b8-20020a056402084800b0043b58015e80si13253437edz.355.2022.07.19.05.34.03; Tue, 19 Jul 2022 05:34:29 -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=dIMlu07Q; 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 S239946AbiGSM0Y (ORCPT + 99 others); Tue, 19 Jul 2022 08:26:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240203AbiGSMYp (ORCPT ); Tue, 19 Jul 2022 08:24:45 -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 744BA61DB2; Tue, 19 Jul 2022 05:09:31 -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 D70476178E; Tue, 19 Jul 2022 12:08:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAB15C341C6; Tue, 19 Jul 2022 12:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232522; bh=9xbLmS2L1ZsO0mG6KIbqEoZxe2e7RCoGwhdZi2U1pbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dIMlu07QqkbMnv7W60ARE83MEWzs5ZLedvB4hm8YJogZodIh/IyLIHdS9dgUbBeVE 5JXHW3vrTscLuE7inh1ur2HyK8ZRL3jq3UWgge3/LmF1VosP86V1r18+zocC+CsDbj Ao3TLSbJSbt1a7eSDkFXIKtlmR1S2+NAadheH8CU= 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.10 059/112] icmp: Fix a data-race around sysctl_icmp_ratelimit. Date: Tue, 19 Jul 2022 13:53:52 +0200 Message-Id: <20220719114632.234741805@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@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.8 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 2a4eb714841f288cf51c7d942d98af6a8c6e4b01 ] While reading sysctl_icmp_ratelimit, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/icmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index f22c0d55f479..9483c2a16b78 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -328,7 +328,8 @@ static bool icmpv4_xrlim_allow(struct net *net, struct rtable *rt, vif = l3mdev_master_ifindex(dst->dev); peer = inet_getpeer_v4(net->ipv4.peers, fl4->daddr, vif, 1); - rc = inet_peer_xrlim_allow(peer, net->ipv4.sysctl_icmp_ratelimit); + rc = inet_peer_xrlim_allow(peer, + READ_ONCE(net->ipv4.sysctl_icmp_ratelimit)); if (peer) inet_putpeer(peer); out: -- 2.35.1