Skip to content

Commit 35f1210

Browse files
committed
Merge branch 'rxrpc-miscellaneous-fixes'
David Howells says: ==================== rxrpc: Miscellaneous fixes Here some miscellaneous fixes for AF_RXRPC: (1) Fix a race in the I/O thread vs UDP socket setup. (2) Fix an uninitialised variable. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 9af25dd + 7a310f8 commit 35f1210

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

net/rxrpc/ar-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ bool rxrpc_direct_abort(struct sk_buff *skb, enum rxrpc_abort_reason why,
10561056
int rxrpc_io_thread(void *data);
10571057
static inline void rxrpc_wake_up_io_thread(struct rxrpc_local *local)
10581058
{
1059-
wake_up_process(local->io_thread);
1059+
wake_up_process(READ_ONCE(local->io_thread));
10601060
}
10611061

10621062
static inline bool rxrpc_protocol_error(struct sk_buff *skb, enum rxrpc_abort_reason why)

net/rxrpc/io_thread.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@ int rxrpc_encap_rcv(struct sock *udp_sk, struct sk_buff *skb)
2727
{
2828
struct sk_buff_head *rx_queue;
2929
struct rxrpc_local *local = rcu_dereference_sk_user_data(udp_sk);
30+
struct task_struct *io_thread;
3031

3132
if (unlikely(!local)) {
3233
kfree_skb(skb);
3334
return 0;
3435
}
36+
io_thread = READ_ONCE(local->io_thread);
37+
if (!io_thread) {
38+
kfree_skb(skb);
39+
return 0;
40+
}
3541
if (skb->tstamp == 0)
3642
skb->tstamp = ktime_get_real();
3743

@@ -47,7 +53,7 @@ int rxrpc_encap_rcv(struct sock *udp_sk, struct sk_buff *skb)
4753
#endif
4854

4955
skb_queue_tail(rx_queue, skb);
50-
rxrpc_wake_up_io_thread(local);
56+
wake_up_process(io_thread);
5157
return 0;
5258
}
5359

@@ -565,7 +571,7 @@ int rxrpc_io_thread(void *data)
565571
__set_current_state(TASK_RUNNING);
566572
rxrpc_see_local(local, rxrpc_local_stop);
567573
rxrpc_destroy_local(local);
568-
local->io_thread = NULL;
574+
WRITE_ONCE(local->io_thread, NULL);
569575
rxrpc_see_local(local, rxrpc_local_stopped);
570576
return 0;
571577
}

net/rxrpc/local_object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
232232
}
233233

234234
wait_for_completion(&local->io_thread_ready);
235-
local->io_thread = io_thread;
235+
WRITE_ONCE(local->io_thread, io_thread);
236236
_leave(" = 0");
237237
return 0;
238238

net/rxrpc/sendmsg.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
303303
sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
304304

305305
reload:
306+
txb = call->tx_pending;
307+
call->tx_pending = NULL;
308+
if (txb)
309+
rxrpc_see_txbuf(txb, rxrpc_txbuf_see_send_more);
310+
306311
ret = -EPIPE;
307312
if (sk->sk_shutdown & SEND_SHUTDOWN)
308313
goto maybe_error;
@@ -329,11 +334,6 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
329334
goto maybe_error;
330335
}
331336

332-
txb = call->tx_pending;
333-
call->tx_pending = NULL;
334-
if (txb)
335-
rxrpc_see_txbuf(txb, rxrpc_txbuf_see_send_more);
336-
337337
do {
338338
if (!txb) {
339339
size_t remain;

0 commit comments

Comments
 (0)