summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2023-11-17 17:48:46 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-02-23 08:24:55 +0100
commit592d29eb6bd95781ea21cbb4a45a51260a98b009 (patch)
treec026fae55d24e2483df028a357de4a7626607a6e /net
parentf4a0b57632fa83cdd3791118690ab2ee0d8efe1f (diff)
downloadlinux-592d29eb6bd95781ea21cbb4a45a51260a98b009.tar.gz
linux-592d29eb6bd95781ea21cbb4a45a51260a98b009.tar.bz2
linux-592d29eb6bd95781ea21cbb4a45a51260a98b009.zip
rxrpc_find_service_conn_rcu: fix the usage of read_seqbegin_or_lock()
[ 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 <oleg@redhat.com> Signed-off-by: David Howells <dhowells@redhat.com> cc: Marc Dionne <marc.dionne@auristor.com> cc: linux-afs@lists.infradead.org Link: https://lore.kernel.org/r/20231117164846.GA10410@redhat.com/ Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/rxrpc/conn_service.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/rxrpc/conn_service.c b/net/rxrpc/conn_service.c
index 21da48e3d2e5..7ad4b4e9341e 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);