Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1905686lql; Wed, 13 Mar 2024 11:23:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUo0oVW/eEylj05ywLbOjst9a/8r/pLu5+hJWddGzMl0s8gAtpzFqt/kcpgfwuODBGnrEJrRPF3eZG6nhf9O4iYqhzjAVgTNMDLcQ4HaQ== X-Google-Smtp-Source: AGHT+IHG1lW2izyOU+YsmBa+BqgZOcb/dlmwCzcMlcKKV4JJ9GW5+0cKPpPJJDYlip3WWrm6OX0t X-Received: by 2002:a17:907:1603:b0:a44:df65:b7e5 with SMTP id cw3-20020a170907160300b00a44df65b7e5mr3674611ejd.49.1710354235018; Wed, 13 Mar 2024 11:23:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710354235; cv=pass; d=google.com; s=arc-20160816; b=Kq5/hva/t2zq4T1Rzpmf/kvqeh1sW/fqcahANdExPsj8Rff8PEZGITKXXPxF8cXYzx rjRyRCA2u5uUg2Bzckd254FbzrursS8JeXkOlszbPsK4k/bcTqM9u7XB34qIC+VHbJ+p rF7gPzVqMxoQjZOn9Iebgvc3FzzvYylZqugOHTJ1L+lzDZ1IMscHudFXRRHWdN1x4QPp xOYPuGnImY12A2M3wjTuuSPZHW1BSSLMadSo23ZNf4kbJDMP9vIVKZTQBigm7P+ZvU4E 1TJq0+fPyXB/eisyP2OrYs/7ScA2JoiFIljX1hDAod6Niki/IBYBK0xi2cTdsD7ry6iN vkdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wysoll6pwQ7EZbzwuC0gP5gWSV1E8bfjsZBhFv8vHN8=; fh=UDybChT8th3KBBN/dtQlnvIe4LqqY5GN+FXyISH2BnE=; b=fUzIhfdDPx/5s78zXChxldte5BdmPzxHkzP/3B+RmwOAND2WIxi8aNMqVEF1HD1BMp omdgz8LMJiai27SUjX1vzL+Nv/WcOZPnwwQNLbk24b6oEnfEHlJSgomn0gkDQCGODM4r GdSuH+YzHFiYZTHhSislCc+4YYP78n6Xq4sJvy+PlLs9C55+vcGPP3WKc4gioeH4GFX6 1mKcMBb+e6xNaxx4MR4kJ36MgNMeEQ9TuqiJ8dlM6SFACYvrfJwNT5JixdVC94z/Lc9d 4HlaGkMcaeF+RTtZHafGuJbvVp8EaIFzRGQKJBNeZIwHDNehzd8EUZYj/MximlgdNOln C+2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M2S8iC2N; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102045-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lb15-20020a170907784f00b00a463689908dsi2427856ejc.23.2024.03.13.11.23.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 11:23:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102045-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M2S8iC2N; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102045-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C58E31F2A4F1 for ; Wed, 13 Mar 2024 17:45:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6CFED153507; Wed, 13 Mar 2024 16:47:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M2S8iC2N" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8635D1534EE; Wed, 13 Mar 2024 16:47:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348425; cv=none; b=OE9yGhXNVXqzzzue4+o1SMNOcQR30uXL1Qaengk9NK4dwc2ipChBEtuOYxZ08ujLMq2Wq+IK5NcjtIv7mh2yppHThF11LOTz0cLGKtxxjh6cobCHaq7T+lTyDyaOh+YkCDPS3iq3Y/RxKixMIZrdWLQUj+MrH0o/5zVgpES/blU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348425; c=relaxed/simple; bh=gnQIEhthbcxCrWwdE1rXnIZF674rQKVPTnmEWr6Yt1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TsA67NfKVkREgIEU2ZdO8PWMUTIoZcRheHbCu0FfP9Vh4ktviMExRcrLqBINTqi/BWPJGXxm4SqfaQnDB3iGjnSM7rQ14edZgiI3J2YFXU+Xy5dQtqq+zjB2Xac3rfAfGsWIEHJcA2WBQwk6xHb+e0h9KOd9qI5ohyZE5LStaeA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M2S8iC2N; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 573E4C433A6; Wed, 13 Mar 2024 16:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348425; bh=gnQIEhthbcxCrWwdE1rXnIZF674rQKVPTnmEWr6Yt1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M2S8iC2Nmuy9jdWhXQfCEc1vT/FUZziCKDJg0cqfgcocjF+vFYT19RGH8hZzygeVO o9V/8PUjoLTMXzfxyqL9OXh3pDCt5nJCJH/qVdbzV7fn/tPNCC8yrGkGpfg9VDFUzz PHyfO/Pr/VSNH4/oxB1OdsATnkl7MLF3ww0a9LFArwlV1klSjhjNhJjJlI8gm+vhOQ 8qBQqDjwWmdXG/9YdMg/Q/fv3b0vhsHs3dHNxbtVHLCIIu2YS2DjSf7by4XWo+IO4k lxAzArOTXUFJAiNVzMLF6yECiknknFU/T7/x1HoBhtHjHo5/0nOceKsk60+MkszimI bfhR0w5A91e7Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.10 20/73] netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser Date: Wed, 13 Mar 2024 12:45:47 -0400 Message-ID: <20240313164640.616049-21-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164640.616049-1-sashal@kernel.org> References: <20240313164640.616049-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.213-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.10.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.10.213-rc1 X-KernelTest-Deadline: 2024-03-15T16:46+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Jason Xing [ Upstream commit 119cae5ea3f9e35cdada8e572cc067f072fa825a ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/netrom/nr_dev.c | 2 +- net/netrom/nr_out.c | 2 +- net/netrom/nr_subr.c | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c index 29e418c8c6c30..4caee8754b794 100644 --- a/net/netrom/nr_dev.c +++ b/net/netrom/nr_dev.c @@ -81,7 +81,7 @@ static int nr_header(struct sk_buff *skb, struct net_device *dev, buff[6] |= AX25_SSSID_SPARE; buff += AX25_ADDR_LEN; - *buff++ = sysctl_netrom_network_ttl_initialiser; + *buff++ = READ_ONCE(sysctl_netrom_network_ttl_initialiser); *buff++ = NR_PROTO_IP; *buff++ = NR_PROTO_IP; diff --git a/net/netrom/nr_out.c b/net/netrom/nr_out.c index 44929657f5b71..5e531394a724b 100644 --- a/net/netrom/nr_out.c +++ b/net/netrom/nr_out.c @@ -204,7 +204,7 @@ void nr_transmit_buffer(struct sock *sk, struct sk_buff *skb) dptr[6] |= AX25_SSSID_SPARE; dptr += AX25_ADDR_LEN; - *dptr++ = sysctl_netrom_network_ttl_initialiser; + *dptr++ = READ_ONCE(sysctl_netrom_network_ttl_initialiser); if (!nr_route_frame(skb, NULL)) { kfree_skb(skb); diff --git a/net/netrom/nr_subr.c b/net/netrom/nr_subr.c index e2d2af924cff4..c3bbd5880850b 100644 --- a/net/netrom/nr_subr.c +++ b/net/netrom/nr_subr.c @@ -182,7 +182,8 @@ void nr_write_internal(struct sock *sk, int frametype) *dptr++ = nr->my_id; *dptr++ = frametype; *dptr++ = nr->window; - if (nr->bpqext) *dptr++ = sysctl_netrom_network_ttl_initialiser; + if (nr->bpqext) + *dptr++ = READ_ONCE(sysctl_netrom_network_ttl_initialiser); break; case NR_DISCREQ: @@ -236,7 +237,7 @@ void __nr_transmit_reply(struct sk_buff *skb, int mine, unsigned char cmdflags) dptr[6] |= AX25_SSSID_SPARE; dptr += AX25_ADDR_LEN; - *dptr++ = sysctl_netrom_network_ttl_initialiser; + *dptr++ = READ_ONCE(sysctl_netrom_network_ttl_initialiser); if (mine) { *dptr++ = 0; -- 2.43.0