All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] kcm: Fix unnecessary psock unreservation.
@ 2023-06-15 11:32 David Howells
  2023-06-17  7:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2023-06-15 11:32 UTC (permalink / raw)
  To: netdev
  Cc: dhowells, syzbot+dd1339599f1840e4cc65, Tom Herbert, Tom Herbert,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jens Axboe, Matthew Wilcox, linux-kernel

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: syzbot+dd1339599f1840e4cc65@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/000000000000a61ffe05fe0c3d08@google.com/
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: syzbot+dd1339599f1840e4cc65@syzkaller.appspotmail.com
cc: Tom Herbert <tom@herbertland.com>
cc: Tom Herbert <tom@quantonium.net>
cc: "David S. Miller" <davem@davemloft.net>
cc: Eric Dumazet <edumazet@google.com>
cc: Jakub Kicinski <kuba@kernel.org>
cc: Paolo Abeni <pabeni@redhat.com>
cc: Jens Axboe <axboe@kernel.dk>
cc: Matthew Wilcox <willy@infradead.org>
cc: netdev@vger.kernel.org
---
 net/kcm/kcmsock.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index d75d775e9462..d0537c1c8cd7 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -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 */


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] kcm: Fix unnecessary psock unreservation.
  2023-06-15 11:32 [PATCH net-next] kcm: Fix unnecessary psock unreservation David Howells
@ 2023-06-17  7:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-17  7:20 UTC (permalink / raw)
  To: David Howells
  Cc: netdev, syzbot+dd1339599f1840e4cc65, tom, tom, davem, edumazet,
	kuba, pabeni, axboe, willy, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-17  7:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-15 11:32 [PATCH net-next] kcm: Fix unnecessary psock unreservation David Howells
2023-06-17  7:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.