Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1872547lql; Wed, 13 Mar 2024 10:21:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXE+32IL4A8BDbN+snZMomU4qsn67bKwVKNn8h3VKRJiWi1po5+fJEm9QF1y8m34Iq8i29qyNE25Gbl6UkNDeo0/SY4kG7BFHeInqiaAg== X-Google-Smtp-Source: AGHT+IHw63CYUIOWo+Da6hzABeNWL6VEnzzz7zz2Oc4i73285sRGzCaVwNWJNNQPjO6bLQI4ZQ3n X-Received: by 2002:a17:907:8b8b:b0:a46:1e21:3739 with SMTP id tb11-20020a1709078b8b00b00a461e213739mr2973281ejc.6.1710350511499; Wed, 13 Mar 2024 10:21:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710350511; cv=pass; d=google.com; s=arc-20160816; b=0XaUqcISCI6uH2uBl9ttwXkTrcFlXSxMEOH4wQlXvHJob6Aohy5m8ka1l3f1sQXIQk GOPZcLoVhZSm5/V12n/dm3ugLtZDk6Xt2zbNmYurrj1kfHFdQGWzMebprWop2zqltqFA 9zexSognpaM/wfUtkP1aWKKTGvr2ge3Jk69/JSjeIyAYeru8s8LUFyrn4ihogOn8tPJY oZzSUV2FjsNpQwxkNzaHumjCCjd4rj8LH6TrK38tMoGMBqQIMpBnGdzwKFZlQC67V/zx WaptTuJiRBhIDbhGNZabkGCNp3A7Nv/LFZLfGlpcmNaBmotYcn/tH4ZU8BaVZ+f+xb0O EJ5w== 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=bhNatPlYaxoC9m4srLPyZKh5dKS8wTFxlnnmKF9KdcQ=; fh=UDybChT8th3KBBN/dtQlnvIe4LqqY5GN+FXyISH2BnE=; b=SGsTFy0N4NUyEpf3QL/9806Ww3Nx9nitcUJOqXdKbI1FvUBNrg4OLxU8cIhanbE53B LjwbB3EXlnKyEW/QXyYAitpFi9e179rYMQgBKOtZ+yI285vQ4OKwDmZK/s/WM6DARMyB Vhxxv1ibgs0y3Q8pfWCy/WiIhRHzrIwro8KBoBiPbfV5D0l4ctzVvIpbJL/6fQN6nS25 GWInHZjSTp5to2KwrYpY9Ik5upGCMWHirPBr0UwMVVHFD6sXXWgfM8QMChH1DrfjKIF8 Go/9I2DSs+lQjbjzmrPeeSMJtfiDFKPJ9WGRfCxdhAFOqaZB4w4gEVQMLd5LKawTfcWo hQDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DzPF939p; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101898-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bu15-20020a170906a14f00b00a44677e24eesi4375134ejb.1043.2024.03.13.10.21.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:21:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DzPF939p; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101898-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 C232B1F2D7C6 for ; Wed, 13 Mar 2024 17:10:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CCEB48004F; Wed, 13 Mar 2024 16:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DzPF939p" 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 000B77F7D9; Wed, 13 Mar 2024 16:40:33 +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=1710348034; cv=none; b=iJDY5VDNM448xPE1Gwa6YpK/ddooSDfMDqBXsZm6NRfoCtD4awoq4URs71QlXG5Ec3Is21NVJ6b62W9nDTM40luKLY8ssglmGd31aluPwTEHOmr+zrqf/TPcbI6CFpDNIY3QZktnsuKegzsckk8j1EKtfHrPNAaHsC+JHGmg4K4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348034; c=relaxed/simple; bh=9vb0yDa0kY/pRTpRxppIpEhL6hSD5H6EThJS2c2n8u8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rRUdCKSy7U2/Eo3VbHDHauiwIW6LAKnfv9D4p1e5IPnFhxtUWLCCNHT5rTH7FiD1pWEGakzNQU1gA0ocu2AJcNptH653bXtZCkIDxPEhxWL28uRKwlIY5kAqgRCKz0ZYDG+jntdxbsCO+lHlFaU9VjPLLZD5shToianYjxm4PPA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DzPF939p; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CEA4C433C7; Wed, 13 Mar 2024 16:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348033; bh=9vb0yDa0kY/pRTpRxppIpEhL6hSD5H6EThJS2c2n8u8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DzPF939pkyQE8q+Swciw9UxtVgW13/trOmdw2mgtJwKLd9GsdXaO24SIgtqM8kCfd tcazWyPZDXkc3QEz4NlOTbkYC6DAEt//IvwtzNDSCFNY+6OWHZNWESrtmBAi/4AVHM fy2dPNbMBT/ZvNmsxbVRpiq3Y1ZpxuZC0leHKxLQU0RExSy02aQChY+WcZbL7v3Ahx rKyk6BiJXnHlDC16rj2hqhdxlkAHx+T+dUEg0kEQllzblt/Tb2Crp24PUpUqZtPDfq SyvMyMKbToW7GH65f1MMlI3v1bd8qpEnk6dcdKmoqxoTTGDdg/H8ROJ1AEua/fzbUb vFv5IpuwDDq5Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 6.1 30/71] netrom: Fix data-races around sysctl_net_busy_read Date: Wed, 13 Mar 2024 12:39:16 -0400 Message-ID: <20240313163957.615276-31-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313163957.615276-1-sashal@kernel.org> References: <20240313163957.615276-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/v6.x/stable-review/patch-6.1.82-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-6.1.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 6.1.82-rc1 X-KernelTest-Deadline: 2024-03-15T16:39+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Jason Xing [ Upstream commit d380ce70058a4ccddc3e5f5c2063165dc07672c6 ] 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/af_netrom.c | 2 +- net/netrom/nr_in.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 5472e79cde830..f0879295de110 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -954,7 +954,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev) * G8PZT's Xrouter which is sending packets with command type 7 * as an extension of the protocol. */ - if (sysctl_netrom_reset_circuit && + if (READ_ONCE(sysctl_netrom_reset_circuit) && (frametype != NR_RESET || flags != 0)) nr_transmit_reset(skb, 1); diff --git a/net/netrom/nr_in.c b/net/netrom/nr_in.c index 2f084b6f69d7e..97944db6b5ac6 100644 --- a/net/netrom/nr_in.c +++ b/net/netrom/nr_in.c @@ -97,7 +97,7 @@ static int nr_state1_machine(struct sock *sk, struct sk_buff *skb, break; case NR_RESET: - if (sysctl_netrom_reset_circuit) + if (READ_ONCE(sysctl_netrom_reset_circuit)) nr_disconnect(sk, ECONNRESET); break; @@ -128,7 +128,7 @@ static int nr_state2_machine(struct sock *sk, struct sk_buff *skb, break; case NR_RESET: - if (sysctl_netrom_reset_circuit) + if (READ_ONCE(sysctl_netrom_reset_circuit)) nr_disconnect(sk, ECONNRESET); break; @@ -262,7 +262,7 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype break; case NR_RESET: - if (sysctl_netrom_reset_circuit) + if (READ_ONCE(sysctl_netrom_reset_circuit)) nr_disconnect(sk, ECONNRESET); break; -- 2.43.0