Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4450324imw; Tue, 19 Jul 2022 06:53:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sc119DoXL9tJvK9ryc/bLY42PMmgkNR2PTGBM5D7ovbK73SCJmPFVdozAEB885A4zdhqYF X-Received: by 2002:a17:907:7ba8:b0:72b:9186:5bff with SMTP id ne40-20020a1709077ba800b0072b91865bffmr30731701ejc.650.1658238824051; Tue, 19 Jul 2022 06:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238824; cv=none; d=google.com; s=arc-20160816; b=PP0IIprrAR4n3+n+PWK22vEFauwI+NmdloKrlV8BS+o0YYymU7kMWul0HowhXcRXdN aHSE3GzJ56CQRmN5o2wQW/xIw36QOVg6oqZD118wy9VznJlxFURBoV5+0PtR9PK1p2iU xYfK6lWpMAzRM2EPpXmDXlxuq1cHCHsM2iZd+EL7TVkbwvImkSQfVGsBkyy1sym/TanK e04Zq+iKXlmP2P3s3IzomEuD4cAWYV5u9CQIQpLw9/Q6KKP54c9ro4y8Jmk4HGk++5wb TUbt1kJp3qHUsTFPp2tqDbiEEKddKiv9WCo/IfTyryF9O1EDMAAp03sObHVZv2P5beoO i8RQ== 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=4hdJ4ezrXgwzJBMjCYYYwpr8gopVgrQ0N1tcKTEsXXA=; b=bumOeCj9W57+5S/Rl0PKpFwsdht0IXBpx4i/7en+2oL7XvgKQhyx2ZuAcw+4DlLBX9 uo/NsE/PUwLhznSUUlScM8+yarZ4/mNo6uDk/xS855AmXNHkXbcp+byCTZCZuHsYMc9H aVS35eabQp2+XEYdXdMe3X0z2DeVX7aODWeTW0hX8MNBSjPnaeK9A95IY0r2Ip1I4kX2 1sz99pLRCr2dw1/vmvXksB7zu66AO/lM+SVGhheTemyspvHrYr+ayvKJAlcOTJMtUyEM zp/XPi8kHorZEnzW9iO/ImsbtkGOEhPD8Jr3sjXnpNuf8slcTaFYFVykJ1QtMbRIZCP3 Eszg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="FDq/m/A5"; 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 c20-20020a056402121400b0043ae18edf05si11158904edw.613.2022.07.19.06.53.19; Tue, 19 Jul 2022 06:53:44 -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="FDq/m/A5"; 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 S237637AbiGSMBJ (ORCPT + 99 others); Tue, 19 Jul 2022 08:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237686AbiGSL6g (ORCPT ); Tue, 19 Jul 2022 07:58:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B995C422E9; Tue, 19 Jul 2022 04:57: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 ams.source.kernel.org (Postfix) with ESMTPS id 779D8B81B2B; Tue, 19 Jul 2022 11:57:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACCDFC341C6; Tue, 19 Jul 2022 11:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658231835; bh=Mks+Xm8o2vp8NRXfZWPWNfWitehtpVo26NqiYS4TcX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FDq/m/A5WsTwBrSPxFz+sFwjHnwocl2ErrmRFsIzRNN5v+Mthts2ogVk5/j/L+Yge hMXV7GH14DXLKx7BnKqEN6hiQOp6TSWQ3gsUEM8G4Foo/xisCDtyHXgvHIUvr+qtEQ BGLqBqUHoqy6bWtEoQbAlfmtmEUbn81oDTL/K/J0= 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 14/43] net: Fix data-races around sysctl_mem. Date: Tue, 19 Jul 2022 13:53:45 +0200 Message-Id: <20220719114523.268104601@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114521.868169025@linuxfoundation.org> References: <20220719114521.868169025@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 310731e2f1611d1d13aae237abcf8e66d33345d5 ] While reading .sysctl_mem, it can be changed concurrently. So, we need to add READ_ONCE() to avoid data-races. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- include/net/sock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/sock.h b/include/net/sock.h index f729ccfe756a..dfeaa8deba96 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1340,7 +1340,7 @@ void __sk_mem_reclaim(struct sock *sk, int amount); /* sysctl_mem values are in pages, we convert them in SK_MEM_QUANTUM units */ static inline long sk_prot_mem_limits(const struct sock *sk, int index) { - long val = sk->sk_prot->sysctl_mem[index]; + long val = READ_ONCE(sk->sk_prot->sysctl_mem[index]); #if PAGE_SIZE > SK_MEM_QUANTUM val <<= PAGE_SHIFT - SK_MEM_QUANTUM_SHIFT; -- 2.35.1