Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp506633ybi; Fri, 24 May 2019 07:14:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMwTU2xap/kCmbesHC/ExtFtLurM9fhQ4kE4i6H8QiFyzxBQ2B+gS9B+GsIzYTqLk/HyUn X-Received: by 2002:a63:d345:: with SMTP id u5mr100450028pgi.83.1558707264368; Fri, 24 May 2019 07:14:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558707264; cv=none; d=google.com; s=arc-20160816; b=AjgSJUIROx/y6fZz9m8JJYkAcBCm+sgIn0EKidrS7eQmmn0kzc9PwxqWTryFe104RD PAMOz2Cdr9DylRFu4VcfKXosgnaBJn7bM04u/MjsZ0GUyfjTijOWCye/IwSEv9yzjV51 Ku0oe36/6oR42xfST90SrCx1TSAYi/agGhO5OIeS3RUjzPgn8bJD550V/vGNRHAh8d1V ERoHCe9eU36IXNiY2/EETos6RvHrv/xnz2j7NdLJelwQyzmDPB6yWA5iZOEaOxcEnjKo jp3CeodP5B6Qo/+inFG02IG2ZG7S6qsUQbTLiE/lmmtCaRKvJhW09wXfD+51FUL282l1 YK2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=kjqprFyamTUGMNByKWVLgMI7TjNUKFvcRsJYMOuyNPY=; b=HiTATGOLSmH2aS8K0Xy9FaLR3J/16rFAHeRjXTt3qsK5/t7Nfdn001Vp0NxFQ8WN5T 9B6JvyyM/eTu994p9GCNGyBZSmy2SIbHiqdWSmsm1wZ2eiFWiWZJyxXOWGoDERwN+LDM 042hcyU9/gSLTv9u4auevmtbv3ZJEanmrHd8GewNur4UQygcHpTqs0bbzw2M99sY97j+ IlOW7NSOmsdSc9rL+1jJ/NZ+2VCqM476pB9+ZFgL5iJVU2y584oa80Z05S9U5KornqYX oCkDi3HskT9+xT3ZXcZCua+2lypT/R9TZypRrBnsIVXqnr805sLBSLNk+2z4O56Na488 Vx0w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si4094592plk.229.2019.05.24.07.14.08; Fri, 24 May 2019 07:14:24 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404055AbfEXOLB (ORCPT + 99 others); Fri, 24 May 2019 10:11:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43162 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403895AbfEXOLB (ORCPT ); Fri, 24 May 2019 10:11:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96E3281126; Fri, 24 May 2019 14:11:00 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.159]) by smtp.corp.redhat.com (Postfix) with SMTP id 8E55B1835C; Fri, 24 May 2019 14:10:55 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 24 May 2019 16:11:00 +0200 (CEST) Date: Fri, 24 May 2019 16:10:54 +0200 From: Oleg Nesterov To: Deepa Dinamani Cc: David Laight , Linux Kernel Mailing List , Andrew Morton , Alexander Viro , Arnd Bergmann , "dbueso@suse.de" , "axboe@kernel.dk" , Davidlohr Bueso , Eric Wong , Jason Baron , Linux FS-devel Mailing List , linux-aio , Omar Kilani , Thomas Gleixner , "stable@vger.kernel.org" Subject: Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask() Message-ID: <20190524141054.GB2655@redhat.com> References: <20190522150505.GA4915@redhat.com> <20190522161407.GB4915@redhat.com> <4f7b6dbeab1d424baaebd7a5df116349@AcuMS.aculab.com> <20190523145944.GB23070@redhat.com> <345cfba5edde470f9a68d913f44fa342@AcuMS.aculab.com> <20190523163604.GE23070@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 24 May 2019 14:11:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/23, Deepa Dinamani wrote: > > Ok, since there has been quite a bit of argument here, I will > backtrack a little bit and maybe it will help us understand what's > happening here. > There are many scenarios being discussed on this thread: > a. State of code before 854a6ed56839a I think everything was correct, > b. State after 854a6ed56839a obviously buggy, > c. Proposed fix as per the patchset in question. Nack, sorry. I'll try to finish my patch on Monday. It will restore the state before 854a6ed56839a and (imo) cleanup/simplify this code. At leat this is what I think right now. May be I will have to change my mind after this discussion. But in any case I can't believe I will ever agree with your fix ;) > These are particularly meant for a scenario(d) such as below: > > 1. block the signals you don't care about. > 2. syscall() > 3. unblock the signals blocked in 1. > > The problem here is that if there is a signal that is not blocked by 1 > and such a signal is delivered between 1 and 2(since they are not > atomic), the syscall in 2 might block forever as it never found out > about the signal. and that is why we have pselect/etc to make this sequence "atomic". > As per [a] and let's consider the case of epoll_pwait only first for simplicity. > > As I said before, ep_poll() is what checks for signal_pending() and is > responsible for setting errno to -EINTR when there is a signal. To clarify, if do_epoll_wait() return -EINTR then signal_pending() is true, right? > So if a signal is received after ep_poll() and ep_poll() returns > success, it is never noticed by the syscall during execution. What you are saying looks very confusing to me, I will assume that you meant something like - a signal SIG_XXX was blocked before sys_epoll_pwait() was called - sys_epoll_pwait(sigmask) unblocks SIG_XXX according to sigmask - sys_epoll_pwait() calls do_epoll_wait() which returns success - SIG_XXX comes after that and it is "never noticed" Yes. Everything is correct. And see my reply to David, SIG_XXX can even come _before_ sys_epoll_pwait() was called. > So the question is does the userspace have to know about this signal > or not. If userspace needs to know about SIG_XXX it should not block it, that is all. > What [b] does is to move the signal check closer to the restoration of > the signal. FOR NO REASON, afaics (to simplify, lets forget the problem with the wrong return value you are trying to fix). And even if there were ANY reason to do this, note that (with or without this fix) the signal_pending() check inside restore_user_sigmask() can NOT help, simply because SIG_XXX can come right after this check. Oleg.