Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4369313imw; Tue, 19 Jul 2022 05:29:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u/ODuqJcyFSlrJbK+EUoR1QT2MMjRIdKDN4mqWPN9Bv2V14qh9rvX/qyA+FZ0B5egg30ac X-Received: by 2002:a05:6402:190b:b0:43a:c95d:ec93 with SMTP id e11-20020a056402190b00b0043ac95dec93mr42609134edz.44.1658233786071; Tue, 19 Jul 2022 05:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658233786; cv=none; d=google.com; s=arc-20160816; b=xggEkmGKSHKx7Rs+H8elSQjHdizOB6HcuM4IlcKMfxh77FE4yRZE3Xv2SA01dOXrFM XNi+evev80mwAOl3OU56a5Ty5kWX/TQMjmjuqWv0wBf8hUwy+y0PCHx/XFrtXNHHjVzb zfDX18oiEgj3Z1wlh2VJSOd7L9fN1+jj7UBLowPlvS21PXZvHuTGFVyYJnkXFOX+8Ri6 WNq+Z0hJRAwSelBEDvar45iXsj+eujS2EGDz/y9Anv3QZSy/E5iKamaRbb2jZm1jSA53 ZUswV6G3+eMcwpMAT3kM/EuHdMWRB3+jnxbPr9cPprOepW+CA2PCmnl2iQ8EA4PKncBq xIPw== 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=Yzo/jJ1ykXOnhyLf64zZ5G0fdRpJfs8FoCsVICBmN8E=; b=MC3zgPoa98mMSktKUBFbnzTi61eL24sgLfbL1eq8kS++hwrK3/gGcqF4mIWhpoeEVk 0yBVj24jA2hHXAzNoccSs1QuA+bpxwUPTuSy0KzIIPx+PmiXm3rPZkNemAeM2LAVjF2q 8hT5xa1YCuZAdSLKxcqFZ2Wbwx9ICIG9SwSs7+w2aimnXsatNMXWKS/WNpaI+10RrxHi r8Imwqq9o/yj6OOYJaFhxygCwWWSNQrpboN0AE3odgXiLu0roPlmLx5N0/VEuvOXWL2v eMArCfgPGHNKBXuN42SCEjlobe2++aMTFToAUL3mt5TyU6Y8WbicvpqW4DucGLtdXgSv yqDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Aa/J/G/r"; 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 q17-20020a056402519100b0043a6ca62799si13800728edd.307.2022.07.19.05.29.21; Tue, 19 Jul 2022 05:29:46 -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="Aa/J/G/r"; 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 S238245AbiGSMGE (ORCPT + 99 others); Tue, 19 Jul 2022 08:06:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238345AbiGSMEa (ORCPT ); Tue, 19 Jul 2022 08:04:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE237481C3; Tue, 19 Jul 2022 05:00:22 -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 EF99E61614; Tue, 19 Jul 2022 12:00:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4DB9C341C6; Tue, 19 Jul 2022 12:00:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232021; bh=bJBnjAVwj8iajVZYIkDU6xVk+TEZszY3WfxBZ4JXnz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aa/J/G/r9EIbFnfSAxClA4GRcj8u1ibCtyzQBOaUvQnMZuYha6k9vfnepyb25UTyu ph7KbCBtnmaBnyvXOi44V+090Yiu+zv8DQs14Mb7F6i7luUFd4wpCJWBEHroocmqzo jZc7RpNtXOFsQtlh/P16bSFVh0ZwQfWfqGQRQbAw= 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 15/48] net: Fix data-races around sysctl_mem. Date: Tue, 19 Jul 2022 13:53:52 +0200 Message-Id: <20220719114521.187114313@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114518.915546280@linuxfoundation.org> References: <20220719114518.915546280@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 7d3a4c2eea95..98946f90781d 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1381,7 +1381,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