Re: [syzbot] [net?] WARNING in unreserve_psock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main

    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@xxxxxxxxxxxxxxxxxxxxxxxxx
    Link: https://lore.kernel.org/r/000000000000a61ffe05fe0c3d08@xxxxxxxxxx/
    Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
    cc: Tom Herbert <tom@xxxxxxxxxxxxxxx>
    cc: Tom Herbert <tom@xxxxxxxxxxxxxx>
    cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
    cc: Eric Dumazet <edumazet@xxxxxxxxxx>
    cc: Jakub Kicinski <kuba@xxxxxxxxxx>
    cc: Paolo Abeni <pabeni@xxxxxxxxxx>
    cc: Jens Axboe <axboe@xxxxxxxxx>
    cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
    cc: netdev@xxxxxxxxxxxxxxx

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 */






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux