Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8878358imu; Sat, 29 Dec 2018 05:46:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/VfS8Nriuohhv+3okBtnQ6WAXXyuGtFYA0bB+LXgs8qT/dEHxrUQ0rdBxuOUqJMd6XrZvk/ X-Received: by 2002:a62:848d:: with SMTP id k135mr31467896pfd.47.1546091182646; Sat, 29 Dec 2018 05:46:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546091182; cv=none; d=google.com; s=arc-20160816; b=rc3/QHb/A00Ygi3F/M85pzBeADyYjG60C4Py96Sd4ulBgrJhVeUpGF+DcJq6FAAV2l WwxcX3aO9tqrTUuEkP3PnPbOw69KLO1aaKashTxXZUqD3Pqzl7Y+RJ7jPmWTx9Auymp7 +bNMc/t1Pyo+2jcdRN4z1JQpKxC1Bbh28SNlMBo8LS654PX8piIhz+pYPrMFLV8DGQxe FOHHaenlNyzYluRzlijYasp0LhqPuV+Zxy6iGxiVspxGo4hsBr4olgpCxY3h/Oe0fERU Cg3soZ69b3MosNjsHt52lnDWk5Ywhsu6ZIixcwKlyQV8NVqiCnDhI8qX7ObEraHW99xv 0kvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:cc:references:to:subject; bh=ZlDrgQEsuA2meByTJwvKYfEEZ2lYh2QZkrYsOMv6/CA=; b=1Ba6ZVWF8Jz9WXCOD6l4mjQJ+NcCq/tcz8f0eGh3GqC37d9S/D4LJ8gqIC+4/T1Fye uf04P1FIF4J8VqRCCrwbCTE99Vnq4X8kg7KqJQldyUMYjb9GiWwMeCggOqUxeH8uKd1N 3gXpBetfq+5SgsQ+cakT3W69rQHYxBM7PNOMlp+5bgNGTYAWRrzzlDF5aamgJMnXQmLt HidOi6ZzALkUtYI51zX7t86j9vUwwfEsVDz+3BmYYsbDCqNUxjAinFWJ2BRcc9Fa1rKO et35HYipAlipkQsX7H/t5OL0Vyg0UX0nL3VU7C2Jxjf2A8YBfWnnEh8S5jAbt/OtRXUh nT+g== ARC-Authentication-Results: i=1; mx.google.com; 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 w1si40186409pgi.66.2018.12.29.05.46.05; Sat, 29 Dec 2018 05:46:22 -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; 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 S1727794AbeL2Lsv (ORCPT + 99 others); Sat, 29 Dec 2018 06:48:51 -0500 Received: from www262.sakura.ne.jp ([202.181.97.72]:56855 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726074AbeL2Lsv (ORCPT ); Sat, 29 Dec 2018 06:48:51 -0500 Received: from fsav109.sakura.ne.jp (fsav109.sakura.ne.jp [27.133.134.236]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id wBTBmnVf002411; Sat, 29 Dec 2018 20:48:49 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav109.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav109.sakura.ne.jp); Sat, 29 Dec 2018 20:48:49 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav109.sakura.ne.jp) Received: from [192.168.1.8] (softbank126126163036.bbtec.net [126.126.163.36]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id wBTBmgQU002368 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NO); Sat, 29 Dec 2018 20:48:48 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Subject: [PATCH] tty/n_hdlc: fix sleep in !TASK_RUNNING state warning To: Paul Fulghum , Arnd Bergmann , Alan Cox References: <000000000000449587057e1e6f8b@google.com> Cc: syzbot , gregkh@linuxfoundation.org, jslaby@suse.com, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com From: Tetsuo Handa Message-ID: <49b3b189-a51f-6a97-0e1f-bc3f2c305299@I-love.SAKURA.ne.jp> Date: Sat, 29 Dec 2018 20:48:42 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: <000000000000449587057e1e6f8b@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). [1] https://syzkaller.appspot.com/bug?id=17d5de7f1fcab794cb8c40032f893f52de899324 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(-) 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; - set_current_state(TASK_INTERRUPTIBLE); - rbuf = 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; } + set_current_state(TASK_INTERRUPTIBLE); schedule(); 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); for (;;) { - set_current_state(TASK_INTERRUPTIBLE); - tbuf = 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 = -EAGAIN; break; } + + set_current_state(TASK_INTERRUPTIBLE); schedule(); n_hdlc = tty2n_hdlc (tty); -- 1.8.3.1