linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Shigeru Yoshida <syoshida@redhat.com>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
	nbd@other.debian.org, linux-kernel@vger.kernel.org,
	syzbot+38e6c55d4969a14c1534@syzkaller.appspotmail.com
Subject: Re: [PATCH] nbd: Fix hung when signal interrupts nbd_start_device_ioctl()
Date: Wed, 7 Sep 2022 13:27:25 -0400	[thread overview]
Message-ID: <YxjUfQUc66B+N1e7@localhost.localdomain> (raw)
In-Reply-To: <20220907163502.577561-1-syoshida@redhat.com>

On Thu, Sep 08, 2022 at 01:35:02AM +0900, Shigeru Yoshida wrote:
> syzbot reported hung task [1].  The following program is a simplified
> version of the reproducer:
> 
> int main(void)
> {
> 	int sv[2], fd;
> 
> 	if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) < 0)
> 		return 1;
> 	if ((fd = open("/dev/nbd0", 0)) < 0)
> 		return 1;
> 	if (ioctl(fd, NBD_SET_SIZE_BLOCKS, 0x81) < 0)
> 		return 1;
> 	if (ioctl(fd, NBD_SET_SOCK, sv[0]) < 0)
> 		return 1;
> 	if (ioctl(fd, NBD_DO_IT) < 0)
> 		return 1;
> 	return 0;
> }
> 
> When signal interrupt nbd_start_device_ioctl() waiting the condition
> atomic_read(&config->recv_threads) == 0, the task can hung because it
> waits the completion of the inflight IOs.
> 
> This patch fixes the issue by clearing queue, not just shutdown, when
> signal interrupt nbd_start_device_ioctl().
> 
> Link: https://syzkaller.appspot.com/bug?id=7d89a3ffacd2b83fdd39549bc4d8e0a89ef21239 [1]
> Reported-by: syzbot+38e6c55d4969a14c1534@syzkaller.appspotmail.com
> Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

  reply	other threads:[~2022-09-07 17:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-07 16:35 [PATCH] nbd: Fix hung when signal interrupts nbd_start_device_ioctl() Shigeru Yoshida
2022-09-07 17:27 ` Josef Bacik [this message]
2022-09-08 14:41 ` Jens Axboe

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=YxjUfQUc66B+N1e7@localhost.localdomain \
    --to=josef@toxicpanda.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nbd@other.debian.org \
    --cc=syoshida@redhat.com \
    --cc=syzbot+38e6c55d4969a14c1534@syzkaller.appspotmail.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;
as well as URLs for NNTP newsgroup(s).