From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C04EC43381 for ; Wed, 6 Mar 2019 19:45:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0139E206DD for ; Wed, 6 Mar 2019 19:45:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729502AbfCFTpB (ORCPT ); Wed, 6 Mar 2019 14:45:01 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:36808 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726143AbfCFTpB (ORCPT ); Wed, 6 Mar 2019 14:45:01 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1h1cTH-0001eY-Up; Wed, 06 Mar 2019 19:44:55 +0000 Date: Wed, 6 Mar 2019 19:44:55 +0000 From: Al Viro To: zhengbin Cc: bcrl@kvack.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, houtao1@huawei.com, yi.zhang@huawei.com Subject: Re: [PATCH] fix syzkaller task hung in exit_aio Message-ID: <20190306194455.GV2217@ZenIV.linux.org.uk> References: <1551880403-132638-1-git-send-email-zhengbin13@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1551880403-132638-1-git-send-email-zhengbin13@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Mar 06, 2019 at 09:53:23PM +0800, zhengbin wrote: > CPU 0 CPU 1 > aio_poll-->vfs_poll > eventfd_write-->spin_lock_irq(lock) > -->..-->aio_poll_wake > -->spin_unlock_irq(lock) > -->spin_lock(lock) > -->if (req->woken) > mask = 0; --->did not call aio_poll_complete > -->iocb_put > > aio_poll_wake > req->woken = true; > if (mask) { > if (!(mask & req->events)) > return 0; --->did not call aio_poll_complete too ... and it's still on waitqueue, so it shouldn't be different from _not_ having had a wakeup yet. And yes, aio_poll() in mainline right now ends up _not_ adding it to "can be cancelled" list, leading to that bug. > vfs_poll-->eventfd_poll-->poll_wait-->aio_poll_queue_proc(add > aio_poll_wake to req->head) > > eventfd_write-->wake_up_locked_poll-->__wake_up_common-->curr->func > -->aio_poll_wake > > This patch fixes that. by the way, fix the bug of the error handling path. Leak on error is real (see thread a few days ago), and overall logics for "woken" should be similar to what you suggest, but I'd rather handle it slightly differently (see the same thread). I've a patch that ought to fix that and it seems to survive testing; I'll post once I finish carving it up - too many cleanups mixed into it. Give me a couple of hours; should be done (and posted) by then.