Skip to contentSkip to conversation

kcm: Fix unnecessary psock unreservation.

PATCH Applied David Howells 2 participants 2 messages Jun 15, 2023 – Jun 17, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kcm: Fix unnecessary psock unreservation.

kcm_write_msgs() calls unreserve_psock() to release its hold on the underlying TCP socket if it has run out of things to transmit, but if we have nothing in the write queue on entry (e.g. because someone did a zero-length sendmsg), we don't actually go into the transmission loop and as a consequence don't call reserve_psock().

Fix this by skipping the call to unreserve_psock() if we didn't reserve a psock.

Fixes c31a25e1db48 ("kcm: Send multiple frags in one sendmsg()")
Reported-by [email protected]
cc Tom Herbert <[email protected]>
cc Tom Herbert <[email protected]>
cc "David S. Miller" <[email protected]>
cc Eric Dumazet <[email protected]>
cc Jakub Kicinski <[email protected]>
cc Paolo Abeni <[email protected]>
cc Jens Axboe <[email protected]>
cc Matthew Wilcox <[email protected]>
---
 net/kcm/kcmsock.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/kcm/kcmsock.c +3 -1
index d75d775e9462..d0537c1c8cd7 100644
@@ -661,6 +661,7 @@ static int kcm_write_msgs(struct kcm_sock *kcm)
 				kcm_abort_tx_psock(psock, ret ? -ret : EPIPE,
 						   true);
 				unreserve_psock(kcm);
+				psock = NULL;
 
 				txm->started_tx = false;
 				kcm_report_tx_retry(kcm);
@@ -696,7 +697,8 @@ static int kcm_write_msgs(struct kcm_sock *kcm)
 	if (!head) {
 		/* Done with all queued messages. */
 		WARN_ON(!skb_queue_empty(&sk->sk_write_queue));
-		unreserve_psock(kcm);
+		if (psock)
+			unreserve_psock(kcm);
 	}
 
 	/* Check if write space is available */
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Thu, 15 Jun 2023 12:32:02 +0100 you wrote:

kcm_write_msgs() calls unreserve_psock() to release its hold on the underlying TCP socket if it has run out of things to transmit, but if we have nothing in the write queue on entry (e.g. because someone did a zero-length sendmsg), we don't actually go into the transmission loop and as a consequence don't call reserve_psock().

Fix this by skipping the call to unreserve_psock() if we didn't reserve a psock.

[...]

Here is the summary with links:
- [net-next] kcm: Fix unnecessary psock unreservation.

    https://git.kernel.org/netdev/net-next/c/9f8d0dc0ec4a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html