Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4453221imw; Tue, 19 Jul 2022 06:57:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v45PDFVsgEsAregIMCy9QurpFL3p4w0mHHkH/tlMG8PIZaYax+qcC9LZHocM91qPlLOde4 X-Received: by 2002:a05:6402:1c01:b0:43a:f714:bcbe with SMTP id ck1-20020a0564021c0100b0043af714bcbemr44692903edb.14.1658239032960; Tue, 19 Jul 2022 06:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658239032; cv=none; d=google.com; s=arc-20160816; b=GVIk+jM6+r4L4aZptJ6BqeqFYPwX9TuoRxWNZ6nWAsrh4bOykb1SYTcW8NCAOGkatH acbRxEzZB6y49rbSr47Y3/q38V4l1iZk+l9Z1VM3JXY8wuKwQ6qOhDG6neQF0eZ94hRX PsJ2LuGWFg0nvIoETARfw0uMOWchT4XBFFFALg3wfH4I8kFdzruOGk72fyV+2113h7Be 6H54bIZtxzvk3nBy+F1mdA6bV6XKX3D0x5Cro21gXJ5tL80qC/fp09j5rx4LKiDj88XJ wOjjJqcz7hJpjtH4Svmz0jRJXO/ypUuaUzUz6UuvSQuKatIXMlJbFZ27WZih6l5M8bnw upEg== 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=oUKrAHKp+FgMAdty5bNqJgWCZ9U+RwG6sA1f9U54REw=; b=rNhTlAedw+8sTq8Rfw0d0N/IsZ1J92VmTTQycbIVhPINNPOxHVM5jIvE9LiK0RqSMp wxgSwkfMSCVtY2n4ses42A1qES20pRQ96IqDSLUfjVTqa4cfQGbmKw2q20OM6Eln8e7N bpZcHk2muAaHUnciNP4ZcKc9VVAgT578aKfcaen9fsD4AczGvE8iyCI/BjKxg0FdDM5R Yo64ZhKgOrZwHvvb+SMXPDdylQwxHZfRWT63dawyQHL8Yl1V/u1A7pNAQMKc7YAtGjDF YzLPG4U3YcLi15yBZcb9lGotJFf4pbAxtJV5Qlo47QVIMiZchM0h9m3T2gdX1QxlH58+ i43Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y+W0xGDN; 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 ht20-20020a170907609400b0072b3ccf55e1si21979587ejc.786.2022.07.19.06.56.48; Tue, 19 Jul 2022 06:57:12 -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=Y+W0xGDN; 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 S242307AbiGSMzn (ORCPT + 99 others); Tue, 19 Jul 2022 08:55:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242490AbiGSMyj (ORCPT ); Tue, 19 Jul 2022 08:54:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 414AD97A3B; Tue, 19 Jul 2022 05:21:47 -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 C1AF2618E1; Tue, 19 Jul 2022 12:21:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95285C341C6; Tue, 19 Jul 2022 12:21:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658233304; bh=nLlYFQCkhFBiv9hsoKKuZAY8cVQn2YoAKCkhCpyctqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y+W0xGDNbzgNfK5lO84r7RcZep3z7T9E55RwHSYlObPiCzsTGGnQShyHiuniLUy2Q 9d75d/zSJjZx4xkeLb4642QSOH/K+2pdMzN9CCYsY2Yed4WJpHLKHw5B4ZssQ/ATQP QNRzWMkZniua3mO6RISvG3mDSOve9Mje+kf3Zh6M= 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.18 077/231] net: Fix data-races around sysctl_mem. Date: Tue, 19 Jul 2022 13:52:42 +0200 Message-Id: <20220719114721.176165552@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114714.247441733@linuxfoundation.org> References: <20220719114714.247441733@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 3c4fb8f03fd9..6bef0ffb1e7b 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1534,7 +1534,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