Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11403035imu; Mon, 31 Dec 2018 21:45:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN6ZrnM4SsJw8GAKl3yItixcLu0M92yDLKbdLFRg9AHRAO6aqOYzBpgpGs9/FuQsoQ0xymFf X-Received: by 2002:a63:fc05:: with SMTP id j5mr9795105pgi.434.1546321536242; Mon, 31 Dec 2018 21:45:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546321536; cv=none; d=google.com; s=arc-20160816; b=OHLK/+MxRT7jIv2DNsG2+yTNnQDaIcvLoUSdfdpqJgORtPQ5cE3tPVOI/TS0m+9u2U bTNp9DREioHJlX5afVk8tioGAmU7hDQrnk3KGG9v0H0nDSihyfIM2EXGr93UuBBlViZQ jIFVeVnEzEDjDI0hLub3vXQFdgM6PHPJ6uc4eQEMGMYA1yEr0c4O1b852KSP2qqKmlqY TeiNjE/yZ1WKjucSGDFhQVzkYFXLjDpyHrgCvM2Lfvlsc4Oxbj1rF5FFy5yhtK1J3we8 RQyYvqlIUEQJk7UTG5XGzbm2D+T3dSimU9qqXxt/KSo4ZKEL/wsMVLbKxa70nxUKNnfs gsfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=PRlJLJKr5eFfT+b/vjdBWReTYKAn14YIYBq3f/2Pb8s=; b=ILlcOloFXg75W5eueZOrdTSuGHT0LOae8B7/JqfrDWNU6n+q55MnC7xRN3jXXQFkX8 21ZD7bhVI1xLGKNDhstVYVtkMzc+guKGv3iIaZXILQ21eSd+3ND8ZJbwGqNhPHRpQT9X ek6RBUB81DZoKO4rPgiqm7bsupELFAoqTW8nLNOxTjaIpVyjW+Zkg/LcO4BEl62IYI0n eiASxAuy5y3Wifa5JAbuCC93Zvl4Km5IsBR6J8cseGwqJE0r2cLCPS5XoaHAblrKBOUa YcwP0D5r1ivDzEa+hKXdstX+UUqcmuek4cfARsjf8EWgXlhRrrXKqsJ5OZXby/N5X283 2PJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microgate-com.20150623.gappssmtp.com header.s=20150623 header.b=fI5E2pxI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4si46752682pla.299.2018.12.31.21.44.49; Mon, 31 Dec 2018 21:45:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microgate-com.20150623.gappssmtp.com header.s=20150623 header.b=fI5E2pxI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729152AbfAADNh (ORCPT + 99 others); Mon, 31 Dec 2018 22:13:37 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46726 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727945AbfAADNg (ORCPT ); Mon, 31 Dec 2018 22:13:36 -0500 Received: by mail-pl1-f196.google.com with SMTP id t13so13152441ply.13 for ; Mon, 31 Dec 2018 19:13:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microgate-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=PRlJLJKr5eFfT+b/vjdBWReTYKAn14YIYBq3f/2Pb8s=; b=fI5E2pxI2gH5i8BgT1zlgrKS3vX9KQCMyfSJiIb6FL+7CWXbOY3XEq8L5pyNsJTmvz APIXQpIkSd0qo/vwxGc8kugteAfH8K7yNj/W9DrIXuZ/Ar387ZkDVGgUZERhIeiijKsa wyRFg92n88ch/isKft0W9HwfgkbVGcnUDM+Gnw195LEsrsdqKpA0CMEDvKJQ6LJQgg3R gKyS2Cuq/cZuoGlJVEq4qyYgdPzaeuSngZPr2XGvF3uZ1Bz1jIKrgf853BdRm8+asKkV WG2NEqBnfLknUwgr6wBqhUhadizxXtjUvbouPXAvEuB68Z+c37LLG1seNZ11O+rgT4/k HYdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=PRlJLJKr5eFfT+b/vjdBWReTYKAn14YIYBq3f/2Pb8s=; b=h0Et2qC+P4piL86Sk8M4CwSxdNfcpxNVm2bIaIuYvOm4MC+kcEuEdqCDucoZxQJA3a UVGe7B13G/TxFJQ+8xIv7hqUCjoboDkAOkM8GcCz7twO8PYdAywFwyi+VW2JLUCIM2Dx Za/o7a4QO4pjbunAgmVtk8779RftIOI7a2GG04kD609/wmSTuXJvjRDKMQgM8QyHTvt8 /F/6dtkznXeH4SlDxDMxXRGlgk+iLJKbwtXajKRcVpwonJObsgqE2G/yuVlxhEEEa+Yi 4ZxlrtJiFpDl6HanOVXzx4qwJkHjvGmcZpROW5Mjux490AlDevfUZjJmiZar9irEL3z6 rsIg== X-Gm-Message-State: AJcUukeTFWr8i4oescZIu2O4Cc/Jmzfy6qyMJ7+UdJwhAMUHwVNW7IYX gi2iaSV5kdudtO/jMF3C/RTAsg== X-Received: by 2002:a17:902:43e4:: with SMTP id j91mr38327898pld.147.1546312416225; Mon, 31 Dec 2018 19:13:36 -0800 (PST) Received: from [192.168.1.77] (c.208.53.119.160.static.broadstripe.net. [208.53.119.160]) by smtp.gmail.com with ESMTPSA id y71sm88127361pfi.123.2018.12.31.19.13.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Dec 2018 19:13:35 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: [PATCH] tty/n_hdlc: fix sleep in !TASK_RUNNING state warning From: Paul Fulghum In-Reply-To: <49b3b189-a51f-6a97-0e1f-bc3f2c305299@I-love.SAKURA.ne.jp> Date: Mon, 31 Dec 2018 19:13:34 -0800 Cc: Arnd Bergmann , Alan Cox , syzbot , gregkh@linuxfoundation.org, jslaby@suse.com, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Message-Id: <62FAC6A3-AC41-44CD-8ABC-79F404BF8CB1@microgate.com> References: <000000000000449587057e1e6f8b@google.com> <49b3b189-a51f-6a97-0e1f-bc3f2c305299@I-love.SAKURA.ne.jp> To: Tetsuo Handa X-Mailer: Apple Mail (2.3445.102.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Dec 31, 2018, at 7:11 PM, Paul Fulghum wrote: NAK to this patch. It causes lost wakeups in both read and write paths. The write path does not need changing. The read path can be fixed by setting current to TASK_RUNNING at the top = of the if (rbuf) block so the warning is not triggered by = copy_to_user(). If this block runs the condition is satisfied and it = breaks out of the polling loop where it is already being set to = TASK_RUNNING and removed from the wait queue. This particular path just = needs to account for the copy_to_user which occurs before breaking out. I=E2=80=99ll make a patch to do this when I have the ability to test it = in a day or two. > On Dec 29, 2018, at 3:48 AM, Tetsuo Handa = wrote: >=20 > syzbot is hitting __might_sleep() warning [1], for commit = 1035b63d3c6fc34a > ("n_hdlc: fix read and write locking") changed to set = TASK_INTERRUPTIBLE > state before calling copy_to_user(). Let's set TASK_INTERRUPTIBLE = state > immediately before calling schedule(). >=20 > [1] = https://syzkaller.appspot.com/bug?id=3D17d5de7f1fcab794cb8c40032f893f52de8= 99324 >=20 > Signed-off-by: Tetsuo Handa > Reported-by: syzbot = > Cc: Paul Fulghum > Cc: Arnd Bergmann > Cc: Alan Cox > --- > drivers/tty/n_hdlc.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c > index dabb391..7835489 100644 > --- a/drivers/tty/n_hdlc.c > +++ b/drivers/tty/n_hdlc.c > @@ -589,8 +589,6 @@ static ssize_t n_hdlc_tty_read(struct tty_struct = *tty, struct file *file, > if (tty_hung_up_p(file)) > break; >=20 > - set_current_state(TASK_INTERRUPTIBLE); > - > rbuf =3D n_hdlc_buf_get(&n_hdlc->rx_buf_list); > if (rbuf) { > if (rbuf->count > nr) { > @@ -617,6 +615,7 @@ static ssize_t n_hdlc_tty_read(struct tty_struct = *tty, struct file *file, > break; > } >=20 > + set_current_state(TASK_INTERRUPTIBLE); > schedule(); >=20 > if (signal_pending(current)) { > @@ -673,8 +672,6 @@ static ssize_t n_hdlc_tty_write(struct tty_struct = *tty, struct file *file, > add_wait_queue(&tty->write_wait, &wait); >=20 > for (;;) { > - set_current_state(TASK_INTERRUPTIBLE); > -=09 > tbuf =3D n_hdlc_buf_get(&n_hdlc->tx_free_buf_list); > if (tbuf) > break; > @@ -683,6 +680,8 @@ static ssize_t n_hdlc_tty_write(struct tty_struct = *tty, struct file *file, > error =3D -EAGAIN; > break; > } > + > + set_current_state(TASK_INTERRUPTIBLE); > schedule(); > =09 > n_hdlc =3D tty2n_hdlc (tty); > --=20 > 1.8.3.1 >=20 >=20 -- Paul Fulghum MicroGate Systems, Ltd. =3DCustomer Driven, by Design=3D (512) 345-7791 x102 (Voice) (512) 343-9046 (Fax) Central Time Zone (GMT -5h) www.microgate.com