Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2085946ybm; Thu, 23 May 2019 11:08:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyN90Yuxnrj31QVboIFWZCdMyO5rUiTrteQwVdFJbNNuGXmjK8Gl9eRZQsucGqs7zDnGkRu X-Received: by 2002:a17:90a:9f93:: with SMTP id o19mr3108469pjp.70.1558634930763; Thu, 23 May 2019 11:08:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558634930; cv=none; d=google.com; s=arc-20160816; b=PJ+5JAgjNsSB4cm7od/lZWUW2ZLNqy/Zq/zveIqxQeqbzfCZuqNb5F15qYWE7qzDei bntN2sdeFTvkc9D+AL32v7ZOUQuh6OyZyv3eGojXUWPl0//nNC73bgmAG27L2PPMtnEi Eq0ubywMsG3xs8aQQlVr3ye5rqp5s1NWLCEIZV6CeDjb+KwKUTeW4n8hGUnUrSOHOxfT O78w5j9O4Rm3gCTYgp0aQ2unSy7rxrmKU2KGCDJ6aCO9E7UJAl4nRHcEAgul8f4i2gS+ OGZIHdqDz7KYAjEZArCHhmGKfTwhPTIuM7mClFZg4FyD/oW+rG0r+3VWNeYVT2MZjNG/ Qsrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=XdOS1jq8b2ZAmKzwdek6sp8pOeqK25qgZhjMRx+3kPc=; b=kxQ44yhGa9iUJO8aoguie9xYOn02m0BSp6hXnYKrkxlaj4JMalSO30hILipCESzvDf JYnvhup0ZSXk/vgeZRg+/5246ElzPwOQkmrfh8hgdg8od7mi7vBM3pmN6iG/3fX7QBC2 Nuntkk+rD1/28PCkly/yHYxaoRdUvI58YjeaD6BcVDmCZOHg2o1ObL50NzLthhslQ5Hl k8whcjcUEqLtf+DbExe6T/mMnprojJsvIhrlkGXvX9fn59KSCNoT3dNMfIqxNkzZ5RFK 7lqXvyfrbEdRYz273P4hDIQ+Qf9GdbWi5k2yXNEwB2ZC3gb2DJrqOb/q1SaMzQm8G76z Un9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NWtL07zF; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g66si82271pje.45.2019.05.23.11.08.34; Thu, 23 May 2019 11:08:50 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NWtL07zF; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731388AbfEWSGt (ORCPT + 99 others); Thu, 23 May 2019 14:06:49 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:45548 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731093AbfEWSGt (ORCPT ); Thu, 23 May 2019 14:06:49 -0400 Received: by mail-io1-f66.google.com with SMTP id b3so228796iob.12; Thu, 23 May 2019 11:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XdOS1jq8b2ZAmKzwdek6sp8pOeqK25qgZhjMRx+3kPc=; b=NWtL07zFOCFP4lBu8Iphuhtalv/5o3pmtac06X4fCcWHWCwJ66NC+/eZo76l5v4fzJ /8EOn/fQ7zeG+DPayQVmNufQw84O/o9H1oOCw0fQfaLZ3sxud2tVSPtfN7Q/HEw7lmxX ouLciFoIAhTvk+ZpGNrpd0iDMLKtjqmCnryYJdyjMrDjqEm5VbOzB5Kc4RsmvChBgu7Y lbD6+axWrJgt+FmL44NWrR2x6diOBV1cHanRkGbk8DpyJJOyMv326+sSpAp4fOxHOESR E3j9rND/5Bml3JxdmQHl5AWGJG69qz+8idDIEcMfQCvBxbKt8bYBJlfTonsCRISMqiz3 PcIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XdOS1jq8b2ZAmKzwdek6sp8pOeqK25qgZhjMRx+3kPc=; b=ZNNI5zfvoh7rqkoGsYMz4q6pRzdD/FF+vCU4Xhv19AR/lXo0UQzKQFxMOk17J3+TFk xB9JcCtG56MsClZZHYnZpWHeSOaGN1qva0Yk44Vg5M2bQpB17di3yULCHiKF8iY1m/em DkjOZ1Im+vWOscwSrDSAOJkCEYGwTA8HGoIsP0OL3AgwmlzgTMa8F6jJYalpx1Jt/i/Q MiISGoTu4Re/jci818uEXxVYFqwvEXv3FbkfxxxXPFvR7r2NLkYIi8SFIzFCIJw/ZFvX 4eSFImCclbjVGaciUcjzlAE3omL6bOZEhFeGuFiUbTosHeUM9xF3W4+EO6KxrHJalS4X gsJA== X-Gm-Message-State: APjAAAUmmCbG8ORP/VO2G41IUYNNcqIzOcHttOlPJeF/j58NaMBB9cSQ FKK+k/sA3UPwODraimJpcph4i7CyIeUWVk1dWGQ= X-Received: by 2002:a6b:c411:: with SMTP id y17mr4123111ioa.265.1558634808133; Thu, 23 May 2019 11:06:48 -0700 (PDT) MIME-Version: 1.0 References: <20190522032144.10995-1-deepa.kernel@gmail.com> <20190522150505.GA4915@redhat.com> <20190522161407.GB4915@redhat.com> <4f7b6dbeab1d424baaebd7a5df116349@AcuMS.aculab.com> <20190523145944.GB23070@redhat.com> <345cfba5edde470f9a68d913f44fa342@AcuMS.aculab.com> <20190523163604.GE23070@redhat.com> In-Reply-To: From: Deepa Dinamani Date: Thu, 23 May 2019 11:06:37 -0700 Message-ID: Subject: Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask() To: David Laight Cc: Oleg Nesterov , 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" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 b. State after 854a6ed56839a c. Proposed fix as per the patchset in question. Oleg, I will discuss these first and then we can discuss the additional changes you suggested. Some background on why we have these syscalls that take sigmask as an argument. This is just for the sake of completeness of the argument. 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. 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. So if a signal is received after ep_poll() and ep_poll() returns success, it is never noticed by the syscall during execution. So the question is does the userspace have to know about this signal or not. From scenario [d] above, I would say it should, even if all the fd's completed successfully. This does not happen in [a]. So this is what I said was already broken. What [b] does is to move the signal check closer to the restoration of the signal. This way it is good. So, if there is a signal after ep_poll() returns success, it is noticed and the signal is delivered when the syscall exits. But, the syscall error status itself is 0. So now [c] is adjusting the return values based on whether extra signals were detected after ep_poll(). This part was needed even for [a]. Let me know if this clarifies things a bit. -Deepa