Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4530074imb; Wed, 6 Mar 2019 16:05:17 -0800 (PST) X-Google-Smtp-Source: APXvYqyt2DcmtgPfUEaAY6Kk+7A2WS9r7qOKlX2s2BAqQF1y0lOGYA16cAciZ8KJFnMzvZQAeORr X-Received: by 2002:a17:902:7203:: with SMTP id ba3mr5629459plb.168.1551917117628; Wed, 06 Mar 2019 16:05:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551917117; cv=none; d=google.com; s=arc-20160816; b=eZeuSe7mx9nc5b12JK0mBM/N17TFzGkoiDH83HWDKGWUxCEmtpfbGDo9kq0vJvLed8 VxEG9O9vnFwesfxn0bYpLKMP1bFn4mYZdGpg3TOU87aY32jxeksHN2ZW0vdlZZ/42kPx XPTyrY3WOnsdpQfsRSatYLSgO9dN6VQcaSL8amVhxb6yJSBG5HTQsJSfGemjWMAdjkU/ m/oRfEDn7Z2nGVO1OnTZvRkwCSlq7zpS7AR2RzW8pPdpDqgJoDPx4MnK7a8hEiOtzK6o lQJgksug4w5OwuSA2jVxmpT1dpcbtBkdNVXT45vpFthq4QEXu76O2/cc2Cf01tL1t9UT ybTQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uJl33Jada2gTLMomWTG3NZxaqqUEqA0zq3XlNtX9uyc=; b=qhG76LlzsNqlD2i2MEVFFqLuodLrwcCl3Zxk3MP17Xa2JLgp0gxO2SJE8mnq35HX3g fKICsMN5uib+9N+kv3DiG1kRFAnktLAOWqs00u7n6ZEHttjtJycuDQRSL3w7sVAkZ8Gd fJQCSam2AOrdYdlsUv5nu902Kh59UbDMQtuekwFCPfoXtMlWRjAB0uKq5JEoF597Nnnn A54FzEo8BWzuyY1wQL4sjsyTIN5tzOzSNQbDitIPRH4X9SbPdyqgi0Oa6ZYNx9pjVf7Z nuLn6iDo3RbX9A/ik8LMh45CQ8BnjfJCftPakVnqBFdOw0SRZPEUcxCWTazHz4RraqK/ rcJw== 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 x1si2673933plb.245.2019.03.06.16.05.02; Wed, 06 Mar 2019 16:05:17 -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 S1726484AbfCGAEX (ORCPT + 99 others); Wed, 6 Mar 2019 19:04:23 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:39966 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbfCGAD3 (ORCPT ); Wed, 6 Mar 2019 19:03:29 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1h1gVJ-00086o-4P; Thu, 07 Mar 2019 00:03:17 +0000 From: Al Viro To: Linus Torvalds Cc: Eric Dumazet , David Miller , Jason Baron , kgraul@linux.ibm.com, ktkhai@virtuozzo.com, kyeongdon.kim@lge.com, Linux List Kernel Mailing , Netdev , pabeni@redhat.com, syzkaller-bugs@googlegroups.com, xiyou.wangcong@gmail.com, Christoph Hellwig , zhengbin , bcrl@kvack.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, houtao1@huawei.com, yi.zhang@huawei.com Subject: [PATCH 2/8] aio_poll_wake(): don't set ->woken if we ignore the wakeup Date: Thu, 7 Mar 2019 00:03:10 +0000 Message-Id: <20190307000316.31133-2-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190307000316.31133-1-viro@ZenIV.linux.org.uk> References: <20190307000316.31133-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro In case of early wakeups, aio_poll() assumes that aio_poll_complete() has either already happened or is imminent. In that case we do not want to put iocb on the list of cancellables. However, ignored wakeups need to be treated as if wakeup has not happened at all. Trivially fixed by having aio_poll_wake() set ->woken only after it's committed to taking iocb out of the waitqueue. Spotted-by: zhengbin Signed-off-by: Al Viro --- fs/aio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index ea30b78187ed..3a8b894378e0 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1668,13 +1668,13 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, __poll_t mask = key_to_poll(key); unsigned long flags; + /* for instances that support it check for an event match first: */ + if (mask && !(mask & req->events)) + return 0; + req->woken = true; - /* for instances that support it check for an event match first: */ if (mask) { - if (!(mask & req->events)) - return 0; - /* * Try to complete the iocb inline if we can. Use * irqsave/irqrestore because not all filesystems (e.g. fuse) -- 2.11.0