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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable 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 E5C28C282CE for ; Tue, 4 Jun 2019 18:35:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6FEA208C3 for ; Tue, 4 Jun 2019 18:35:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726261AbfFDSfY (ORCPT ); Tue, 4 Jun 2019 14:35:24 -0400 Received: from dcvr.yhbt.net ([64.71.152.64]:59492 "EHLO dcvr.yhbt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726510AbfFDSfX (ORCPT ); Tue, 4 Jun 2019 14:35:23 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 4A3DF1F462; Tue, 4 Jun 2019 18:35:23 +0000 (UTC) Date: Tue, 4 Jun 2019 18:35:23 +0000 From: Eric Wong To: Oleg Nesterov Cc: Andrew Morton , Deepa Dinamani , linux-kernel@vger.kernel.org, arnd@arndb.de, dbueso@suse.de, axboe@kernel.dk, dave@stgolabs.net, jbaron@akamai.com, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, omar.kilani@gmail.com, tglx@linutronix.de, stable@vger.kernel.org, Al Viro , "Eric W. Biederman" , Linus Torvalds , David Laight Subject: Re: [PATCH] signal: remove the wrong signal_pending() check in restore_user_sigmask() Message-ID: <20190604183523.kkruvskcgbli2fpu@dcvr> References: <20190522032144.10995-1-deepa.kernel@gmail.com> <20190529161157.GA27659@redhat.com> <20190604134117.GA29963@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190604134117.GA29963@redhat.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Oleg Nesterov wrote: > This is the minimal fix for stable, I'll send cleanups later. > > The commit 854a6ed56839a40f6b5d02a2962f48841482eec4 ("signal: Add > restore_user_sigmask()") introduced the visible change which breaks > user-space: a signal temporary unblocked by set_user_sigmask() can > be delivered even if the caller returns success or timeout. > > Change restore_user_sigmask() to accept the additional "interrupted" > argument which should be used instead of signal_pending() check, and > update the callers. > > Reported-by: Eric Wong > Fixes: 854a6ed56839a40f6b5d02a2962f48841482eec4 ("signal: Add restore_user_sigmask()") > cc: stable@vger.kernel.org (v5.0+) > Signed-off-by: Oleg Nesterov Thanks, for epoll_pwait on top of Linux v5.1.7 and cmogstored v1.7.0: Tested-by: Eric Wong (cmogstored v1.7.1 already works around this when it sees a 0 return value (but not >0, yet...)) > diff --git a/fs/io_uring.c b/fs/io_uring.c > index 0fbb486..1147c5d 100644 > --- a/fs/io_uring.c > +++ b/fs/io_uring.c > @@ -2201,11 +2201,12 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, > } > > ret = wait_event_interruptible(ctx->wait, io_cqring_events(ring) >= min_events); > - if (ret == -ERESTARTSYS) > - ret = -EINTR; > > if (sig) > - restore_user_sigmask(sig, &sigsaved); > + restore_user_sigmask(sig, &sigsaved, ret == -ERESTARTSYS); > + > + if (ret == -ERESTARTSYS) > + ret = -EINTR; > > return READ_ONCE(ring->r.head) == READ_ONCE(ring->r.tail) ? ret : 0; > } That io_uring bit didn't apply cleanly to stable, since stable is missing fdb288a679cdf6a71f3c1ae6f348ba4dae742681 ("io_uring: use wait_event_interruptible for cq_wait conditional wait") and related commits. In any case, I'm not using io_uring anywhere, yet (and probably won't, since I'll still need threads to deal with open/unlink/rename on slow JBOD HDDs).