From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 EB6CF4A2052 for ; Mon, 14 Sep 2026 15:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398841; cv=none; b=MqrQBheQ9KkrYwItYB40Xb2TFHVvD54tZRA09WAv7mED55BefvncW4c+VqPmYIjaGDN2GM8ziGHdNdQwkmyOaD9dFOCXa1qqoMx9VHHMdKobXbMQEmHgH4x203edroD4VDiUJmwI/fjMJdSAprlNJX1Q7Bo/S7gVHy98MGG3tOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398841; c=relaxed/simple; bh=dCLrLzGxwCqaGfZh56kYijfTb4kpt+8llNj1BU5gtig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MYrUXKA6xANeD3Vj3Qz6v8r6WDnaQ9JODvFWSJe1XAnq9IEsxXMYPR4sKtv3o+k923OAdO/ufcZGs52X8is0T09JfYvKxEZOmuzPFWnvWfGkWNb5eoExld03CVBxfUfAxUaE/cPuBwk3JctE1AtbMEk961Q4UsbDejAa2jSwBbA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=gBaXpz8s; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gBaXpz8s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L0rxafblLK8f4qTe6lPuie/QPs+2crTJHKrvKFcaEZA=; b=gBaXpz8sjk6z5T0/LAoCi42C1eYNE26QduQMlGwx51M8bb9KEzXhOYrvkyFuPFJ6fwfpPj Qrw5iJTO2tt8B9QDgWWc7cQBo/qveNfFpnaF1SM707yiXD59odkTGGKNsuOCOEbRpKKZwX V7AGAqdcj3f0Y7A/+/Z1b1CYuXn9WK0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-HDhq3wvhMoKdcYoyBOD_VA-1; Mon, 14 Sep 2026 11:13:56 -0400 X-MC-Unique: HDhq3wvhMoKdcYoyBOD_VA-1 X-Mimecast-MFC-AGG-ID: HDhq3wvhMoKdcYoyBOD_VA_1789398834 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A1D5E19540FE; Mon, 14 Sep 2026 15:13:54 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2C2E5180057E; Mon, 14 Sep 2026 15:13:50 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, David Laight , stable@vger.kernel.org Subject: [PATCH net v10 01/14] rxrpc: Fix lack of short-send handling in rxrpc_kernel_send_data() Date: Mon, 14 Sep 2026 16:13:25 +0100 Message-ID: <20260914151340.3227501-2-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Fix rxrpc_kernel_send_data() to loop around if it detects a short send. David Laight suggested doing it here rather than wrapping all the calls in loops. Further, remove the len argument and use the iterator count instead and return 0 on success, not the amount copied. Note this is also a prerequisite for changing the way rxrpc_send_data() works to return a short send rather than an error if some data was buffered. Fixes: 651350d10f93 ("[AF_RXRPC]: Add an interface to the AF_RXRPC module f= or the AFS filesystem to use") Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260824091645.41= 5423-1-dhowells%40redhat.com Suggested-by: David Laight Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: stable@vger.kernel.org --- Documentation/networking/rxrpc.rst | 6 ++++-- fs/afs/rxrpc.c | 28 ++++++++++---------------- include/net/af_rxrpc.h | 5 ++--- net/rxrpc/rxperf.c | 11 +++------- net/rxrpc/sendmsg.c | 32 ++++++++++++++++++++---------- 5 files changed, 42 insertions(+), 40 deletions(-) diff --git a/Documentation/networking/rxrpc.rst b/Documentation/networking/= rxrpc.rst index 8926dab8e2e6..01ad12fdf305 100644 --- a/Documentation/networking/rxrpc.rst +++ b/Documentation/networking/rxrpc.rst @@ -870,7 +870,6 @@ The kernel interface functions are as follows: int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call, struct msghdr *msg, - size_t len, rxrpc_notify_end_tx_t notify_end_rx); =20 This is used to supply either the request part of a client call or the @@ -880,13 +879,16 @@ The kernel interface functions are as follows: MSG_MORE if there will be subsequent data sends for this call. =20 The msg must not specify a destination address, control data or any f= lags - other than MSG_MORE. len is the total amount of data to transmit. + other than MSG_MORE. =20 notify_end_rx can be NULL or it can be used to specify a function to = be called when the call changes state to end the Tx phase. This functio= n is called with a spinlock held to prevent the last DATA packet from being transmitted until the function returns. =20 + It returns 0 if all the data is queued and a negative error code on + failure. + (#) Receive data from a call:: =20 int rxrpc_kernel_recv_data(struct socket *sock, diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c index d82916657a3d..09d9da92a1be 100644 --- a/fs/afs/rxrpc.c +++ b/fs/afs/rxrpc.c @@ -412,8 +412,7 @@ void afs_make_call(struct afs_call *call, gfp_t gfp) msg.msg_controllen =3D 0; msg.msg_flags =3D MSG_WAITALL | (call->write_iter ? MSG_MORE : 0); =20 - ret =3D rxrpc_kernel_send_data(call->net->socket, rxcall, - &msg, call->request_size, + ret =3D rxrpc_kernel_send_data(call->net->socket, rxcall, &msg, afs_notify_end_request_tx); if (ret < 0) goto error_do_abort; @@ -425,7 +424,6 @@ void afs_make_call(struct afs_call *call, gfp_t gfp) =20 ret =3D rxrpc_kernel_send_data(call->net->socket, call->rxcall, &msg, - iov_iter_count(&msg.msg_iter), afs_notify_end_request_tx); *call->write_iter =3D msg.msg_iter; =20 @@ -871,7 +869,7 @@ void afs_send_empty_reply(struct afs_call *call) msg.msg_controllen =3D 0; msg.msg_flags =3D 0; =20 - switch (rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, 0, + switch (rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, afs_notify_end_reply_tx)) { case 0: _leave(" [replied]"); @@ -912,21 +910,17 @@ void afs_send_simple_reply(struct afs_call *call, con= st void *buf, size_t len) msg.msg_controllen =3D 0; msg.msg_flags =3D 0; =20 - n =3D rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, len, + n =3D rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, afs_notify_end_reply_tx); - if (n >=3D 0) { - /* Success */ - _leave(" [replied]"); - return; - } - - if (n =3D=3D -ENOMEM) { - _debug("oom"); - rxrpc_kernel_abort_call(net->socket, call->rxcall, - RXGEN_SS_MARSHAL, -ENOMEM, - afs_abort_oom); + if (n < 0) { + if (n =3D=3D -ENOMEM) { + _debug("oom"); + rxrpc_kernel_abort_call(net->socket, call->rxcall, + RXGEN_SS_MARSHAL, -ENOMEM, + afs_abort_oom); + } + _leave(" [error]"); } - _leave(" [error]"); } =20 /* diff --git a/include/net/af_rxrpc.h b/include/net/af_rxrpc.h index 0fb4c41c9bbf..f3980348ed34 100644 --- a/include/net/af_rxrpc.h +++ b/include/net/af_rxrpc.h @@ -64,9 +64,8 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket = *sock, bool upgrade, enum rxrpc_interruptibility interruptibility, unsigned int debug_id); -int rxrpc_kernel_send_data(struct socket *, struct rxrpc_call *, - struct msghdr *, size_t, - rxrpc_notify_end_tx_t); +int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call, + struct msghdr *msg, rxrpc_notify_end_tx_t notify_end_tx); int rxrpc_kernel_recv_data(struct socket *, struct rxrpc_call *, struct iov_iter *, size_t *, bool, u32 *, u16 *); bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *, diff --git a/net/rxrpc/rxperf.c b/net/rxrpc/rxperf.c index b8df6d22314d..dad04062213f 100644 --- a/net/rxrpc/rxperf.c +++ b/net/rxrpc/rxperf.c @@ -525,12 +525,10 @@ static int rxperf_process_call(struct rxperf_call *ca= ll) iov_iter_bvec(&msg.msg_iter, WRITE, &bv, 1, len); msg.msg_flags =3D MSG_MORE; n =3D rxrpc_kernel_send_data(rxperf_socket, call->rxcall, &msg, - len, rxperf_notify_end_reply_tx); + rxperf_notify_end_reply_tx); if (n < 0) return n; - if (n =3D=3D 0) - return -EIO; - reply_len -=3D n; + reply_len -=3D len; } =20 len =3D sizeof(rxperf_magic_cookie); @@ -538,11 +536,8 @@ static int rxperf_process_call(struct rxperf_call *cal= l) iov[0].iov_len =3D len; iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, len); msg.msg_flags =3D 0; - n =3D rxrpc_kernel_send_data(rxperf_socket, call->rxcall, &msg, len, + n =3D rxrpc_kernel_send_data(rxperf_socket, call->rxcall, &msg, rxperf_notify_end_reply_tx); - if (n >=3D 0) - return 0; /* Success */ - if (n =3D=3D -ENOMEM) rxrpc_kernel_abort_call(rxperf_socket, call->rxcall, RXGEN_SS_MARSHAL, -ENOMEM, diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c index ed2c9a51005a..34aae8e789a4 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -794,7 +794,6 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msgh= dr *msg, size_t len) * @sock: The socket the call is on * @call: The call to send data through * @msg: The data to send - * @len: The amount of data to send * @notify_end_tx: Notification that the last packet is queued. * * Allow a kernel service to send data on a call. The call must be in an = state @@ -805,8 +804,7 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msgh= dr *msg, size_t len) * Return: %0 if successful and a negative error code otherwise. */ int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call, - struct msghdr *msg, size_t len, - rxrpc_notify_end_tx_t notify_end_tx) + struct msghdr *msg, rxrpc_notify_end_tx_t notify_end_tx) { bool dropped_lock =3D false; int ret; @@ -816,15 +814,29 @@ int rxrpc_kernel_send_data(struct socket *sock, struc= t rxrpc_call *call, ASSERTCMP(msg->msg_name, =3D=3D, NULL); ASSERTCMP(msg->msg_control, =3D=3D, NULL); =20 - mutex_lock(&call->user_mutex); + for (;;) { + mutex_lock(&call->user_mutex); =20 - ret =3D rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, len, - notify_end_tx, &dropped_lock); - if (ret =3D=3D -ESHUTDOWN) - ret =3D call->error; + ret =3D rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, + msg_data_left(msg), + notify_end_tx, &dropped_lock); + if (ret =3D=3D -ESHUTDOWN) + ret =3D call->error; + + if (!dropped_lock) + mutex_unlock(&call->user_mutex); + if (ret < 0) + break; + if (msg_data_left(msg) =3D=3D 0) { + ret =3D 0; + break; + } + if (ret =3D=3D 0) { + ret =3D -EIO; + break; + } + } =20 - if (!dropped_lock) - mutex_unlock(&call->user_mutex); _leave(" =3D %d", ret); return ret; } From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 4888F4A5EB9 for ; Mon, 14 Sep 2026 15:14:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398848; cv=none; b=Q7j8egWSYZSnh1N6MT6q8StyKo+xO4rp23bISLidsthRMECeSuoNzMLRUe/qo7o8dm/GLJa6pZ5cyJya4e5VRMXUlGr+6n8SIfUAF9ITQPn5+2Y2NJzJpCc4DVP03m+WU7a5hSzT7qw4EpkR+svQRbMZDpRohM+OjjOnOMmxffE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398848; c=relaxed/simple; bh=qu1a4D3n3eMBQyrcOyOOdCePdmonXSrT6Fdpl/F0JcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ScMgSJRgDliN5Sy+0k2wVKq/cqOwXKVvkQF8HIn4Couom8hrHiuBd6dqO0IiAFm/ZkBQ76nxdT+AZ4CPTYkxaEm06FmxU119KrxktKwH1eZqcQe5KMoJWJBiM/jrlXV3ttELm20KTRfvgsmZ5OjMwzxnNUXOechIxpG1V6wl03g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SwIoKBw+; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SwIoKBw+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bxfU28vY4jGpIFbJ5It3kleVAPLwHORiApFBN+rAZFQ=; b=SwIoKBw+N/rwRLC3EOrzhF7wDilLPJxrhS8xeJD/ckFvPBC7c4ZESc6utSz9Sxo650A5qK lHEHVZ5wGydWViRJ4Nup5ceoSmYAj4loSGZ8lXOD6fBC9wOPv0zrGIgBxlmSJhsBxuVuaC nV1Xa1uA3Xqg2rNzfdPRLULZ2ykZ1d4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-163-wsStrZxBPK6hNFa3vlztqg-1; Mon, 14 Sep 2026 11:14:01 -0400 X-MC-Unique: wsStrZxBPK6hNFa3vlztqg-1 X-Mimecast-MFC-AGG-ID: wsStrZxBPK6hNFa3vlztqg_1789398840 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A4CAB1955DA3; Mon, 14 Sep 2026 15:13:59 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 49BAF1955F74; Mon, 14 Sep 2026 15:13:56 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v10 02/14] afs: Fix afs to abort the rxrpc call on send error Date: Mon, 14 Sep 2026 16:13:26 +0100 Message-ID: <20260914151340.3227501-3-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Fix afs_send_empty_reply() and afs_send_simple_reply() to always try to abort the rxrpc call rather than just aborting on -ENOMEM and otherwise abandoning it. If the call is already complete due to network failure or a received abort, this will do nothing. Also make afs_make_call() always abort on send error; again, it does nothing if the rxrpc call is already dead. Fixes: 08e0e7c82eea ("[AF_RXRPC]: Make the in-kernel AFS filesystem use AF_= RXRPC.") Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260824091645.41= 5423-1-dhowells%40redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: stable@vger.kernel.org --- fs/afs/rxrpc.c | 36 +++++++++++------------------------- include/trace/events/rxrpc.h | 2 +- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c index 09d9da92a1be..2b241716dae7 100644 --- a/fs/afs/rxrpc.c +++ b/fs/afs/rxrpc.c @@ -441,10 +441,8 @@ void afs_make_call(struct afs_call *call, gfp_t gfp) return; =20 error_do_abort: - if (ret !=3D -ECONNABORTED) - rxrpc_kernel_abort_call(call->net->socket, rxcall, - RX_USER_ABORT, ret, - afs_abort_send_data_error); + rxrpc_kernel_abort_call(call->net->socket, rxcall, + RX_USER_ABORT, ret, afs_abort_send_data_error); if (call->async) { afs_see_call(call, afs_call_trace_async_abort); return; @@ -857,6 +855,7 @@ void afs_send_empty_reply(struct afs_call *call) { struct afs_net *net =3D call->net; struct msghdr msg; + int ret; =20 _enter(""); =20 @@ -869,22 +868,12 @@ void afs_send_empty_reply(struct afs_call *call) msg.msg_controllen =3D 0; msg.msg_flags =3D 0; =20 - switch (rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, - afs_notify_end_reply_tx)) { - case 0: - _leave(" [replied]"); - return; - - case -ENOMEM: - _debug("oom"); + ret =3D rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, + afs_notify_end_reply_tx); + if (ret < 0) rxrpc_kernel_abort_call(net->socket, call->rxcall, - RXGEN_SS_MARSHAL, -ENOMEM, - afs_abort_oom); - fallthrough; - default: - _leave(" [error]"); - return; - } + RXGEN_SS_MARSHAL, ret, + afs_abort_send_error); } =20 /* @@ -913,12 +902,9 @@ void afs_send_simple_reply(struct afs_call *call, cons= t void *buf, size_t len) n =3D rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, afs_notify_end_reply_tx); if (n < 0) { - if (n =3D=3D -ENOMEM) { - _debug("oom"); - rxrpc_kernel_abort_call(net->socket, call->rxcall, - RXGEN_SS_MARSHAL, -ENOMEM, - afs_abort_oom); - } + rxrpc_kernel_abort_call(net->socket, call->rxcall, + RXGEN_SS_MARSHAL, n, + afs_abort_send_error); _leave(" [error]"); } } diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h index 704a10de6670..554dfb777b93 100644 --- a/include/trace/events/rxrpc.h +++ b/include/trace/events/rxrpc.h @@ -20,10 +20,10 @@ /* AFS errors */ \ EM(afs_abort_general_error, "afs-error") \ EM(afs_abort_interrupted, "afs-intr") \ - EM(afs_abort_oom, "afs-oom") \ EM(afs_abort_op_not_supported, "afs-op-notsupp") \ EM(afs_abort_probeuuid_negative, "afs-probeuuid-neg") \ EM(afs_abort_send_data_error, "afs-send-data") \ + EM(afs_abort_send_error, "afs-send-error") \ EM(afs_abort_unmarshal_error, "afs-unmarshal") \ EM(afs_abort_unsupported_sec_class, "afs-unsup-sec-class") \ /* rxperf errors */ \ From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 3A2074A5ED4 for ; Mon, 14 Sep 2026 15:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398853; cv=none; b=Wn014Q7g1hx36GwP+LJ8SYM99ByTaCsXHI97cyzrHFKO5g/Uv8/qd2E7ws3iI3NEqqEZoi3dvMN1VxQ2CwKm2qg2HyjMF5daHfk/+FC5KXE3oEgJDU+Pb9VxHIGtgwtYSyw1ZI4sTcRrgMJXarXcbISssmmagxmeA9qYzFoQedg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398853; c=relaxed/simple; bh=phAkye/EJNpcSduR90Yp8yo3aM4oCybisxH/jY/cUG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iu5TXzP04r3C8EVIfNQRhSpZwFj97CXglNBS9ou+zk4YUHyXAiF3Berf5SzHC9z9aHqd/ZXsTBtJ/vit92+nv8Q2fRe4eBweQ+yYhY8FV0QBMwR5vxd2jM04jGFiZTFKiDJFOzeUt3sRxoszfqliRN7k5OimI1GsxpIufRHEYvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UHAtJypa; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UHAtJypa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EOO7MP/O7yI0gdCaE6cgkc3hHa5AFZfhvVJeV02lzh0=; b=UHAtJypafeLKTwOuE06e3eNnXQb1FawXRMin4zvdlbtQC4j+WF+tyJwXmsaKuWakx2+P14 7MK929sii7aR/+GaRtp5/tbLhujyVMcckVzjtspCQY6j2RbYOgj7n9Z+2ylfddDl3hlwMH qY5tRfGPgC8JxL5bqEJSYOz4pPojjX8= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-455-mUJnU8zBPjqvFBDBPZMPLQ-1; Mon, 14 Sep 2026 11:14:05 -0400 X-MC-Unique: mUJnU8zBPjqvFBDBPZMPLQ-1 X-Mimecast-MFC-AGG-ID: mUJnU8zBPjqvFBDBPZMPLQ_1789398844 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7CC23182A100; Mon, 14 Sep 2026 15:14:04 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 345F01955F73; Mon, 14 Sep 2026 15:14:00 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net v10 03/14] rxrpc: Fix aborting in rxperf test server Date: Mon, 14 Sep 2026 16:13:27 +0100 Message-ID: <20260914151340.3227501-4-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Fix rxperf_process_call() to always abort if it gets a send error rather than only aborting on ENOMEM. Fixes: 75bfdbf2fca3 ("rxrpc: Implement an in-kernel rxperf server for testi= ng purposes") Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260824091645.41= 5423-1-dhowells%40redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org --- include/trace/events/rxrpc.h | 2 +- net/rxrpc/rxperf.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h index 554dfb777b93..56dc9b614071 100644 --- a/include/trace/events/rxrpc.h +++ b/include/trace/events/rxrpc.h @@ -28,8 +28,8 @@ EM(afs_abort_unsupported_sec_class, "afs-unsup-sec-class") \ /* rxperf errors */ \ EM(rxperf_abort_general_error, "rxperf-error") \ - EM(rxperf_abort_oom, "rxperf-oom") \ EM(rxperf_abort_op_not_supported, "rxperf-op-notsupp") \ + EM(rxperf_abort_send_error, "rxperf-send-error") \ EM(rxperf_abort_unmarshal_error, "rxperf-unmarshal") \ /* RxKAD security errors */ \ EM(rxkad_abort_1_short_check, "rxkad1-short-check") \ diff --git a/net/rxrpc/rxperf.c b/net/rxrpc/rxperf.c index dad04062213f..7e9a53615309 100644 --- a/net/rxrpc/rxperf.c +++ b/net/rxrpc/rxperf.c @@ -538,10 +538,10 @@ static int rxperf_process_call(struct rxperf_call *ca= ll) msg.msg_flags =3D 0; n =3D rxrpc_kernel_send_data(rxperf_socket, call->rxcall, &msg, rxperf_notify_end_reply_tx); - if (n =3D=3D -ENOMEM) + if (n < 0) rxrpc_kernel_abort_call(rxperf_socket, call->rxcall, - RXGEN_SS_MARSHAL, -ENOMEM, - rxperf_abort_oom); + RXGEN_SS_MARSHAL, n, + rxperf_abort_send_error); return n; } From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 203B54A8A11 for ; Mon, 14 Sep 2026 15:14:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398860; cv=none; b=L3Krpl+3Cmny8N4bnH2S4YgWkN7uUUTt5ZtGmd4ECYyN0UJq0qKHvbFbyUGR4ZE7flx2c1eXbrREDZo4N2ECCd5kfYM8+WjZ6TDsAeRj2bN8WGeUQcNgeNJkD0oED1o7lJqanV7FaXlg3H7+8SpMSbFQ79tgn4ELnK7RmHZJV2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398860; c=relaxed/simple; bh=BTUYdjiNyWYKS0lyIKWewUOB3C4RptV4RmilWSTe1zc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YqMXO41sPqj3kEIb0mKE4rdtGVsCyXWd+mdwYeGl00lemJmAdgM7sXlF8XvXM8RsnU33vBDZuNYlqiqStE+ZoZNImAtyl3Jig2JfMTa7EfU9qZqvKD7mYkdJ6KrDPdFCx5ApQBDyDzi601ExZFi3/Wq/MhXsQdECjxqAYMAGyfI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SjAMXnRu; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SjAMXnRu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SO0lyd2TLY4/Tg6BoXH46sF7IwyWzQWoxxUwdMPlakQ=; b=SjAMXnRuRn2zJULWgRsMtuJrNsJsfcUMY+2blkj+u1QAqzdwoortrbpyidXeXq7UQx3Xy8 fGT3IEZ6b2IScIxD/UFMtTd7L/Jz8K911JbaAMcYIQGDfnZVgbNpquEDmX8Q/BOUIP5ABH KxOcxodhqRTQ8sw10J3vodXUgwnSxFw= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-qFx_ZRCdMnKWLYn098GeqQ-1; Mon, 14 Sep 2026 11:14:11 -0400 X-MC-Unique: qFx_ZRCdMnKWLYn098GeqQ-1 X-Mimecast-MFC-AGG-ID: qFx_ZRCdMnKWLYn098GeqQ_1789398850 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DD7E2180A9F9; Mon, 14 Sep 2026 15:14:09 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0C614180057F; Mon, 14 Sep 2026 15:14:05 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, Jeffrey Altman Subject: [PATCH net v10 04/14] rxrpc: Fix sendmsg length Date: Mon, 14 Sep 2026 16:13:28 +0100 Message-ID: <20260914151340.3227501-5-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" rxrpc_send_data() is given two data lengths (len and msg->msg_iter.count) and is inconsistent about how it uses them. Fix this by using len in preference to msg->msg_iter.count. Also limit the amount copied to either len or msg->msg_iter.count, whichever is smaller. Note that, currently, all the callers have len and msg->msg_iter.count the same and so the problem won't occur. This is a prerequisite for another patch that fixes the handling of encryption errors. Fixes: 382d7974de31 ("RxRPC: Use iov_iter_count() in rxrpc_send_data() inst= ead of the len argument") Signed-off-by: David Howells cc: Marc Dionne cc: Jeffrey Altman cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org --- net/rxrpc/sendmsg.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c index 34aae8e789a4..bbb39835ef9e 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -379,9 +379,9 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, =20 ret =3D -EMSGSIZE; if (call->tx_total_len !=3D -1) { - if (len - copied > call->tx_total_len) + if (len > call->tx_total_len) goto maybe_error; - if (!more && len - copied !=3D call->tx_total_len) + if (!more && len !=3D call->tx_total_len) goto maybe_error; } =20 @@ -405,7 +405,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, * the security header is going to be in the padded * region (enc blocksize), but the trailer is not. */ - remain =3D more ? INT_MAX : msg_data_left(msg); + remain =3D more ? INT_MAX : len; txb =3D call->conn->security->alloc_txbuf(call, remain, sk->sk_allocati= on); if (!txb) { ret =3D -ENOMEM; @@ -416,8 +416,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, _debug("append"); =20 /* append next segment of data to the current buffer */ - if (msg_data_left(msg) > 0) { - size_t copy =3D umin(txb->space, msg_data_left(msg)); + if (len > 0) { + size_t copy =3D min3(txb->space, len, msg_data_left(msg)); =20 _debug("add %zu", copy); if (!copy_from_iter_full(txb->data + txb->offset, @@ -428,6 +428,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, txb->len +=3D copy; txb->offset +=3D copy; copied +=3D copy; + len -=3D copy; if (call->tx_total_len !=3D -1) call->tx_total_len -=3D copy; } @@ -439,8 +440,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, =20 /* add the packet to the send queue if it's now full */ if (!txb->space || - (msg_data_left(msg) =3D=3D 0 && !more)) { - if (msg_data_left(msg) =3D=3D 0 && !more) + (len =3D=3D 0 && !more)) { + if (len =3D=3D 0 && !more) txb->flags |=3D RXRPC_LAST_PACKET; =20 ret =3D call->security->secure_packet(call, txb); @@ -449,7 +450,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, rxrpc_queue_packet(rx, call, txb, notify_end_tx); txb =3D NULL; } - } while (msg_data_left(msg) > 0); + } while (len > 0 && msg_data_left(msg) > 0); =20 success: ret =3D copied; From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 5331E4A2609 for ; Mon, 14 Sep 2026 15:14:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398863; cv=none; b=bPlC+LaC6Ek/uTT6vDkNNjF5ovoPI+yXRAfgXeHLgWgnJyv0lVN2vZN3Y3/4fdy2mFvjf9f60Ec7mCsoW7yl1KDnj94yIAwu6pwBbhU3DvOdQaXFyTHwd9OkD/Vc2KD320ar+DAAQj4Du5sdw5FteOdKj67N4qSOHVi3iZGrkok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398863; c=relaxed/simple; bh=MSYZLvdSF53s2gnH1MwLihMDsZmX1XHocL1mZCeHnb0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eV5xfV4K+3N8XFNTMfByRKlvRpZMrqu4md+FrSZ37DNWdr9rl/vE4i16lhmghZkfiCDseF5M7LiJ8JqclOV+zDE1hRGi5VmLGZiy/Ki/HdjGZ6w1GrZZspkn+WbpTPGH50Ejpp20u2C6Q1mZMyWhYebZhevdNmT7Z3C0xNwqM30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fIQ/fRkz; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fIQ/fRkz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398860; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TbhDlTCGOaV2Ga00p5gBetKJa/ySX4o9J5SlE1M7twI=; b=fIQ/fRkzjQwuFmVp1xbQY5Nm2Jaq3L5M7EEE0iJN4cAK+ncIuIzL4pyGonjcsWNUv4NA7I HMhMnvX77xJtU+6ZLmlwBdydQCu77BR/oZUBWHaYVKoRy49lGdLIwwlGQ601yMR2F6Tjf5 UrLkO1D1JUICELOU5lxZFZjNkbOvMe0= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-57-TVIb0RX8Pvewe_xL6Z2UIg-1; Mon, 14 Sep 2026 11:14:17 -0400 X-MC-Unique: TVIb0RX8Pvewe_xL6Z2UIg-1 X-Mimecast-MFC-AGG-ID: TVIb0RX8Pvewe_xL6Z2UIg_1789398855 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1D23F182A101; Mon, 14 Sep 2026 15:14:15 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 82C793003EF9; Mon, 14 Sep 2026 15:14:11 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v10 05/14] rxrpc: Fix update of call->tx_pending without holding lock Date: Mon, 14 Sep 2026 16:13:29 +0100 Message-ID: <20260914151340.3227501-6-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Currently, rxrpc_send_data() updates call->tx_pending just before it returns - but it won't be holding the call->user_mutex when it does this if a wait was interrupted by a signal. This would allow a parallel sendmsg() to race. Further, both the callers of rxrpc_send_data() call it with the lock held, and then it returns an indication through the parameter list to say whether it has dropped the lock or not - after which the callers both just drop the lock if it's still held. Fix this by: (1) Moving the release of call->user_mutex down into rxrpc_send_data() and get rid of the indicator parameter. This makes it easier to see where the lock is held. (2) After waiting, if the attempt to reacquire the mutex is interrupted, just return directly there rather than going to out_unlock (3) Restricting the txb variable to inside the buffering loop and leaving ->tx_pending set until we've queued the buffer. Note that there's a slight change in behaviour in that wait_for_space failure now doesn't check for completion because it doesn't hold the call user_mutex. The caller, however, should re-issue the send and pick up any error at a second attempt. Fixes: b0f571ecd794 ("rxrpc: Fix locking in rxrpc's sendmsg") Closes: https://sashiko.dev/#/patchset/20260702144919.172295-1-dhowells%40r= edhat.com Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: stable@vger.kernel.org --- net/rxrpc/sendmsg.c | 61 ++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c index bbb39835ef9e..b370e440e2fd 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -320,10 +320,9 @@ static int rxrpc_alloc_txqueue(struct sock *sk, struct= rxrpc_call *call) static int rxrpc_send_data(struct rxrpc_sock *rx, struct rxrpc_call *call, struct msghdr *msg, size_t len, - rxrpc_notify_end_tx_t notify_end_tx, - bool *_dropped_lock) + rxrpc_notify_end_tx_t notify_end_tx) + __releases(&call->user_mutex) { - struct rxrpc_txbuf *txb; struct sock *sk =3D &rx->sk; enum rxrpc_call_state state; long timeo; @@ -341,23 +340,18 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, =20 ret =3D rxrpc_wait_to_be_connected(call, &timeo); if (ret < 0) - return ret; + goto out_unlock; =20 if (call->conn->state =3D=3D RXRPC_CONN_CLIENT_UNSECURED) { ret =3D rxrpc_init_client_conn_security(call->conn); if (ret < 0) - return ret; + goto out_unlock; } =20 /* this should be in poll */ sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); =20 reload: - txb =3D call->tx_pending; - call->tx_pending =3D NULL; - if (txb) - rxrpc_see_txbuf(txb, rxrpc_txbuf_see_send_more); - ret =3D -EPIPE; if (sk->sk_shutdown & SEND_SHUTDOWN) goto maybe_error; @@ -386,6 +380,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, } =20 do { + struct rxrpc_txbuf *txb =3D call->tx_pending; + if (!txb) { size_t remain; =20 @@ -411,6 +407,9 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, ret =3D -ENOMEM; goto maybe_error; } + call->tx_pending =3D txb; + } else { + rxrpc_see_txbuf(txb, rxrpc_txbuf_see_send_more); } =20 _debug("append"); @@ -446,9 +445,9 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, =20 ret =3D call->security->secure_packet(call, txb); if (ret < 0) - goto out; + goto out_unlock; rxrpc_queue_packet(rx, call, txb, notify_end_tx); - txb =3D NULL; + call->tx_pending =3D NULL; } } while (len > 0 && msg_data_left(msg) > 0); =20 @@ -457,45 +456,46 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, if (rxrpc_call_is_complete(call) && call->error < 0) ret =3D call->error; -out: - call->tx_pending =3D txb; +out_unlock: + mutex_unlock(&call->user_mutex); _leave(" =3D %d", ret); return ret; =20 call_terminated: - rxrpc_put_txbuf(txb, rxrpc_txbuf_put_send_aborted); - _leave(" =3D %d", call->error); - return call->error; + ret =3D call->error; + goto out_unlock; =20 maybe_error: if (copied) goto success; - goto out; + goto out_unlock; =20 efault: ret =3D -EFAULT; - goto out; + goto out_unlock; =20 wait_for_space: ret =3D -EAGAIN; if (msg->msg_flags & MSG_DONTWAIT) goto maybe_error; mutex_unlock(&call->user_mutex); - *_dropped_lock =3D true; + ret =3D rxrpc_wait_for_tx_window(rx, call, &timeo, msg->msg_flags & MSG_WAITALL); if (ret < 0) - goto maybe_error; + goto out_nolock; if (call->interruptibility =3D=3D RXRPC_INTERRUPTIBLE) { if (mutex_lock_interruptible(&call->user_mutex) < 0) { ret =3D sock_intr_errno(timeo); - goto maybe_error; + goto out_nolock; } } else { mutex_lock(&call->user_mutex); } - *_dropped_lock =3D false; goto reload; +out_nolock: + _leave(" =3D %d [intr]", ret); + return copied ?: ret; } =20 /* @@ -661,7 +661,6 @@ rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx= , struct msghdr *msg, int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len) { struct rxrpc_call *call; - bool dropped_lock =3D false; int ret; =20 struct rxrpc_send_params p =3D { @@ -770,16 +769,15 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct ms= ghdr *msg, size_t len) ret =3D 0; break; case RXRPC_CMD_SEND_DATA: - ret =3D rxrpc_send_data(rx, call, msg, len, NULL, &dropped_lock); - break; + ret =3D rxrpc_send_data(rx, call, msg, len, NULL); + goto error_put; default: ret =3D -EINVAL; break; } =20 out_put_unlock: - if (!dropped_lock) - mutex_unlock(&call->user_mutex); + mutex_unlock(&call->user_mutex); error_put: rxrpc_put_call(call, rxrpc_call_put_sendmsg); _leave(" =3D %d", ret); @@ -807,7 +805,6 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msgh= dr *msg, size_t len) int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call, struct msghdr *msg, rxrpc_notify_end_tx_t notify_end_tx) { - bool dropped_lock =3D false; int ret; =20 _enter("{%d},", call->debug_id); @@ -819,13 +816,9 @@ int rxrpc_kernel_send_data(struct socket *sock, struct= rxrpc_call *call, mutex_lock(&call->user_mutex); =20 ret =3D rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, - msg_data_left(msg), - notify_end_tx, &dropped_lock); + msg_data_left(msg), notify_end_tx); if (ret =3D=3D -ESHUTDOWN) ret =3D call->error; - - if (!dropped_lock) - mutex_unlock(&call->user_mutex); if (ret < 0) break; if (msg_data_left(msg) =3D=3D 0) { From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 9CDD74A8FCD for ; Mon, 14 Sep 2026 15:14:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398869; cv=none; b=tHkCn7143KdHtwmZN/O2f0IDj65mpqvlrf3BTlgczr5Y6pXHT//K/P3XMbdBYuX5TVhU4VHqMHPr8mJ4YBDEFk1jIHmK1Feoax8Wko5/I+ecrvRsKIcRv+GsHflNBUNP13jp8xy/LoTcfPtBl5wv8vCKUmVMoRG+H6FDymb6OvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398869; c=relaxed/simple; bh=ah6DVqgjWSsjAl7nGPEMc1dYlpPs9nu3vx5QsgwP/1U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kL5qun0TI5q5LdR7Ozga9y6mDp4d6qnKjkRKpHkyq1oDfbVlfeiw9G+N8NSXwfs09+b/xbsTIhvaQMai46c1EEwRuVI/G17gTv+WL3lLxDTPlB2r7NAR/nqXn4Cf2VQnVI92td4MsbrDkcuSygWk4UiETrkI7tDzkrkQiHbw7ls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=L/jqJkwu; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="L/jqJkwu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398865; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i/Au7LwzqNLdJcIcoE6j8/auqWHac1zYcU/BxTnTJZ8=; b=L/jqJkwu7WstRrflRAVXEUv/yx5o2omlY84EHstHWpn8zvAUUMmOiE12nakNPuTwx7t1eB e3bOTkEpb6qEBoRL+P3JasZY7FTeYCTXwkbdZxM8Zf2gtvgQZ4ZWIeDWrf+UW7jnC7vPgY R7GmJSH7MGnwT4Vdra/7mKlxxlzVFh0= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-OvpZnCxmOvKMrxne6JtqZA-1; Mon, 14 Sep 2026 11:14:22 -0400 X-MC-Unique: OvpZnCxmOvKMrxne6JtqZA-1 X-Mimecast-MFC-AGG-ID: OvpZnCxmOvKMrxne6JtqZA_1789398860 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 157DC18333E3; Mon, 14 Sep 2026 15:14:20 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A64841956086; Mon, 14 Sep 2026 15:14:16 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, Jeffrey Altman , stable@vger.kernel.org Subject: [PATCH net v10 06/14] rxrpc: Fix error handling in rxrpc_send_data() Date: Mon, 14 Sep 2026 16:13:30 +0100 Message-ID: <20260914151340.3227501-7-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Fix the error handling in rxrpc_send_data() so that it doesn't return an error if it has successfully queued the last packet of a call, but the call has seen to have completed after it did that. Rather, leave it to recvmsg() to report the completion (which it will do anyway). The problem with trying to report the error twice is that the caller may try to clean up the dead call twice. Further, if we haven't queued the final packet yet, return -ESHUTDOWN if the call is now marked complete (e.g. it got aborted by the peer) as there's no point sendmsg() continuing to try to add data to a call if it is defunct. The application should abort the call and then call recvmsg() to pick up the reason. Fixes: 4ba68c519255 ("rxrpc: Return an error to sendmsg if call failed") Signed-off-by: David Howells cc: Marc Dionne cc: Jeffrey Altman cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: stable@vger.kernel.org --- fs/afs/rxrpc.c | 11 +++--- net/rxrpc/rxperf.c | 38 +++++++++++++------- net/rxrpc/sendmsg.c | 86 +++++++++++++++++++++++++++++++++------------ 3 files changed, 95 insertions(+), 40 deletions(-) diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c index 2b241716dae7..4694a6fca9b4 100644 --- a/fs/afs/rxrpc.c +++ b/fs/afs/rxrpc.c @@ -448,13 +448,14 @@ void afs_make_call(struct afs_call *call, gfp_t gfp) return; } =20 - if (ret =3D=3D -ECONNABORTED) { + if (ret =3D=3D -ESHUTDOWN) { len =3D 0; iov_iter_kvec(&msg.msg_iter, ITER_DEST, NULL, 0, 0); - rxrpc_kernel_recv_data(call->net->socket, rxcall, - &msg.msg_iter, &len, false, - &call->abort_code, &call->service_id); - call->responded =3D true; + ret =3D rxrpc_kernel_recv_data(call->net->socket, rxcall, + &msg.msg_iter, &len, false, + &call->abort_code, &call->service_id); + if (ret =3D=3D -ECONNABORTED) + call->responded =3D true; } call->error =3D ret; trace_afs_call_done(call); diff --git a/net/rxrpc/rxperf.c b/net/rxrpc/rxperf.c index 7e9a53615309..83016830e696 100644 --- a/net/rxrpc/rxperf.c +++ b/net/rxrpc/rxperf.c @@ -74,7 +74,7 @@ static struct workqueue_struct *rxperf_workqueue; static void rxperf_deliver_to_call(struct work_struct *work); static int rxperf_deliver_param_block(struct rxperf_call *call); static int rxperf_deliver_request(struct rxperf_call *call); -static int rxperf_process_call(struct rxperf_call *call); +static void rxperf_process_call(struct rxperf_call *call); static void rxperf_charge_preallocation(struct work_struct *work); =20 static DECLARE_WORK(rxperf_charge_preallocation_work, @@ -293,18 +293,28 @@ static void rxperf_deliver_to_call(struct work_struct= *work) state =3D=3D RXPERF_CALL_SV_AWAIT_ACK ) { if (state =3D=3D RXPERF_CALL_SV_AWAIT_ACK) { - if (!rxrpc_kernel_check_life(rxperf_socket, call->rxcall)) + size_t len =3D 0; + iov_iter_kvec(&call->iter, ITER_DEST, NULL, 0, 0); + ret =3D rxrpc_kernel_recv_data(rxperf_socket, + call->rxcall, &call->iter, + &len, false, &remote_abort, + &call->service_id); + + if (ret =3D=3D -EINPROGRESS || ret =3D=3D -EAGAIN) + return; + if (ret < 0 || ret =3D=3D 1) { + if (ret =3D=3D 1) + ret =3D 0; goto call_complete; + } return; } =20 ret =3D call->deliver(call); - if (ret =3D=3D 0) - ret =3D rxperf_process_call(call); - switch (ret) { case 0: - continue; + rxperf_process_call(call); + return; case -EINPROGRESS: case -EAGAIN: return; @@ -508,7 +518,7 @@ static int rxperf_deliver_request(struct rxperf_call *c= all) /* * Process a call for which we've received the request. */ -static int rxperf_process_call(struct rxperf_call *call) +static void rxperf_process_call(struct rxperf_call *call) { struct msghdr msg =3D {}; struct bio_vec bv; @@ -527,7 +537,7 @@ static int rxperf_process_call(struct rxperf_call *call) n =3D rxrpc_kernel_send_data(rxperf_socket, call->rxcall, &msg, rxperf_notify_end_reply_tx); if (n < 0) - return n; + goto send_error; reply_len -=3D len; } =20 @@ -539,10 +549,13 @@ static int rxperf_process_call(struct rxperf_call *ca= ll) n =3D rxrpc_kernel_send_data(rxperf_socket, call->rxcall, &msg, rxperf_notify_end_reply_tx); if (n < 0) - rxrpc_kernel_abort_call(rxperf_socket, call->rxcall, - RXGEN_SS_MARSHAL, n, - rxperf_abort_send_error); - return n; + goto send_error; + return; + +send_error: + rxrpc_kernel_abort_call(rxperf_socket, call->rxcall, + RXGEN_SS_MARSHAL, n, + rxperf_abort_send_error); } =20 /* @@ -695,4 +708,3 @@ static void __exit rxperf_exit(void) rcu_barrier(); } module_exit(rxperf_exit); - diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c index b370e440e2fd..1012d2d337a5 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -329,13 +329,6 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, bool more =3D msg->msg_flags & MSG_MORE; int ret, copied =3D 0; =20 - if (test_bit(RXRPC_CALL_TX_NO_MORE, &call->flags)) { - trace_rxrpc_abort(call->debug_id, rxrpc_sendmsg_late_send, - call->cid, call->call_id, call->rx_consumed, - 0, -EPROTO); - return -EPROTO; - } - timeo =3D sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT); =20 ret =3D rxrpc_wait_to_be_connected(call, &timeo); @@ -352,13 +345,20 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); =20 reload: + if (unlikely(test_bit(RXRPC_CALL_TX_NO_MORE, &call->flags))) { + trace_rxrpc_abort(call->debug_id, rxrpc_sendmsg_late_send, + call->cid, call->call_id, call->rx_consumed, + 0, -EPROTO); + ret =3D -EPROTO; + goto out_unlock; + } + ret =3D -EPIPE; if (sk->sk_shutdown & SEND_SHUTDOWN) - goto maybe_error; + goto out_unlock; state =3D rxrpc_call_state(call); - ret =3D -ESHUTDOWN; if (state >=3D RXRPC_CALL_COMPLETE) - goto maybe_error; + goto call_terminated; ret =3D -EPROTO; if (state !=3D RXRPC_CALL_CLIENT_PRE_SEND && state !=3D RXRPC_CALL_CLIENT_SEND_REQUEST && @@ -368,7 +368,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, trace_rxrpc_abort(call->debug_id, rxrpc_sendmsg_late_send, call->cid, call->call_id, call->rx_consumed, 0, -EPROTO); - goto maybe_error; + goto out_unlock; } =20 ret =3D -EMSGSIZE; @@ -448,31 +448,73 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, goto out_unlock; rxrpc_queue_packet(rx, call, txb, notify_end_tx); call->tx_pending =3D NULL; + + /* At this point, if that was the last packet, it may + * have been transmitted and the reply (client call) or + * final ACK (service call) may have been received, + * completing the call. + */ } } while (len > 0 && msg_data_left(msg) > 0); =20 -success: + /* Don't check for call completeness here, but leave that to recvmsg or + * a further call to sendmsg(). + */ ret =3D copied; - if (rxrpc_call_is_complete(call) && - call->error < 0) - ret =3D call->error; out_unlock: mutex_unlock(&call->user_mutex); +out: + + /* The return value is a bit complicated as we want to avoid returning + * an error if we have queued the final packet. In descending order of + * preference: + * + * (1) If we queue the last packet: the amount copied (which may be + * zero). recvmsg() should be used to collect the result. + * + * (2) If another sendmsg() has already queued the last packet: -EPROTO. + * + * (3) If the send side of the socket is shut down, -EPIPE. + * + * (4) If the call is in the wrong state to transmit: -EPROTO. + * + * (5) If the call has terminated early, likely due to an external + * event such as being remotely aborted: -ESHUTDOWN. + * + * (6) If some data has been copied by this call: the amount copied + * (which will be greater than zero). + * + * (7) Any other error. + * + * For (2)-(5), there's no point in continuing with the sendmsg(). The + * app should abort the call (just in case the error came from + * somewhere else) and then use recvmsg() to collect the final result + * of the call. + */ _leave(" =3D %d", ret); return ret; =20 call_terminated: - ret =3D call->error; + ret =3D -ESHUTDOWN; goto out_unlock; =20 maybe_error: - if (copied) - goto success; + if (copied) { + if (test_bit(RXRPC_CALL_TX_NO_MORE, &call->flags)) { + /* If we've get here, we must have slept waiting for space and . + */ + ret =3D copied; + goto out_unlock; + } + if (rxrpc_call_is_complete(call)) + goto call_terminated; + ret =3D copied; + } goto out_unlock; =20 efault: ret =3D -EFAULT; - goto out_unlock; + goto maybe_error; =20 wait_for_space: ret =3D -EAGAIN; @@ -495,7 +537,9 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, goto reload; out_nolock: _leave(" =3D %d [intr]", ret); - return copied ?: ret; + if (copied) + ret =3D copied; + goto out; } =20 /* @@ -817,8 +861,6 @@ int rxrpc_kernel_send_data(struct socket *sock, struct = rxrpc_call *call, =20 ret =3D rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, msg_data_left(msg), notify_end_tx); - if (ret =3D=3D -ESHUTDOWN) - ret =3D call->error; if (ret < 0) break; if (msg_data_left(msg) =3D=3D 0) { From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 6591249B5AE for ; Mon, 14 Sep 2026 15:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398872; cv=none; b=hpah63U94guvUuyFw22IzXugQ2dJi/mbkdyEdiuaP8NuYfvUQnBx9uX/S/y/JXU8kxhQgktFdvbJ5B10hsSdCUf7PYmQ1kVINJW2zRAOPNI2nDj+n5iiKJ9CeqMGgirU9RWAPJcQd8H4q80xUKfbSOruHuW0K4GOnBmAwrPbBGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398872; c=relaxed/simple; bh=n+++pehzSMdqbL5BtCndPHmia10d0QX7iMtIrAmvWjk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dKtqeOcM1pfySB97oWIFVbOuemaWawjolKXJ8+1+KwQI/a9cAvm+4wAV/Ilmy8zY20cbp14UkHoD9JzsffBsAnLR3QGSFL8LjD8zAfT1LcDj8FZLyQWTneluu6BW7rdtoWMzCHjBYagDY/S6hlqbr+vo/vrV6h3QZRoecmkh59w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Q0xYo4PH; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Q0xYo4PH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=giDxXwL1o+CMg1THzWf5zoSR2NVsWyaJX7jNumHMRio=; b=Q0xYo4PH3g6t9EtmlsSN9N4JL3Xk7n6BMvGVW9cUYWQUOEorTMkq1YpOpj+J0YJbuZhQUv 33rijMVPmKGXmSE7E9+ZgOxcv1jRdQSN8ILaP1dbvqb4vggEFI3UwxkNnmydyQ6ofJbWUR jnMjgOu8VzaqxYrTLsojSV4j7AlvDXE= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-264-aCqHsJ7nP-CHMM1mNlMo4w-1; Mon, 14 Sep 2026 11:14:26 -0400 X-MC-Unique: aCqHsJ7nP-CHMM1mNlMo4w-1 X-Mimecast-MFC-AGG-ID: aCqHsJ7nP-CHMM1mNlMo4w_1789398865 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C820D182A102; Mon, 14 Sep 2026 15:14:24 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B0DEE1956053; Mon, 14 Sep 2026 15:14:21 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v10 07/14] rxrpc: Fix packet encryption error handling Date: Mon, 14 Sep 2026 16:13:31 +0100 Message-ID: <20260914151340.3227501-8-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" In rxrpc_send_data(), if ->secure_packet() returns an error, the code currently just jumps to out: and returns the error to the app on the assumption that any error returned by this is automatically fatal for the call, and may even have corrupted the transmission queue - but leaving it to userspace to deal with. Nothing stops the application from retrying the sendmsg(), which will try to encrypt the buffer again, and might succeed with a corrupt buffer. Fix rxrpc_send_data() in the following ways: (1) If -ENOMEM is returned, assume we never got as far as the encryption and that the operation is retryable. In which case, jump to maybe_error_rewind and, if we've copied all remaining data into the last packet, remove some of the bytes from it that we just added so that we don't tell the caller that we've completed the transmission phase. The iterator is also correspondingly rewound. (2) If any other error occurs, set the TX_ERROR flag on the call and return that error directly; on all subsequent attempts to add data to the call, return -EIO. The app must then abort the call to get rid of it (this allows the app to choose the abort code to use). Fixes: 17926a79320a ("[AF_RXRPC]: Provide secure RxRPC sockets for use by u= serspace and kernel both") Closes: https://sashiko.dev/#/patchset/20260702144919.172295-1-dhowells%40r= edhat.com Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: stable@vger.kernel.org --- Documentation/networking/rxrpc.rst | 6 ++- include/trace/events/rxrpc.h | 1 + net/rxrpc/ar-internal.h | 1 + net/rxrpc/sendmsg.c | 63 +++++++++++++++++++++++++----- 4 files changed, 59 insertions(+), 12 deletions(-) diff --git a/Documentation/networking/rxrpc.rst b/Documentation/networking/= rxrpc.rst index 01ad12fdf305..9b7eeae84148 100644 --- a/Documentation/networking/rxrpc.rst +++ b/Documentation/networking/rxrpc.rst @@ -878,8 +878,10 @@ The kernel interface functions are as follows: exclusively to in-kernel virtual addresses. msg.msg_flags may be giv= en MSG_MORE if there will be subsequent data sends for this call. =20 - The msg must not specify a destination address, control data or any f= lags - other than MSG_MORE. + msg must not specify a destination address, control data or any flags + other than MSG_MORE. The last-packet flag will only be set on the + outgoing packet if MSG_MORE is not set and all the data in the iterat= or is + buffered. =20 notify_end_rx can be NULL or it can be used to specify a function to = be called when the call changes state to end the Tx phase. This functio= n is diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h index 56dc9b614071..a5c92592d8f9 100644 --- a/include/trace/events/rxrpc.h +++ b/include/trace/events/rxrpc.h @@ -148,6 +148,7 @@ EM(rxrpc_eproto_wrong_security, "wrong-sec") \ EM(rxrpc_recvmsg_excess_data, "recvmsg-excess") \ EM(rxrpc_recvmsg_short_data, "recvmsg-short") \ + EM(rxrpc_sendmsg_tx_error, "tx-error") \ E_(rxrpc_sendmsg_late_send, "sendmsg-late") =20 #define rxrpc_call_poke_traces \ diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h index 865f05fe37ab..a6f830c1621f 100644 --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h @@ -642,6 +642,7 @@ enum rxrpc_call_flag { RXRPC_CALL_TX_LAST, /* Last packet in Tx buffer (at rxtx_top) */ RXRPC_CALL_TX_ALL_ACKED, /* Last packet has been hard-acked */ RXRPC_CALL_TX_NO_MORE, /* No more data to transmit (MSG_MORE deasserted)= */ + RXRPC_CALL_TX_ERROR, /* Terminal error; call needs abort */ RXRPC_CALL_SEND_PING, /* A ping will need to be sent */ RXRPC_CALL_RETRANS_TIMEOUT, /* Retransmission due to timeout occurred */ RXRPC_CALL_BEGAN_RX_TIMER, /* We began the expect_rx_by timer */ diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c index 1012d2d337a5..ed7ff32da184 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -325,6 +325,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, { struct sock *sk =3D &rx->sk; enum rxrpc_call_state state; + unsigned int rewind_by =3D 0; long timeo; bool more =3D msg->msg_flags & MSG_MORE; int ret, copied =3D 0; @@ -352,6 +353,13 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, ret =3D -EPROTO; goto out_unlock; } + if (unlikely(test_bit(RXRPC_CALL_TX_ERROR, &call->flags))) { + trace_rxrpc_abort(call->debug_id, rxrpc_sendmsg_tx_error, + call->cid, call->call_id, call->rx_consumed, + 0, -EIO); + ret =3D -EIO; + goto out_unlock; + } =20 ret =3D -EPIPE; if (sk->sk_shutdown & SEND_SHUTDOWN) @@ -423,6 +431,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, copy, &msg->msg_iter)) goto efault; _debug("added"); + rewind_by =3D copy; txb->space -=3D copy; txb->len +=3D copy; txb->offset +=3D copy; @@ -440,14 +449,29 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, /* add the packet to the send queue if it's now full */ if (!txb->space || (len =3D=3D 0 && !more)) { + /* Do any required crypto. If this fails, it could + * have corrupted the txbuf content with a partial + * encrypt. Assume that ENOMEM is retryable, but + * everything else is terminal. + */ + ret =3D call->security->secure_packet(call, txb); + if (ret < 0) { + /* Assume that ENOMEM here means that the + * encryption hasn't happened yet. The data is + * aligned to avoid the need for slow buffering + * in the crypto walk. + */ + if (ret =3D=3D -ENOMEM) + goto maybe_error_rewind; + set_bit(RXRPC_CALL_TX_ERROR, &call->flags); + goto out; + } + if (len =3D=3D 0 && !more) txb->flags |=3D RXRPC_LAST_PACKET; - - ret =3D call->security->secure_packet(call, txb); - if (ret < 0) - goto out_unlock; rxrpc_queue_packet(rx, call, txb, notify_end_tx); call->tx_pending =3D NULL; + rewind_by =3D 0; =20 /* At this point, if that was the last packet, it may * have been transmitted and the reply (client call) or @@ -474,19 +498,22 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, * * (2) If another sendmsg() has already queued the last packet: -EPROTO. * - * (3) If the send side of the socket is shut down, -EPIPE. + * (3) If an error caused it to be impossible to continue with the + * call: -EIO. * - * (4) If the call is in the wrong state to transmit: -EPROTO. + * (4) If the send side of the socket is shut down, -EPIPE. * - * (5) If the call has terminated early, likely due to an external + * (5) If the call is in the wrong state to transmit: -EPROTO. + * + * (6) If the call has terminated early, likely due to an external * event such as being remotely aborted: -ESHUTDOWN. * - * (6) If some data has been copied by this call: the amount copied + * (7) If some data has been copied by this call: the amount copied * (which will be greater than zero). * - * (7) Any other error. + * (8) Any other error. * - * For (2)-(5), there's no point in continuing with the sendmsg(). The + * For (2)-(6), there's no point in continuing with the sendmsg(). The * app should abort the call (just in case the error came from * somewhere else) and then use recvmsg() to collect the final result * of the call. @@ -498,6 +525,22 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, ret =3D -ESHUTDOWN; goto out_unlock; =20 +maybe_error_rewind: + /* If we got a retryable error after copying all the supplied data into + * the last packet, we need to rewind as much as we can so the caller + * knows they need to retry the sendmsg. + */ + if (rewind_by && !more && !len) { + struct rxrpc_txbuf *txb =3D call->tx_pending; + + txb->space +=3D rewind_by; + txb->len -=3D rewind_by; + txb->offset -=3D rewind_by; + copied -=3D rewind_by; + if (call->tx_total_len !=3D -1) + call->tx_total_len +=3D rewind_by; + iov_iter_revert(&msg->msg_iter, rewind_by); + } maybe_error: if (copied) { if (test_bit(RXRPC_CALL_TX_NO_MORE, &call->flags)) { From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 E98354A99D5 for ; Mon, 14 Sep 2026 15:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398880; cv=none; b=MdxYoYP4zYm137AjmwrIBm0Mmb7uSOnhaBlow81FQzmahF1bXTqaADP/gnBZ603t/yRBDNuWzMC4jJYA+B3QCr8QsOOLcnh+2w+LnlkeqZwQmD1Gegftav8Jk/zfyXJLh1GftwiR6I02nqzeRZzQQHHiunDYRpsQ/hNrjNUuaMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398880; c=relaxed/simple; bh=R+vDyZMcwZtPeSYXp7LPR+k2Zxh6L5h6f3+A0yiEABM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rBUFReMo3tcg9ccWQxYbGRVJdsXG2NkvrR/RS1SN5dB2XJLyUoYnZbgFMhyg4VHD4n40+3DRa1EAu5jBhGyDbutnH+qDxQtJLiVBZN1lCv3V7hUdWlykc+hs5xFugDdCwJBIGz3oDDjyOB2NR2qXn+h4kAJpN/8R18BuRvhghKg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=V9uC+fiR; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="V9uC+fiR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BRwiUko/ZuIdCZgQfYPgdfiRngNwWLuc9cEVQ2YL2IE=; b=V9uC+fiRZDYdqbKbdh3N6yyfFiUQD1mo3vpCTxiwE71Ce2DqS8WP3pn7sQEz4B18PpOxbq MewaoV9vvGWnHDPp2yX87mdkcVATIwUTkOUOPlXWMVFyjb9sPMmurBxNSIVUmvQBJpr8CU fQ8idJNDzaFBnAJNOZ91nN6hiamLKpU= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-257-0EcR6ZddMBKq1-uDhdZ6kA-1; Mon, 14 Sep 2026 11:14:31 -0400 X-MC-Unique: 0EcR6ZddMBKq1-uDhdZ6kA-1 X-Mimecast-MFC-AGG-ID: 0EcR6ZddMBKq1-uDhdZ6kA_1789398869 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 84F2818334BB; Mon, 14 Sep 2026 15:14:29 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6D51F1956053; Mon, 14 Sep 2026 15:14:26 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, stable@kernel.org Subject: [PATCH net v10 08/14] rxrpc: Fix double IRQ enablement Date: Mon, 14 Sep 2026 16:13:32 +0100 Message-ID: <20260914151340.3227501-9-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" rxrpc_notify_socket() explicitly disables and then re-enables IRQs, but one of its call chains (rxrpc_input_queue_data() -> rxrpc_end_rx_phase() -> rxrpc_call_completed() -> rxrpc_set_call_completion()) has IRQs disabled around it. Fix this by making rxrpc_notify_socket() use irqsave spinlocks. Fixes: a2ea9a907260 ("rxrpc: Use irq-disabling spinlocks between app and I/= O thread") Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260812110129.97= 9970-6-dhowells@redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: stable@kernel.org --- net/rxrpc/recvmsg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c index efcba4b2e74f..56fa324d0962 100644 --- a/net/rxrpc/recvmsg.c +++ b/net/rxrpc/recvmsg.c @@ -24,6 +24,7 @@ void rxrpc_notify_socket(struct rxrpc_call *call) { struct rxrpc_sock *rx; struct sock *sk; + unsigned long flags; =20 _enter("%d", call->debug_id); =20 @@ -38,16 +39,16 @@ void rxrpc_notify_socket(struct rxrpc_call *call) sk =3D &rx->sk; if (rx && sk->sk_state < RXRPC_CLOSE) { if (call->notify_rx) { - spin_lock_irq(&call->notify_lock); + spin_lock_irqsave(&call->notify_lock, flags); call->notify_rx(sk, call, call->user_call_ID); - spin_unlock_irq(&call->notify_lock); + spin_unlock_irqrestore(&call->notify_lock, flags); } else { - spin_lock_irq(&rx->recvmsg_lock); + spin_lock_irqsave(&rx->recvmsg_lock, flags); if (list_empty(&call->recvmsg_link)) { rxrpc_get_call(call, rxrpc_call_get_notify_socket); list_add_tail(&call->recvmsg_link, &rx->recvmsg_q); } - spin_unlock_irq(&rx->recvmsg_lock); + spin_unlock_irqrestore(&rx->recvmsg_lock, flags); =20 if (!sock_flag(sk, SOCK_DEAD)) { _debug("call %ps", sk->sk_data_ready); From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 0A6C04A8FCD for ; Mon, 14 Sep 2026 15:14:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398882; cv=none; b=VM+eqJ0SXHb2cotGDHXB9ffj0uok+YKKw+Ld/7VF6dH4LZNjIQCa3E8dXj1+B1pA/CE2pDacMGGyzidvR25Ep0PKqlBcxIKc89vTVEyYcvsCVpQk/jEFbEMhisROEmCxgCrTjlItbODwcY7d+4RIYa9e7RMNEbgnqpJgdRiyNpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398882; c=relaxed/simple; bh=dxHFbm5ZYJZ7zev3sJQdS85KbgO1FWu8tpH3DpETNMQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QLZzpmwlHMEXL26iQ+yGaNEH4H0QunPW+BoBJat/1aiNDr/gnIu3NI5Op0KSihDgfWhyT9+KwmmIrWqXPf8TghOsxoewwjb4ctrZ8tm8edU2Oej7Voe7ADX5qC7txFyonTUyDUo6WhrGcl/zPu3OD3Pm5OzpiDduZLCs5/w1dUg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LqfTdLbQ; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LqfTdLbQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398879; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UeMvGpSmLxbGdrY4BRF/xvcUp4vFc+5CNvOggcrFyAU=; b=LqfTdLbQTMU+oao7CEewJL+vKYmDKQIUsGfmbEz8/qOl18wi/thABn3H4aAAzHiv44HIj3 ni4otYj38LuS+J6fkr8phac7ezXX+qrscwu+mYv2YC8GZffeuRovIr+MELIZIEbAFDlEPk fWP/yapihizX/oNmZScuI1JXrPhfsDk= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-464-XUZKcn-1N_qJf-p2xjRI1Q-1; Mon, 14 Sep 2026 11:14:35 -0400 X-MC-Unique: XUZKcn-1N_qJf-p2xjRI1Q-1 X-Mimecast-MFC-AGG-ID: XUZKcn-1N_qJf-p2xjRI1Q_1789398874 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2330618333E2; Mon, 14 Sep 2026 15:14:34 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 11B8C40E; Mon, 14 Sep 2026 15:14:30 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, stable@kernel.org Subject: [PATCH net v10 09/14] rxrpc: Fix generation of notifications after call completion Date: Mon, 14 Sep 2026 16:13:33 +0100 Message-ID: <20260914151340.3227501-10-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Content-Type: text/plain; charset="utf-8" AF_RXRPC may generate a notification to the application after a call has completed because it generates one notification when rxrpc_input_split_jumbo() queues the final packet and completes the call and then generates another when rxrpc_input_split_jumbo() does the aggregated data receive notification at the end of the function. This might cause the AFS filesystem to malfunction because it tries to queue the afs_call for processing an extra time. Most of the time this happens quickly enough that the second queue_work skips, but sometimes this means that the call work may happen a second time with implications for afs_call lifetime management. Fix this by: (1) Create a lighter version of rxrpc_notify_socket() that's just used to requeue a call for rxrpc_recvmsg() without creating another notification. (2) Move rxrpc_notify_socket() to call_state.c and rename it to __rxrpc_notify_socket(). (3) Create a wrapper called rxrpc_notify_socket() that skips the notification if a call is completed. (4) Make rxrpc_set_call_completion() call __rxrpc_notify_socket() to avoid the skip-if-completed check. Also remove the comment on rxrpc_notify_socket() that said it added the call to a dummy queue to prevent further notification. Fixes: 2d1faf7a0ca3 ("rxrpc: Simplify skbuff accounting in receive path") Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: stable@kernel.org --- include/trace/events/rxrpc.h | 1 + net/rxrpc/ar-internal.h | 2 +- net/rxrpc/call_state.c | 57 +++++++++++++++++++++++++++++++++++- net/rxrpc/recvmsg.c | 45 ++++++++++------------------ 4 files changed, 74 insertions(+), 31 deletions(-) diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h index a5c92592d8f9..52f8718cf725 100644 --- a/include/trace/events/rxrpc.h +++ b/include/trace/events/rxrpc.h @@ -343,6 +343,7 @@ EM(rxrpc_call_see_distribute_error, "SEE dist-err") \ EM(rxrpc_call_see_input, "SEE input ") \ EM(rxrpc_call_see_notify_released, "SEE nfy-rlsd") \ + EM(rxrpc_call_see_notify_skipped, "SEE nfy-skip") \ EM(rxrpc_call_see_recvmsg, "SEE recvmsg ") \ EM(rxrpc_call_see_recvmsg_requeue, "SEE recv-rqu") \ EM(rxrpc_call_see_recvmsg_requeue_first, "SEE recv-rqF") \ diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h index a6f830c1621f..cb36a709f540 100644 --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h @@ -1110,6 +1110,7 @@ static inline bool rxrpc_is_client_call(const struct = rxrpc_call *call) /* * call_state.c */ +void rxrpc_notify_socket(struct rxrpc_call *call); bool rxrpc_set_call_completion(struct rxrpc_call *call, enum rxrpc_call_completion compl, u32 abort_code, @@ -1442,7 +1443,6 @@ extern const struct seq_operations rxrpc_local_seq_op= s; /* * recvmsg.c */ -void rxrpc_notify_socket(struct rxrpc_call *); int rxrpc_recvmsg(struct socket *, struct msghdr *, size_t, int); =20 /* diff --git a/net/rxrpc/call_state.c b/net/rxrpc/call_state.c index 6afb54373ebb..52465e88a044 100644 --- a/net/rxrpc/call_state.c +++ b/net/rxrpc/call_state.c @@ -7,6 +7,61 @@ =20 #include "ar-internal.h" =20 +/* + * Post a call for attention by the socket or kernel service. + */ +static void __rxrpc_notify_socket(struct rxrpc_call *call) +{ + struct rxrpc_sock *rx; + struct sock *sk; + unsigned long flags; + + if (test_bit(RXRPC_CALL_RELEASED, &call->flags)) { + rxrpc_see_call(call, rxrpc_call_see_notify_released); + return; + } + + rcu_read_lock(); + + rx =3D rcu_dereference(call->socket); + sk =3D &rx->sk; + if (rx && sk->sk_state < RXRPC_CLOSE) { + if (call->notify_rx) { + spin_lock_irqsave(&call->notify_lock, flags); + call->notify_rx(sk, call, call->user_call_ID); + spin_unlock_irqrestore(&call->notify_lock, flags); + } else { + spin_lock_irqsave(&rx->recvmsg_lock, flags); + if (list_empty(&call->recvmsg_link)) { + rxrpc_get_call(call, rxrpc_call_get_notify_socket); + list_add_tail(&call->recvmsg_link, &rx->recvmsg_q); + } + spin_unlock_irqrestore(&rx->recvmsg_lock, flags); + + if (!sock_flag(sk, SOCK_DEAD)) { + _debug("call %ps", sk->sk_data_ready); + sk->sk_data_ready(sk); + } + } + } + + rcu_read_unlock(); +} + +/* + * Post a call for attention by the socket or kernel service if the call i= sn't + * already complete. + */ +void rxrpc_notify_socket(struct rxrpc_call *call) +{ + if (rxrpc_call_is_complete(call)) { + rxrpc_see_call(call, rxrpc_call_see_notify_skipped); + return; + } + + __rxrpc_notify_socket(call); +} + /* * Transition a call to the complete state. */ @@ -25,7 +80,7 @@ bool rxrpc_set_call_completion(struct rxrpc_call *call, rxrpc_set_call_state(call, RXRPC_CALL_COMPLETE); trace_rxrpc_call_complete(call); wake_up(&call->waitq); - rxrpc_notify_socket(call); + __rxrpc_notify_socket(call); return true; } =20 diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c index 56fa324d0962..22afc71ea474 100644 --- a/net/rxrpc/recvmsg.c +++ b/net/rxrpc/recvmsg.c @@ -17,14 +17,14 @@ #include "ar-internal.h" =20 /* - * Post a call for attention by the socket or kernel service. Further - * notifications are suppressed by putting recvmsg_link on a dummy queue. + * Requeue a call for recvmsg() to pick up. We ignore RXRPC_CLOSE, allowi= ng + * recvmsg() to continue picking up calls that are already on the queue if= it + * wants to, but no new calls will get added. */ -void rxrpc_notify_socket(struct rxrpc_call *call) +static void rxrpc_requeue_call(struct socket *sock, struct rxrpc_call *cal= l) { - struct rxrpc_sock *rx; - struct sock *sk; - unsigned long flags; + struct rxrpc_sock *rx =3D rxrpc_sk(sock->sk); + struct sock *sk =3D &rx->sk; =20 _enter("%d", call->debug_id); =20 @@ -33,31 +33,18 @@ void rxrpc_notify_socket(struct rxrpc_call *call) return; } =20 - rcu_read_lock(); - - rx =3D rcu_dereference(call->socket); - sk =3D &rx->sk; - if (rx && sk->sk_state < RXRPC_CLOSE) { - if (call->notify_rx) { - spin_lock_irqsave(&call->notify_lock, flags); - call->notify_rx(sk, call, call->user_call_ID); - spin_unlock_irqrestore(&call->notify_lock, flags); - } else { - spin_lock_irqsave(&rx->recvmsg_lock, flags); - if (list_empty(&call->recvmsg_link)) { - rxrpc_get_call(call, rxrpc_call_get_notify_socket); - list_add_tail(&call->recvmsg_link, &rx->recvmsg_q); - } - spin_unlock_irqrestore(&rx->recvmsg_lock, flags); + spin_lock_irq(&rx->recvmsg_lock); + if (list_empty(&call->recvmsg_link)) { + rxrpc_get_call(call, rxrpc_call_get_notify_socket); + list_add_tail(&call->recvmsg_link, &rx->recvmsg_q); + } + spin_unlock_irq(&rx->recvmsg_lock); =20 - if (!sock_flag(sk, SOCK_DEAD)) { - _debug("call %ps", sk->sk_data_ready); - sk->sk_data_ready(sk); - } - } + if (!sock_flag(sk, SOCK_DEAD)) { + _debug("call %ps", sk->sk_data_ready); + sk->sk_data_ready(sk); } =20 - rcu_read_unlock(); _leave(""); } =20 @@ -562,7 +549,7 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *m= sg, size_t len, =20 if (!(flags & MSG_PEEK) && !skb_queue_empty(&call->recvmsg_queue)) - rxrpc_notify_socket(call); + rxrpc_requeue_call(sock, call); goto not_yet_complete; =20 call_failed: From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 10EF049B5CF for ; Mon, 14 Sep 2026 15:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398887; cv=none; b=oWRqkvU/c4mN847ixkUrVbPCgvDhS/0JbTcL/BAqEE//2nJQRBg9qv2byH4G2nyXpXn02b7Vun1U2vetjA0LiX34WoRMe46J/eBAuBIsYyBwLZmzyf+rG8XH6C4bJnvF9HxzQJugtOlUAzFO9DTtQRM0EqxRqNnqzdafhdjBqkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398887; c=relaxed/simple; bh=S/Lj/pYcJczz56lh3VLaZdxY00WzdPXkbPQOBltxj9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HOvOi4WjT8zVUQCwwS6QprWv2R9jluIFwMRUQj9oPNppKGh+c9O/3Mhfg9K8a+gWUNw0CKQv7I1iwuBCQ/8KKqDf5m9JBxnXWqHrIIDH0vROUUxhm3HH0oai9/YtkTvYBQawrxXhn9kUS5vhNELEFMVvCz2vi4Ds23oy2wGqV6Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DjFjO+0V; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DjFjO+0V" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rZZYqLvurOLNLwad7WLLLlFjkLSEkWNVoz/2rnznaAk=; b=DjFjO+0VX7RtI6M04+RxfxHk1ijX9hG5+Erep12j1qkRacqSbT/rqw4lzYW09vLx780J+D oLzXnJWhoaruDODeqw28SpNjggDaXZVme6hiGApYxPgag0+tcr92y24+pu6wA5CR1vAF+x BM9tA3vmQnlRhNdfKgUk1WZvvJyMOZE= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-1HrBCneLP3q01it3SYIIRw-1; Mon, 14 Sep 2026 11:14:40 -0400 X-MC-Unique: 1HrBCneLP3q01it3SYIIRw-1 X-Mimecast-MFC-AGG-ID: 1HrBCneLP3q01it3SYIIRw_1789398878 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D50771829E1D; Mon, 14 Sep 2026 15:14:38 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BBAA21800345; Mon, 14 Sep 2026 15:14:35 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v10 10/14] rxrpc: Fix RxGK key parser to check enctype is supported Date: Mon, 14 Sep 2026 16:13:34 +0100 Message-ID: <20260914151340.3227501-11-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Fix the parser of RxGK keys supplied by userspace to check that the specified encryption type is supported and check the key length. Further, since the checking function isn't necessarily available in CONFIG_RXGK=3Dn, make the RxGK key wrangling bits conditional. Fixes: 0ca100ff4df6 ("rxrpc: Add YFS RxGK (GSSAPI) security class") Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260824091645.41= 5423-1-dhowells%40redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: stable@vger.kernel.org --- net/rxrpc/key.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c index a0aa78d89289..dc1b3aa51bf3 100644 --- a/net/rxrpc/key.c +++ b/net/rxrpc/key.c @@ -129,6 +129,7 @@ static int rxrpc_preparse_xdr_rxkad(struct key_preparse= d_payload *prep, return 0; } =20 +#ifdef CONFIG_RXGK static u64 xdr_dec64(const __be32 *xdr) { return (u64)ntohl(xdr[0]) << 32 | (u64)ntohl(xdr[1]); @@ -166,12 +167,14 @@ static int rxrpc_preparse_xdr_yfs_rxgk(struct key_pre= parsed_payload *prep, size_t datalen, const __be32 *xdr, unsigned int toklen) { + const struct krb5_enctype *enc; struct rxrpc_key_token *token, **pptoken; time64_t expiry; size_t plen; const __be32 *ticket, *key; s64 tmp; size_t raw_keylen, raw_tktlen, keylen, tktlen; + int ret =3D -EKEYREJECTED; =20 _enter(",{%x,%x,%x,%x},%x", ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), ntohl(xdr[3]), @@ -229,6 +232,17 @@ static int rxrpc_preparse_xdr_yfs_rxgk(struct key_prep= arsed_payload *prep, token->rxgk->key.data =3D token->rxgk->_key; token->rxgk->ticket.len =3D raw_tktlen; =20 + /* Check the enctype is supported. */ + enc =3D crypto_krb5_find_enctype(token->rxgk->enctype); + if (!enc) { + ret =3D -ENOPKG; + goto reject_token; + } + if (raw_keylen !=3D enc->key_len) { + ret =3D -EKEYREJECTED; + goto reject_token; + } + if (token->rxgk->endtime !=3D 0) { expiry =3D rxrpc_s64_to_time64(token->rxgk->endtime); if (expiry < 0) @@ -280,12 +294,13 @@ static int rxrpc_preparse_xdr_yfs_rxgk(struct key_pre= parsed_payload *prep, kfree(token->rxgk); kfree(token); reject: - return -EKEYREJECTED; + return ret; expired: kfree(token->rxgk); kfree(token); return -EKEYEXPIRED; } +#endif /* CONFIG_RXGK */ =20 /* * attempt to parse the data as the XDR format @@ -386,9 +401,11 @@ static int rxrpc_preparse_xdr(struct key_preparsed_pay= load *prep) case RXRPC_SECURITY_RXKAD: ret2 =3D rxrpc_preparse_xdr_rxkad(prep, datalen, token, toklen); break; +#ifdef CONFIG_RXGK case RXRPC_SECURITY_YFS_RXGK: ret2 =3D rxrpc_preparse_xdr_yfs_rxgk(prep, datalen, token, toklen); break; +#endif default: ret2 =3D -EPROTONOSUPPORT; break; @@ -556,10 +573,12 @@ static void rxrpc_free_token_list(struct rxrpc_key_to= ken *token) case RXRPC_SECURITY_RXKAD: kfree(token->kad); break; +#ifdef CONFIG_RXGK case RXRPC_SECURITY_YFS_RXGK: kfree(token->rxgk->ticket.data); kfree(token->rxgk); break; +#endif default: pr_err("Unknown token type %x on rxrpc key\n", token->security_index); @@ -603,9 +622,11 @@ static void rxrpc_describe(const struct key *key, stru= ct seq_file *m) case RXRPC_SECURITY_RXKAD: seq_puts(m, "ka"); break; +#ifdef CONFIG_RXGK case RXRPC_SECURITY_YFS_RXGK: seq_puts(m, "ygk"); break; +#endif default: /* we have a ticket we can't encode */ seq_printf(m, "%u", token->security_index); break; @@ -770,12 +791,14 @@ static long rxrpc_read(const struct key *key, toksize +=3D RND(token->kad->ticket_len); break; =20 +#ifdef CONFIG_RXGK case RXRPC_SECURITY_YFS_RXGK: toksize +=3D 6 * 8 + 2 * 4; if (!token->no_leak_key) toksize +=3D RND(token->rxgk->key.len); toksize +=3D RND(token->rxgk->ticket.len); break; +#endif =20 default: /* we have a ticket we can't encode */ pr_err("Unsupported key token type (%u)\n", @@ -856,6 +879,7 @@ static long rxrpc_read(const struct key *key, ENCODE_DATA(token->kad->ticket_len, token->kad->ticket); break; =20 +#ifdef CONFIG_RXGK case RXRPC_SECURITY_YFS_RXGK: ENCODE64(token->rxgk->begintime); ENCODE64(token->rxgk->endtime); @@ -869,6 +893,7 @@ static long rxrpc_read(const struct key *key, ENCODE_DATA(token->rxgk->key.len, token->rxgk->key.data); ENCODE_DATA(token->rxgk->ticket.len, token->rxgk->ticket.data); break; +#endif =20 default: pr_err("Unsupported key token type (%u)\n", From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 07C304A99D5 for ; Mon, 14 Sep 2026 15:14:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398892; cv=none; b=qmV/GeL/O5e1mot0nlkSItf/gThaCK65CzWGq9QNj/KO2TGEuYnFf3AZ+h/BQnevh1mTFBK8lxBxXQE916/2QXIwDyPNE74dDOv/YK/YeaPGxeX/rALZoelYe//RcfOlGvuPnUy/F08Zm2k6pes+POJbKNPDkqJq1j2oFopXU0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398892; c=relaxed/simple; bh=dh1Mrzcf+f+rjoBXTJvcOxtnk9SkdiWfNRAvyCc0RxM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SP9bK13S3hKAxqesZEaPbF16aaWxJRKFSMjb94x/oTKPvl6Gf5wxKe3ZDd4i7gcC5yhB8FbYtJ6ZrPyrXLPDfnezDnnYhgJFlmoiIF02oYzlWJx9+QtY5CuQkL5/mqLjP+JiOeSazTxIYPkWgULFwmZIcKhxO3FocfQhfAFwtYI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IalhPHxY; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IalhPHxY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/XWJhOFpUonxJbFBVSNDuN9cV/WjNeJgeL08PIPjZ7A=; b=IalhPHxY4s+Oe618KwLnviV44iL+JM2e0yrI5qTIzzidYz3SEEEkC5xWcAQiSAVMT49ytb B5bMy0WIrpqQH4b/5NcyIgp9YXTomKucc6SqeXsEUq9rwePvZ65jerXiVe0FdG3wDWuWZX btlFEWR5/NvEI6vdCfgw2Y9e2sDy6Kw= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-PcsrAKv7Obe0lTargPrb-A-1; Mon, 14 Sep 2026 11:14:45 -0400 X-MC-Unique: PcsrAKv7Obe0lTargPrb-A-1 X-Mimecast-MFC-AGG-ID: PcsrAKv7Obe0lTargPrb-A_1789398883 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7600C195DBAA; Mon, 14 Sep 2026 15:14:43 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 663AF40E; Mon, 14 Sep 2026 15:14:40 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v10 11/14] afs: Fix creation of RxGK CM channel token to have right size Date: Mon, 14 Sep 2026 16:13:35 +0100 Message-ID: <20260914151340.3227501-12-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Content-Type: text/plain; charset="utf-8" Fix afs_create_yfs_cm_token() so that it calculates the token size correctly, remembering to add in the 4 bytes of the level. As it happens, this bug has no effect because crypto_krb5_how_much_buffer() rounds encsize up to a multiple of the crypto block size (16 or 32) before adding on the checksum size - and so there's actually 8 bytes of unused space allocated within the blob-to-be-encrypted and 4 bytes of that gets used. Fixes: d98c317fd9aa ("afs: Use rxgk RESPONSE to pass token for callback cha= nnel") Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260824091645.41= 5423-1-dhowells%40redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: stable@vger.kernel.org --- fs/afs/cm_security.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/afs/cm_security.c b/fs/afs/cm_security.c index 103168c70dd4..5eeeef761cf3 100644 --- a/fs/afs/cm_security.c +++ b/fs/afs/cm_security.c @@ -235,7 +235,7 @@ static int afs_create_yfs_cm_token(struct sk_buff *chal= lenge, * struct RXGK_AuthName identities<>; * }; */ - toksize =3D keysize + 8 + 4 + 4 + 8 + xdr_len_object(authsize); + toksize =3D keysize + 4 + 8 + 4 + 4 + 8 + xdr_len_object(authsize); =20 offset =3D 0; encsize =3D crypto_krb5_how_much_buffer(token_krb5, KRB5_ENCRYPT_MODE, to= ksize, &offset); From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 8ADB54AA58F for ; Mon, 14 Sep 2026 15:14:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398895; cv=none; b=m6QCEyGDrknEb4zh8wVVaSTAE5snHXJbWFMhQPpcXGOe+Udt/nYgQazTxr7pDjfwcIHBMVqvItaXowh6NNjdJy0vN1NtfpOmQC+tHfVutpWt2wbAsgPXqFzZkElI6bP27SGxKSRwrSwY3CDyWGVvFje3l2Z32p2gN/XDCGImEl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398895; c=relaxed/simple; bh=7VhYWvTRpk42aGwR/DyS0rUdC1K5k+gwI3S8xT1cqMU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rStPdY4YyyRrfR4iiJ3njiV0i+VthXhbz+AKJ7wTcz7tHSGgMBoHyvOiZKuH3Ve/Eyoft6l7ZSGvW24SbeCXjid5PrK3D9Sf7XnzfTQq12Iy9DfGOvRgCHpXWmuZYs6f7QUolMGwd67JGqbCkCREUyRalouZmLfQzUCv4ZnCdMw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=eFxCa4O0; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eFxCa4O0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398892; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/YQ6jY2vMxj6CmWtcGwa3WgcRCD6xKPLYBefHI9f7cw=; b=eFxCa4O0NQGTWanuuAI/MNYpvdCtJlxxO7pioAVehGZt9FRWQ10kjV7WPc3WiF7Q3iNOSa jGaRZIejZe9YqDVcvuxc/Tb6RnQtOFDdio3tQ3qQ11b7rUcZaqlAoGC0t1ojw4uw8YIEhz CYxdaVMmj70RUYWgDA93EYOkR9ve0MQ= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-BW6U-u8IN0GV9M4pgcEr3w-1; Mon, 14 Sep 2026 11:14:50 -0400 X-MC-Unique: BW6U-u8IN0GV9M4pgcEr3w-1 X-Mimecast-MFC-AGG-ID: BW6U-u8IN0GV9M4pgcEr3w_1789398888 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C78D6182E6B7; Mon, 14 Sep 2026 15:14:48 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0465E180056E; Mon, 14 Sep 2026 15:14:44 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, Jeffrey Altman , Jarkko Sakkinen , keyrings@vger.kernel.org, stable@kernel.org Subject: [PATCH net v10 12/14] afs: Fix lack of setting call->server when doing FS.InlineBulkStatus Date: Mon, 14 Sep 2026 16:13:36 +0100 Message-ID: <20260914151340.3227501-13-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Fix afs_make_op_call to set call->server. This will prevent afs_done_fs_inline_bulk_status() from oopsing if the server does not support the FS.InlineBulkStatus RPC due to call->server not being set. Note that this requires afs_make_op_call() to be moved so that it can use afs_use_server(); the server is un-used by afs_free_call(). Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" conce= pt") Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260824091645.41= 5423-1-dhowells%40redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: Jeffrey Altman cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: Jarkko Sakkinen cc: linux-afs@lists.infradead.org cc: keyrings@vger.kernel.org cc: stable@kernel.org --- fs/afs/internal.h | 33 +++++++++++++++++---------------- include/trace/events/afs.h | 1 + 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 290873bac89b..65a0866cd8b8 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -1416,22 +1416,6 @@ static inline void afs_see_call(struct afs_call *cal= l, enum afs_call_trace why) __builtin_return_address(0)); } =20 -static inline void afs_make_op_call(struct afs_operation *op, struct afs_c= all *call, - gfp_t gfp) -{ - struct afs_addr_list *alist =3D op->estate->addresses; - - op->call =3D afs_get_call(call, afs_call_trace_get); - op->type =3D call->type; - call->op =3D op; - call->key =3D op->key; - call->intr =3D !(op->flags & AFS_OPERATION_UNINTR); - call->peer =3D rxrpc_kernel_get_peer(alist->addrs[op->addr_index].peer); - call->service_id =3D op->server->service_id; - afs_make_call(call, gfp); - afs_put_call(call); -} - static inline void afs_extract_begin(struct afs_call *call, void *buf, siz= e_t size) { call->iov_len =3D size; @@ -1763,6 +1747,23 @@ static inline struct inode *AFS_VNODE_TO_I(struct af= s_vnode *vnode) return &vnode->netfs.inode; } =20 +static inline void afs_make_op_call(struct afs_operation *op, struct afs_c= all *call, + gfp_t gfp) +{ + struct afs_addr_list *alist =3D op->estate->addresses; + + op->call =3D afs_get_call(call, afs_call_trace_get); + op->type =3D call->type; + call->op =3D op; + call->server =3D afs_use_server(op->server, false, afs_server_trace_use_c= all); + call->key =3D op->key; + call->intr =3D !(op->flags & AFS_OPERATION_UNINTR); + call->peer =3D rxrpc_kernel_get_peer(alist->addrs[op->addr_index].peer); + call->service_id =3D op->server->service_id; + afs_make_call(call, gfp); + afs_put_call(call); +} + /* * Note that a dentry got changed. We need to set d_fsdata to the data ve= rsion * number derived from the result of the operation. It doesn't matter if diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h index 1b3c48b5591d..04b0bb682b81 100644 --- a/include/trace/events/afs.h +++ b/include/trace/events/afs.h @@ -148,6 +148,7 @@ enum yfs_cm_operation { EM(afs_server_trace_unuse_slist_isort, "UNU isort") \ EM(afs_server_trace_update, "UPDATE ") \ EM(afs_server_trace_use_by_uuid, "USE uuid ") \ + EM(afs_server_trace_use_call, "USE call ") \ EM(afs_server_trace_use_cm_call, "USE cm-cl") \ EM(afs_server_trace_use_get_caps, "USE gcaps") \ EM(afs_server_trace_use_give_up_cb, "USE gvupc") \ From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 DE33B4A2A58 for ; Mon, 14 Sep 2026 15:14:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398902; cv=none; b=VHJc0qsuQq/Ni2VfUVFN/FbWjx4lqevU5jFsFq3ES+PbBpsamMb6UZLEdz10tpigwHM1WsuhNovVvVbId+xEUUY1PKKHSIAkQumdJ72bDU1JR9DZuWdKtVtwO/Wc6fPRYEjsbiSU7ZyKIRBgbX1eFfs/4MXBiGUXjrDQzQRj/CM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398902; c=relaxed/simple; bh=Xkx5uacLGMq2ROvzW9biAuFwvhBWSlh0ZaPMFOhQcvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cpCyKdfoRVefwqTdDH3gwdVUAsZ5Q+2oebWS35SwC2ndhSly3vJaMGUwW4p0ryBglNZ7fRZGCWinZgRp9LPk1EWLTKQLOljjaar0jFA1+bGvjau26KdtZLqF5lT9ytgkqRkCka5+a4vwS88RquC/l7Uer7EKCjFui6c6LQWXPeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=behZT0eY; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="behZT0eY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PicxqHVPZpCvrfAde8up7sgm2mpBjZr5f4x8vg4jkKM=; b=behZT0eYVQSCNOuiKiok2MCNHx1Qz01G4HSWRb3s3Lgq+nGnq9Ts66ZnaiVACefj3jOSW+ 06proTfbSa8Ney8Dmmn7MWTrNiBeLGU+DoyFCWstrhshh1JuehcpAyCb9RQUj3qBlRaPdH S5nhp016r73qs1M/8F94v7m6UfGhnOY= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-g-n6QT3sMXm3k7qj4pPO1g-1; Mon, 14 Sep 2026 11:14:54 -0400 X-MC-Unique: g-n6QT3sMXm3k7qj4pPO1g-1 X-Mimecast-MFC-AGG-ID: g-n6QT3sMXm3k7qj4pPO1g_1789398893 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 64EC019540EC; Mon, 14 Sep 2026 15:14:53 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 776761955F7D; Mon, 14 Sep 2026 15:14:50 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net v10 13/14] afs: Fix uncleared op->call pointer Date: Mon, 14 Sep 2026 16:13:37 +0100 Message-ID: <20260914151340.3227501-14-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Fix uncleared op->call pointer in afs_wait_for_operation() lest server rotation occur and try to reuse the call. Note that afs_read_receive() already does this. Note that this was spotted by AI code inspection rather than by hitting an issue. Fixes: 6f2ff7e89bd0 ("afs: Don't put afs_call in afs_wait_for_call_to_compl= ete()") Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260907113743.14= 53210-1-dhowells%40redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org --- fs/afs/fs_operation.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/afs/fs_operation.c b/fs/afs/fs_operation.c index 20801b29521d..94fa65548d71 100644 --- a/fs/afs/fs_operation.c +++ b/fs/afs/fs_operation.c @@ -297,6 +297,7 @@ void afs_wait_for_operation(struct afs_operation *op) op->call_error =3D op->call->error; op->call_responded =3D op->call->responded; afs_put_call(op->call); + op->call =3D NULL; } } From nobody Fri Sep 25 09:19:49 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 C3AF34AD4A0 for ; Mon, 14 Sep 2026 15:15:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398908; cv=none; b=gR8davyuSPEX+aRLLAiWOSNoF5Gkfp1C2z7KlYqRqAwTW6Rz4eksNQhh6HBrhx3KonYfP4e9NbItUVpoOorIUIGMoyb0Ed7znG7qlif7UXhOnxq1g0hrRnWvwbKkYmooXR9PqlTJEZNpssMh4sp0dzsfVJYz4jEbRy2r2lIvVFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789398908; c=relaxed/simple; bh=hNd6bIyFAvlFxc6hjuFcDqVwVqg86Zvx1YHzqvt4tLo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jez5NTJuny0N2TV6BkSkz41AN2QtIywiS/T29y3uxoRSHsbHXwK+pkWFwYARowtRA87XyHIzChTLI6a3TSPSiMLQtIyCHv0qm84DVtU/ETWOJHhv2f5aUqtRLx2kdIBYFT6eq0KCovS/pWCebyJOOahaFAJ2aoB5nbzl4N6x9aU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=cUn38/Id; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cUn38/Id" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789398902; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HHCKmh+GTex17viqHU7+p3b1kZPrhM46bDIsKbGkEho=; b=cUn38/IdzjbC6noEfIlT1NJZjhL/ddlmpEmFJ0KEcbpyfjU5uPXeNdoXFQkaEmq484EvCC P5yIaoE4Ztm+3B+9J9rk0cSuDqmGqq1SjjQeCOMeUZxHxk/7yx35VbmjKqXe3lRyhiFeKf k99KQ6Lwl0hkQPfTDxvi1LqjYLUM1Pw= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-219-FM2AOCG5NnyFscYW_fIqdw-1; Mon, 14 Sep 2026 11:15:00 -0400 X-MC-Unique: FM2AOCG5NnyFscYW_fIqdw-1 X-Mimecast-MFC-AGG-ID: FM2AOCG5NnyFscYW_fIqdw_1789398899 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A95BB189F3B1; Mon, 14 Sep 2026 15:14:58 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E826D3003EF9; Mon, 14 Sep 2026 15:14:54 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, Seungwon Bae , stable@vger.kernel.org Subject: [PATCH net v10 14/14] rxrpc: fix use-after-free in rxrpc_poke_conn() Date: Mon, 14 Sep 2026 16:13:38 +0100 Message-ID: <20260914151340.3227501-15-dhowells@redhat.com> In-Reply-To: <20260914151340.3227501-1-dhowells@redhat.com> References: <20260914151340.3227501-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" From: Seungwon Bae rxrpc_poke_conn() takes a reference on the connection with no liveness check, unlike its sibling rxrpc_queue_conn() which gates on atomic_read(&conn->active) >=3D 0. The per-connection timer is armed with no reference held for it, and rxrpc_put_connection() cancels it with a non-synchronous timer_delete() only after the refcount reaches 0. refcount_t saturates rather than resurrecting, so the connection can be kfree()d while still linked in local->conn_attend_q (nothing in teardown unlinks attend_link). The rxrpc I/O thread then performs a UAF write (list_del_init) plus UAF reads and indirect calls through conn->security. Reproduced on a KASAN + PREEMPT kernel: 56 "refcount_t: addition on 0" saturations at load, escalating to BUG: KASAN: slab-use-after-free in rxrpc_io_thread Write of size 8 AF_RXRPC socket creation (rxrpc_create) has no capability check, so this is reachable by an unprivileged user. Guard rxrpc_poke_conn() with the same liveness/refcount check the sibling rxrpc_queue_conn() uses before taking the poke reference, so a connection past its last-active point is not poked/requeued after teardown began. Verified before/after on KASAN+PREEMPT at equal timer volume: 56 saturations + 15 KASAN reports unpatched vs 0 and 0 patched. Fixes: f2cce89a074e ("rxrpc: Implement a mechanism to send an event notific= ation to a connection") Signed-off-by: Seungwon Bae Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: stable@vger.kernel.org --- net/rxrpc/conn_object.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c index 0ece717db0f8..1be50e0c9cee 100644 --- a/net/rxrpc/conn_object.c +++ b/net/rxrpc/conn_object.c @@ -34,7 +34,10 @@ void rxrpc_poke_conn(struct rxrpc_connection *conn, enum= rxrpc_conn_trace why) spin_lock_irq(&local->lock); busy =3D !list_empty(&conn->attend_link); if (!busy) { - rxrpc_get_connection(conn, why); + if (!rxrpc_get_connection_maybe(conn, why)) { + spin_unlock_irq(&local->lock); + return; + } list_add_tail(&conn->attend_link, &local->conn_attend_q); } spin_unlock_irq(&local->lock);