From mboxrd@z Thu Jan 1 00:00:00 1970 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 A42FA48CC5; Sat, 3 Feb 2024 04:15:49 +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=1706933749; cv=none; b=owX3qWyElzyQVOG13f9LuWeVUG1oZp70O7k3P+txOyhG7DoGYekfJqdJv3YsxBI3i7c+z3t7ZUjq6qbz4KFCrb36wyx0qySdev/52S1pJ8ZAPSXQzjh1AhksNBg00T0uYs42gEBYtSG0MYLNC6BXIIXnt5GEqeU0bymF4dS9Wbg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706933749; c=relaxed/simple; bh=pWC2Hn9x8MhcoQ+aQ+Wmx6+kS6XGEtKsIf7/fuPS4T4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GVAseZLmqqh5iWkYxCW+TIOlwKknQFmCfxvPzVnCagbnTZkcjR+sEcFQ+WiYugSmYGECAJ6Js726goo8M3gI1hbRI84UHfHHURg7r1uVRfLOIZHUfIOJ78nHTXfLZWXnObYTvDib6LhFFE0QCM86vcmgKX3Ji2aqNwZMctI+20c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=v42oE3TZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="v42oE3TZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C494C433C7; Sat, 3 Feb 2024 04:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1706933749; bh=pWC2Hn9x8MhcoQ+aQ+Wmx6+kS6XGEtKsIf7/fuPS4T4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v42oE3TZmQ+PvplAS3ta3Uu8PlWpxeGEX/AuvNtR8ne5A+6aMWjq3wpZ5K7hBp28z SgWm8RdTAxcCwxgvV1ADUClc809V9rn07/9bI/LMsQE27tMeyZHnr89sBdwokOucIS hG5p0tgzWsRUZgiAxB0Vtwpf6oxjgw0rUHGEqMd4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Oleg Nesterov , David Howells , Marc Dionne , linux-afs@lists.infradead.org, Sasha Levin Subject: [PATCH 6.7 044/353] rxrpc_find_service_conn_rcu: fix the usage of read_seqbegin_or_lock() Date: Fri, 2 Feb 2024 20:02:42 -0800 Message-ID: <20240203035405.201753981@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240203035403.657508530@linuxfoundation.org> References: <20240203035403.657508530@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.7-stable review patch. If anyone has any objections, please let me know. ------------------ From: Oleg Nesterov [ Upstream commit bad1a11c0f061aa073bab785389fe04f19ba02e1 ] rxrpc_find_service_conn_rcu() should make the "seq" counter odd on the second pass, otherwise read_seqbegin_or_lock() never takes the lock. Signed-off-by: Oleg Nesterov Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org Link: https://lore.kernel.org/r/20231117164846.GA10410@redhat.com/ Signed-off-by: Sasha Levin --- net/rxrpc/conn_service.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/rxrpc/conn_service.c b/net/rxrpc/conn_service.c index 89ac05a711a4..39c908a3ca6e 100644 --- a/net/rxrpc/conn_service.c +++ b/net/rxrpc/conn_service.c @@ -25,7 +25,7 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *peer, struct rxrpc_conn_proto k; struct rxrpc_skb_priv *sp = rxrpc_skb(skb); struct rb_node *p; - unsigned int seq = 0; + unsigned int seq = 1; k.epoch = sp->hdr.epoch; k.cid = sp->hdr.cid & RXRPC_CIDMASK; @@ -35,6 +35,7 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *peer, * under just the RCU read lock, so we have to check for * changes. */ + seq++; /* 2 on the 1st/lockless path, otherwise odd */ read_seqbegin_or_lock(&peer->service_conn_lock, &seq); p = rcu_dereference_raw(peer->service_conns.rb_node); -- 2.43.0