Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1871705lql; Wed, 13 Mar 2024 10:20:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVoFEntTZck221fklmQeOkIsv4YppXfo+5HclfsgzLSCo/eOpto9dntrVWVfJ+CQzTfuGgOvON9YE362J3duzjwyhUmt6vhwFKT5QiCig== X-Google-Smtp-Source: AGHT+IEYW32ONYRK8/rm/B3SfDGV0DxvIfUu0iFssDEEbkRDfNBOPohrY0Rv4oTk0ulILwalzGSv X-Received: by 2002:a2e:98d8:0:b0:2d4:49d0:d210 with SMTP id s24-20020a2e98d8000000b002d449d0d210mr2488904ljj.50.1710350419637; Wed, 13 Mar 2024 10:20:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710350419; cv=pass; d=google.com; s=arc-20160816; b=CvJlOQ8vTgmwO9hmpy3Cl3nDebsd9m9DH316l+KCT0+b5FW67I21oFtHA7W+vpjTEn eCQFvpjhrXx0M9PF5u17xtz7NvFiC7+zay+4v6HTpxpi4I09KzFi+ztz2myNd2tp+GYV tg+nMjSTMlK6ww+KVtDtFrEWecQ2Fh6pyKTAomFpiZV1CdGGI8rzmRpiD0ck1+JfRkuG DAeU0ZNPNQFFI4MQfBwG3yupHROUaPSzBB9EFhEpi4vvjxQjUOD3xJgeov8H2IvNiGNN wrMd+H5ob21bygIR665Ojc1cE5cJKRHaHeXZZRo5AQNeNcgl/d5+5fZtN14QmAlXhJmI FmSg== 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=yo/J5Mr7FcWg11bWwLta4jYqKbDS21efzXTxDy6N4lI=; fh=UDybChT8th3KBBN/dtQlnvIe4LqqY5GN+FXyISH2BnE=; b=M2k7YVPzWK4JqC/J1NmoZn8nZbAbFzsHc0xMo8QQKk7BFK0t/kPwY6iGdgJ9Onv4hM /XTplo756Ew7H1FAj1+Otp0R2pGZ16Im817nCA3YMOMS/OXKjOx3NzXHp/ptrW/pOJ7F ipsv28UlivA9N1GiYUoxKgnj7aExox9bIPdIUybVOUzrsofbKfOjNTotrnU6+78ku7tM d/rxH/AZ+oSu8JodWEEjX9m4A4mktbzPteT/VjUcsU6/cV1bcDCqBANDwHebMKgBss4e HbLhoSNY6FG0c6Eyn85zpdBNu8HzZazICn3VTw59Cyo+hd1o/iIdsDESnV4iXetUuJGn ksvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i58RMqc+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101889-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 p7-20020a05640243c700b0056842db5c4fsi4479608edc.115.2024.03.13.10.20.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:20:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101889-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=i58RMqc+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101889-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 1F51C1F2BDCD for ; Wed, 13 Mar 2024 17:08:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 021C87C0AA; Wed, 13 Mar 2024 16:40:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i58RMqc+" 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 18B7B7C080; Wed, 13 Mar 2024 16:40:24 +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=1710348025; cv=none; b=lSIt1x4RtktLuMPHZZcA5YgeI2kKyqcVm5RxKS6qjIFG8WeishRy3J68lHIFaQwYPbZqVd2M3e220HrgeuWqIDGa8w4hFdS2fxQKxT7IXGrnjkv+/2/IJ5/RbSrQpC/bmvJ241a7V14pcqpxAyuA5ClYBkgv03QkUADIjMer+qI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348025; c=relaxed/simple; bh=sMKE9+q0Dh0q2fgAnNSJaMiGGhkv/VNO3lY3K/oikNk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OBgAErvuK1290rz4qvuPIdu9Ua7JB7GGFXaH3lXSj4vfkDlzoRNiAKmkjydkRnSv61Zn//1fhCna8vsVgJEqXtpr1Ak+noF8VwCyYWBMLBS5uvMBksRcGDflJnlhZkUS1rksRhGO3dVYjj4ZgH3JUbI5ClIykLQyZLruCpQu/G4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i58RMqc+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDA73C43394; Wed, 13 Mar 2024 16:40:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348024; bh=sMKE9+q0Dh0q2fgAnNSJaMiGGhkv/VNO3lY3K/oikNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i58RMqc+zcX9CJD1dCBadlIMM4LVAKXmNG1fylDJjD+e0duwIfSlmhS314GbfN3io QyLh2ap62tM+vm09YAZvLybp+UKp4afvAJcnqETI82SmiLmH5WhRLsIJbJxcpPhdiV sf914U7hd65BJl8tBl8KaqQ/fgQ0lJTK2Ro5V/++y/V4cQP34tyOytSql38ESfWXEu dKA7m7Gm5rEV3tj7UUe84UpF6CQNUHj5J1Oot8prYbWPQq6Rh3VEw9CN/eUrjTTG/g tX+XZ01N7t1MuKLccVFLuSCidpe/PH49w6r74NUZB1aELVKOW0HaW6l//+EgZ3uBNc irlYBesLYD02w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 6.1 21/71] netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser Date: Wed, 13 Mar 2024 12:39:07 -0400 Message-ID: <20240313163957.615276-22-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 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 3aaac4a22b387..2c34389c3ce6f 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