Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp239944pxf; Wed, 10 Mar 2021 05:25:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYdyDBVpwgjUEVkDJhmUz4C4HL4wMg/e47ZHZX9R5g5Lb4h0/F2iXAxlPK/8zsSN7n7bxi X-Received: by 2002:aa7:da0f:: with SMTP id r15mr3230677eds.111.1615382747143; Wed, 10 Mar 2021 05:25:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615382747; cv=none; d=google.com; s=arc-20160816; b=m4i0S71tLW0usI2XeuG/gR5eNRmVZPqvWxpz076qYWxa0KFnJQb1AXxxv+SGY59gH2 AdEkcpIkfX7fscv9utihKp51EbNWp+Shas67TgisTQjIz+0o2TRtOzHW8lYy90N90Hbx s/9FN/z9WpwIUHZCm3N1hwOdQwVbti032r2YOc2FmxIJ+7328W77/4CeElvNuoFBox5I 0Q9t9N7/yHdFHEg8IKgeUF80sewmJ+wFSX+YQuNE8iDFh8FkYQ0aqBByypdTGiYwqj29 JIi93L4+5jCedJayWk6CmSQDFzlQKKYzRvUdVVY8Vk2ErKi1k+cHq2mbnsDnjh9GzC8M kJ6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bUIKiMzMSJWkl75LOt6B0oMARwoDh3Ufi9jUvoRKMGk=; b=AZMKqAyMsgH58D5qXQeyxuzRTtWQCnunBmqKI6Yzu3twfX7o2fa6CLX5eQdM66wO0O PnQHxpZIvwex2ICGrwK7bU8YPfhzuDRmcqNooHoRlQ2A705X23wlXgXHITH/yJNXqu4N rczjyMYllD5McWY7N2fbS2uhvFqO2e3Ltfs3DAV9xO8sStlfLXVElFb5A+oL1oF/usAO C45tj44GMWfzv3tMg/Wy6awSLP46zp6DaPhH5p+hqThwyYccLFeO15q0dmtpgFKXea7h oI1zJPyV+LZfcj5l4RBNhn7AW6wvF9gDdoF03EiOMKzto5ZPfCfczy6nTjRzDOyFpuW3 gdTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CDo+bjXG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si11498624ejd.310.2021.03.10.05.25.24; Wed, 10 Mar 2021 05:25:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CDo+bjXG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232761AbhCJNYJ (ORCPT + 99 others); Wed, 10 Mar 2021 08:24:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:45286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231907AbhCJNYD (ORCPT ); Wed, 10 Mar 2021 08:24:03 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7719964FDA; Wed, 10 Mar 2021 13:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382642; bh=8PnZjmJnJ8XwYFe3tQsXEMTsIshZbzpo2C7X8CHBVBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CDo+bjXG+AXnBr496lCCyKhQyU4Ug3dgzev9LIiAOJL/nkSd+VO8JkSzQn38nHW8E IyRE0DU8JU9I2IqwqvEeGyw2GWUmLv4A4nnMvI5PQBKFZ57bQqfSbDDlPZvMuV+gzK ASgdQ68WmrQFi120HfJPiwM+BrNmJG5PDct17494= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , syzbot+695b03d82fa8e4901b06@syzkaller.appspotmail.com, Pavel Begunkov , Jens Axboe Subject: [PATCH 5.11 04/36] io_uring: unpark SQPOLL thread for cancelation Date: Wed, 10 Mar 2021 14:23:17 +0100 Message-Id: <20210310132320.660441161@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132320.510840709@linuxfoundation.org> References: <20210310132320.510840709@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Pavel Begunkov commit 34343786ecc5ff493ca4d1f873b4386759ba52ee upstream We park SQPOLL task before going into io_uring_cancel_files(), so the task won't run task_works including those that might be important for the cancellation passes. In this case it's io_poll_remove_one(), which frees requests via io_put_req_deferred(). Unpark it for while waiting, it's ok as we disable submissions beforehand, so no new requests will be generated. INFO: task syz-executor893:8493 blocked for more than 143 seconds. Call Trace: context_switch kernel/sched/core.c:4327 [inline] __schedule+0x90c/0x21a0 kernel/sched/core.c:5078 schedule+0xcf/0x270 kernel/sched/core.c:5157 io_uring_cancel_files fs/io_uring.c:8912 [inline] io_uring_cancel_task_requests+0xe70/0x11a0 fs/io_uring.c:8979 __io_uring_files_cancel+0x110/0x1b0 fs/io_uring.c:9067 io_uring_files_cancel include/linux/io_uring.h:51 [inline] do_exit+0x2fe/0x2ae0 kernel/exit.c:780 do_group_exit+0x125/0x310 kernel/exit.c:922 __do_sys_exit_group kernel/exit.c:933 [inline] __se_sys_exit_group kernel/exit.c:931 [inline] __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:931 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Cc: stable@vger.kernel.org # 5.5+ Reported-by: syzbot+695b03d82fa8e4901b06@syzkaller.appspotmail.com Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -8955,11 +8955,16 @@ static void io_uring_cancel_files(struct break; io_uring_try_cancel_requests(ctx, task, files); + + if (ctx->sq_data) + io_sq_thread_unpark(ctx->sq_data); prepare_to_wait(&task->io_uring->wait, &wait, TASK_UNINTERRUPTIBLE); if (inflight == io_uring_count_inflight(ctx, task, files)) schedule(); finish_wait(&task->io_uring->wait, &wait); + if (ctx->sq_data) + io_sq_thread_park(ctx->sq_data); } }