Skip to content

Commit bad1a11

Browse files
oleg-nesterovdhowells
authored andcommitted
rxrpc_find_service_conn_rcu: fix the usage of read_seqbegin_or_lock()
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 <[email protected]> Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: [email protected] Link: https://lore.kernel.org/r/[email protected]/
1 parent df91b9d commit bad1a11

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/rxrpc/conn_service.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *peer,
2525
struct rxrpc_conn_proto k;
2626
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
2727
struct rb_node *p;
28-
unsigned int seq = 0;
28+
unsigned int seq = 1;
2929

3030
k.epoch = sp->hdr.epoch;
3131
k.cid = sp->hdr.cid & RXRPC_CIDMASK;
@@ -35,6 +35,7 @@ struct rxrpc_connection *rxrpc_find_service_conn_rcu(struct rxrpc_peer *peer,
3535
* under just the RCU read lock, so we have to check for
3636
* changes.
3737
*/
38+
seq++; /* 2 on the 1st/lockless path, otherwise odd */
3839
read_seqbegin_or_lock(&peer->service_conn_lock, &seq);
3940

4041
p = rcu_dereference_raw(peer->service_conns.rb_node);

0 commit comments

Comments
 (0)