Skip to content

Commit 41b996c

Browse files
dhowellskuba-moo
authored andcommitted
rxrpc: Fix call state set to not include the SERVER_SECURING state
The RXRPC_CALL_SERVER_SECURING state doesn't really belong with the other states in the call's state set as the other states govern the call's Rx/Tx phase transition and govern when packets can and can't be received or transmitted. The "Securing" state doesn't actually govern the reception of packets and would need to be split depending on whether or not we've received the last packet yet (to mirror RECV_REQUEST/ACK_REQUEST). The "Securing" state is more about whether or not we can start forwarding packets to the application as recvmsg will need to decode them and the decoding can't take place until the challenge/response exchange has completed. Fix this by removing the RXRPC_CALL_SERVER_SECURING state from the state set and, instead, using a flag, RXRPC_CALL_CONN_CHALLENGING, to track whether or not we can queue the call for reception by recvmsg() or notify the kernel app that data is ready. In the event that we've already received all the packets, the connection event handler will poke the app layer in the appropriate manner. Also there's a race whereby the app layer sees the last packet before rxrpc has managed to end the rx phase and change the state to one amenable to allowing a reply. Fix this by queuing the packet after calling rxrpc_end_rx_phase(). Fixes: 17926a7 ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both") Signed-off-by: David Howells <dhowells@redhat.com> cc: Marc Dionne <marc.dionne@auristor.com> cc: Simon Horman <horms@kernel.org> cc: linux-afs@lists.infradead.org Link: https://patch.msgid.link/20250204230558.712536-2-dhowells@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 811b8f5 commit 41b996c

File tree

5 files changed

+6
-10
lines changed

5 files changed

+6
-10
lines changed

net/rxrpc/ar-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ enum rxrpc_call_flag {
582582
RXRPC_CALL_EXCLUSIVE, /* The call uses a once-only connection */
583583
RXRPC_CALL_RX_IS_IDLE, /* recvmsg() is idle - send an ACK */
584584
RXRPC_CALL_RECVMSG_READ_ALL, /* recvmsg() read all of the received data */
585+
RXRPC_CALL_CONN_CHALLENGING, /* The connection is being challenged */
585586
};
586587

587588
/*
@@ -602,7 +603,6 @@ enum rxrpc_call_state {
602603
RXRPC_CALL_CLIENT_AWAIT_REPLY, /* - client awaiting reply */
603604
RXRPC_CALL_CLIENT_RECV_REPLY, /* - client receiving reply phase */
604605
RXRPC_CALL_SERVER_PREALLOC, /* - service preallocation */
605-
RXRPC_CALL_SERVER_SECURING, /* - server securing request connection */
606606
RXRPC_CALL_SERVER_RECV_REQUEST, /* - server receiving request */
607607
RXRPC_CALL_SERVER_ACK_REQUEST, /* - server pending ACK of request */
608608
RXRPC_CALL_SERVER_SEND_REPLY, /* - server sending reply */

net/rxrpc/call_object.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const char *const rxrpc_call_states[NR__RXRPC_CALL_STATES] = {
2222
[RXRPC_CALL_CLIENT_AWAIT_REPLY] = "ClAwtRpl",
2323
[RXRPC_CALL_CLIENT_RECV_REPLY] = "ClRcvRpl",
2424
[RXRPC_CALL_SERVER_PREALLOC] = "SvPrealc",
25-
[RXRPC_CALL_SERVER_SECURING] = "SvSecure",
2625
[RXRPC_CALL_SERVER_RECV_REQUEST] = "SvRcvReq",
2726
[RXRPC_CALL_SERVER_ACK_REQUEST] = "SvAckReq",
2827
[RXRPC_CALL_SERVER_SEND_REPLY] = "SvSndRpl",
@@ -453,17 +452,16 @@ void rxrpc_incoming_call(struct rxrpc_sock *rx,
453452
call->cong_tstamp = skb->tstamp;
454453

455454
__set_bit(RXRPC_CALL_EXPOSED, &call->flags);
456-
rxrpc_set_call_state(call, RXRPC_CALL_SERVER_SECURING);
455+
rxrpc_set_call_state(call, RXRPC_CALL_SERVER_RECV_REQUEST);
457456

458457
spin_lock(&conn->state_lock);
459458

460459
switch (conn->state) {
461460
case RXRPC_CONN_SERVICE_UNSECURED:
462461
case RXRPC_CONN_SERVICE_CHALLENGING:
463-
rxrpc_set_call_state(call, RXRPC_CALL_SERVER_SECURING);
462+
__set_bit(RXRPC_CALL_CONN_CHALLENGING, &call->flags);
464463
break;
465464
case RXRPC_CONN_SERVICE:
466-
rxrpc_set_call_state(call, RXRPC_CALL_SERVER_RECV_REQUEST);
467465
break;
468466

469467
case RXRPC_CONN_ABORTED:

net/rxrpc/conn_event.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,8 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn)
228228
*/
229229
static void rxrpc_call_is_secure(struct rxrpc_call *call)
230230
{
231-
if (call && __rxrpc_call_state(call) == RXRPC_CALL_SERVER_SECURING) {
232-
rxrpc_set_call_state(call, RXRPC_CALL_SERVER_RECV_REQUEST);
231+
if (call && __test_and_clear_bit(RXRPC_CALL_CONN_CHALLENGING, &call->flags))
233232
rxrpc_notify_socket(call);
234-
}
235233
}
236234

237235
/*

net/rxrpc/input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ static bool rxrpc_input_split_jumbo(struct rxrpc_call *call, struct sk_buff *skb
657657
rxrpc_propose_delay_ACK(call, sp->hdr.serial,
658658
rxrpc_propose_ack_input_data);
659659
}
660-
if (notify) {
660+
if (notify && !test_bit(RXRPC_CALL_CONN_CHALLENGING, &call->flags)) {
661661
trace_rxrpc_notify_socket(call->debug_id, sp->hdr.serial);
662662
rxrpc_notify_socket(call);
663663
}

net/rxrpc/sendmsg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
707707
} else {
708708
switch (rxrpc_call_state(call)) {
709709
case RXRPC_CALL_CLIENT_AWAIT_CONN:
710-
case RXRPC_CALL_SERVER_SECURING:
710+
case RXRPC_CALL_SERVER_RECV_REQUEST:
711711
if (p.command == RXRPC_CMD_SEND_ABORT)
712712
break;
713713
fallthrough;

0 commit comments

Comments
 (0)