Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp620842ybi; Fri, 24 May 2019 08:47:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyneW0H/072a3ndotoMNM9Dh9ZL1STo9izOll8CxhTguinwXQVxAIORi2B/Tr18fngj0gBk X-Received: by 2002:a17:90a:af8a:: with SMTP id w10mr10516338pjq.132.1558712832858; Fri, 24 May 2019 08:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558712832; cv=none; d=google.com; s=arc-20160816; b=E9mq3p4a/JRZFR7MO7aEHaT2Sisc7GLTi7kT6DaM/DkRqt2/ZGgip8hFHDdzYut97o txVqWNufEmCFDOWwASHFjd42MPWHs+UTw5gDO0AHLH9rikrpoDrymHNv8XvgFV0T/D9w l4w18sS8rIwerSFD2hk+/BE2AC+2sZJGJmNXWpkzN0uxgftIBP580HpeQlF2J42Nc7xq FPrC2gJ7K0b8eBvWA+DF39yyMoMLvn5VUiAzbYGg+KcYGX4MGunHonR98V1EPGRLmcdL N4cvwJCEMBEbCEUYwr4IkswoNLGxrLfbFw0C82JsEv93MbrAkSMsmb7T/H0wvKh0RVKW Gisg== 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=GBqDvJWIJDVgOKZJb45yGw/e3TDy2hp+YthUjQolS5Q=; b=tgW98mTBPkl3Q1J0gYSNWUuNjYWwVbunlLQxo5XZHGZg7lRyfSapOA/o4dbNCMvSTw 9iZDMIEUaPmT6NjS4f1yXZck2lX5LeW/t9qhi+alz756hYvN9prT9O2rvALiih9qYc1T Y0mnZhdrS1bWaBd3yrWNevfAQBqyx6Ka6ekbUrNij7yn9G42sop1K/97RaVwo5dmZd5O 3HxzQARuaial4FNFIatZ/Gk5Y/VK+JypJ8nH3Aoh8QsMRMktxjwnnA6htmYSdasrbJgi sOAqk9zYpu10dPy6XG1IdkZSQlIiz6VWwbBuC6vZP3QTCIIJXsoJpv9ayjPy1CROlaNY Ytdw== 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 f34si4746172ple.322.2019.05.24.08.46.56; Fri, 24 May 2019 08:47:12 -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 S2390021AbfEXPoj (ORCPT + 99 others); Fri, 24 May 2019 11:44:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36768 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389206AbfEXPoj (ORCPT ); Fri, 24 May 2019 11:44:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95F5DC09AD13; Fri, 24 May 2019 15:44:33 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.159]) by smtp.corp.redhat.com (Postfix) with SMTP id 4A11C63F62; Fri, 24 May 2019 15:44:26 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 24 May 2019 17:44:33 +0200 (CEST) Date: Fri, 24 May 2019 17:44:25 +0200 From: Oleg Nesterov To: David Laight Cc: 'Deepa Dinamani' , 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: <20190524154425.GE2655@redhat.com> References: <20190522161407.GB4915@redhat.com> <4f7b6dbeab1d424baaebd7a5df116349@AcuMS.aculab.com> <20190523145944.GB23070@redhat.com> <345cfba5edde470f9a68d913f44fa342@AcuMS.aculab.com> <20190523163604.GE23070@redhat.com> <20190524132911.GA2655@redhat.com> <766510cbbec640b18fd99f3946b37475@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <766510cbbec640b18fd99f3946b37475@AcuMS.aculab.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 24 May 2019 15:44:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/24, David Laight wrote: > > From: Oleg Nesterov > > Sent: 24 May 2019 14:29 > > It seems that we all are just trying to confuse each other. I got lost. > > I'm always lost :-) same here ;) > To my mind changing the signal mask should be enough to get a masked > signal handler called - even if the mask is reset before the syscall exits. well, the kernel doesn't do this, and on purpose. > There shouldn't be any need for an interruptible wait to be interrupted. can't parse ;) > I suspect that if you send a signal to a process that is looping > in userspace (on a different) the signal handler is called on the next > exit to userspace regardless as to whether the kernel blocks. > > epoll and pselect shouldn't be any different. They differ exactly because they manipulate the blocked mask, > Having the signal unmasked at any time should be enough to get it called. No. The sigmask passed to pselect() tells the kernel which signals should interrupt the syscall if it blocks. The fact that pselect() actually unblocks a signal is just the internal implementation detail. > > > I suspect you need to defer the re-instatement of the original mask > > > to the code that calls the signal handlers (which probably should > > > be called with the programs signal mask). > > > > This is what the kernel does when the signal is delivered, the original mask > > is restored after the signal handler runs. > > I'd have thought that the original signal mask (all blocked in the examples) > should be restored before the signal handler is called. No. And this means that if you have 2 pending signals, they both will be delivered. Unless of course sigaction->sa_mask includes the 2nd one. > After all the signal handler is allowed to modify the processes signal mask. only untill the handler returns. > I've had horrid thoughts about SIG_SUSPEND :-) google knows nothing about SIG_SUSPEND, neither me ;) Oleg.