mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: syzbot <syzbot+dd1339599f1840e4cc65@syzkaller.appspotmail.com>
Cc: dhowells@redhat.com, bpf@vger.kernel.org, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	pabeni@redhat.com, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [net?] WARNING in unreserve_psock
Date: Wed, 14 Jun 2023 18:22:02 +0100	[thread overview]
Message-ID: <1665043.1686763322@warthog.procyon.org.uk> (raw)
In-Reply-To: <000000000000a61ffe05fe0c3d08@google.com>

#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@syzkaller.appspotmail.com
    Link: https://lore.kernel.org/r/000000000000a61ffe05fe0c3d08@google.com/
    Signed-off-by: David Howells <dhowells@redhat.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

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


  parent reply	other threads:[~2023-06-14 17:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13 16:16 syzbot
2023-06-14  0:43 ` syzbot
2023-06-14 16:10   ` David Howells
2023-06-14 17:22   ` David Howells [this message]
2023-06-14 23:41     ` syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1665043.1686763322@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+dd1339599f1840e4cc65@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®