Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 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: Jens Axboe <axboe@kernel.dk>
cc: Matthew Wilcox <willy@infradead.org>
Link: https://lore.kernel.org/r/20787.1686828722@warthog.procyon.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

David Howells and committed by
Jakub Kicinski
9f8d0dc0 5a6f6873

+3 -1
+3 -1
net/kcm/kcmsock.c
··· 661 661 kcm_abort_tx_psock(psock, ret ? -ret : EPIPE, 662 662 true); 663 663 unreserve_psock(kcm); 664 + psock = NULL; 664 665 665 666 txm->started_tx = false; 666 667 kcm_report_tx_retry(kcm); ··· 697 696 if (!head) { 698 697 /* Done with all queued messages. */ 699 698 WARN_ON(!skb_queue_empty(&sk->sk_write_queue)); 700 - unreserve_psock(kcm); 699 + if (psock) 700 + unreserve_psock(kcm); 701 701 } 702 702 703 703 /* Check if write space is available */