Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5755364ybi; Tue, 4 Jun 2019 11:36:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrpDIxSFtMV3jRHGToQfGX91HxC4oXSmEzwSTgbxFWM9me4PKeMac6W0iCiewfFHsHBRMU X-Received: by 2002:a62:5e42:: with SMTP id s63mr38991048pfb.78.1559673405573; Tue, 04 Jun 2019 11:36:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559673405; cv=none; d=google.com; s=arc-20160816; b=MYbFAfX6NrxU0YsqrKyTiwHTkykE7HUJY2v2hj1jkK7W58+7g0nd34xPazVpLWaNRb Qtuy87QOPwu6NCCF9mtv8AbM2mLIHsqAP94gP9OU9zbKdKb+rCPUAgLcvBIahU8dhckC 1TQQpHLcV0/bRTY4623tEM8vppKfheQ2H7X7wC5sHB+px0rxW+N/f5zm12BEJ0mF/bXo yWqfEjOilUlQY5UoQB9eQVtIkekiTGefELEgvcxwUaRaLvNeJqRF5fw5zzOfRB06FIUJ gGgWKJSb0KvPSocxK1+qvFKhYfqpBUque4b1iNssp+pcfgWzeEL+0L1Fz8p/iomgB+3l c8ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=kXf/ST4WO645Lbz7iK+baWXu1f5FHN1W2aDMc1Xs2JE=; b=K5HtzyGwg/A3ZOlQyGk8YykQu7ELNfSSC35U4Y6YbKOUN8/Rnwu4qUdMutylOwjT/j vxfaykg5X7nOcex78qgiInPWZfZgzcdyvXC/G+1DZ9eu+xST7RzMc+NKHCb7RNt0FmZh YZV8sVwx+1996Gb6TZCq3sZNSL2a3IKRQ4w33rjTVgRoWrEumWEfLA3kE5MrRzoLL56q C7OWT7IsapGh1w9jUAcJSuQG8QIF1HICDd0OEg/hj4ilvipveQ7dCFz+y+eC5ep9fyRU Ey8H89xH0NWmGEYIVm6UMXWb2ekxs1hN+U8onXAgLkkM79f9rAA89B/POdW5bWKUpZLE bvUQ== 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 w13si23258812plp.271.2019.06.04.11.36.29; Tue, 04 Jun 2019 11:36:45 -0700 (PDT) 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 S1726555AbfFDSfY (ORCPT + 99 others); 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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).