Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1972112ybm; Thu, 23 May 2019 09:21:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeeXR32y8+Gr3vBvcb80g1A4oL8YlIOJXHEa/W1s0rmiZ7bK+jjNtnbFOLkaIkc2dJWwea X-Received: by 2002:a17:90a:808a:: with SMTP id c10mr2326751pjn.67.1558628478405; Thu, 23 May 2019 09:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558628478; cv=none; d=google.com; s=arc-20160816; b=tvKrwziN77bOkfrWT2/wOfhuwiMI3Q/ESc35FurB1p4e7EkC09ODXnlhwprnHBPXzf 19hBDxh6rKLyW8cCk62dC6MDQPLw+movxBKHj0/+yODBieZ+J3tz2+WGzzVg6ttoKtH+ +s60oWlAtc557OZiTzOfoFzKX4MdwIJTIjaWJCfmMmGzqPe86I4pbeCqSD6Tgr3Ea1Rc QfQtQ5o0i4trKqRSIVY6GIKHK4ltI3ikS1W9Pr88FYGYw+n5Hsnw4yhAhTquvJTmLKaj S0nT4r6NCB5Ol+xzqvK3x56JJ30LCu23CyPf4BX/9p3HJSciLk8m4v5mBAUG3bJqeqEd M7PA== 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 :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=wJrU9mR3ePuZ6Ae3onxpET3oHhDtWYYNg6RQiU78kjc=; b=AtkpaXEopvV7yyDVf3IGK4BB/QspHtQlsrEOFoWLhZ35s0OKZSQIeywx6xLh8cLAyY QRqO0640GxBEyQAlPtYkbrql2ObmC9NdgSfbB3nAxc+Yz0autlKewKQ7qYSsBuOAiKsi 6v3Stz5wUmm57xjNoD6NHHDBkWhK98zMazGRy+3DS8tuqlnc+IOksqUuWKm5dv8UPoZl ijQjg6+9bCnMRL6LRqEku+5mshgHZIDm4a4+D+Ud+vQADaLwN7SN0XgYHRsz7EOiRgPF kRAWkwGYY2tHELy5afOxSpRKJVA00mUvNAzyDQn7wosubvbwQ1byj75+Yb2HWwCBRL8E vE9Q== 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 n19si30815928pgc.113.2019.05.23.09.21.01; Thu, 23 May 2019 09:21:18 -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 S1731622AbfEWQS4 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 23 May 2019 12:18:56 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:23088 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731107AbfEWQS4 (ORCPT ); Thu, 23 May 2019 12:18:56 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-206-NxgE-QeqMLGOVa7vAw4lcw-1; Thu, 23 May 2019 17:18:52 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 23 May 2019 17:18:52 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 23 May 2019 17:18:52 +0100 From: David Laight To: 'Oleg Nesterov' 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() Thread-Topic: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask() Thread-Index: AQHVELwtsgR+BAQFXk2JV68Wk/7LjKZ4aINAgABVkoCAAB2x0A== Date: Thu, 23 May 2019 16:18:52 +0000 Message-ID: <345cfba5edde470f9a68d913f44fa342@AcuMS.aculab.com> References: <20190522032144.10995-1-deepa.kernel@gmail.com> <20190522150505.GA4915@redhat.com> <20190522161407.GB4915@redhat.com> <4f7b6dbeab1d424baaebd7a5df116349@AcuMS.aculab.com> <20190523145944.GB23070@redhat.com> In-Reply-To: <20190523145944.GB23070@redhat.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-MC-Unique: NxgE-QeqMLGOVa7vAw4lcw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oleg Nesterov > On 05/23, David Laight wrote: > > > > I'm confused... > > Me too. To clarify, the current code is obviously buggy, pselect/whatever > shouldn't return 0 (or anything else) if it was interrupted and we are going > to deliver the signal. If it was interrupted the return value has to be EINTR. Whether any signal handlers are called is a separate matter. > But it seems that Deepa has other concerns which I do not understand at all. > > In any case, the signal_pending() check _inside_ restore_user_sigmask() can't > be right, with or without this patch. If nothing else, a signal can come right > after the check. > > > So epoll() can return 'success' or 'timeout' (etc) and the handler for SIG_URG > > should still be called. > > Not sure I understand... OK, suppose that you do > > block-all-signals; > ret = pselect(..., sigmask(SIG_URG)); > > if it returns success/timeout then the handler for SIG_URG should not be called? Ugg... Posix probably allows the signal handler be called at the point the event happens rather than being deferred until the system call completes. Queueing up the signal handler to be run at a later time (syscall exit) certainly makes sense. Definitely safest to call the signal handler even if success/timeout is returned. pselect() exists to stop the entry race, not the exit one. > or I am totally confused... The pselect(2) man page says that the signal handler for a signal that is enabled for the duration should run. Clearly it is also valid to call the signal handlers for any signals that are allowed on entry/exit (they could happen just after the return). Also remember that pselect() can also be used to disable signals. So ISTM that signal handlers allowed by either signal mask should be called during syscall exit. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)