Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5903235ybi; Tue, 4 Jun 2019 14:28:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFa30Dhf2uSuLD3zP1AIrtknPJHtCao9cTyXSzctZTtSA7NrwgN0/SwhHzjtRzJm71CxwB X-Received: by 2002:a62:5486:: with SMTP id i128mr41028813pfb.156.1559683739769; Tue, 04 Jun 2019 14:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559683739; cv=none; d=google.com; s=arc-20160816; b=068riAuXKqlQTZuutZzIeAQok7DN2AsA/8IhAXAi9+05vbVUbFwB2VO4qnUwRteKLc VAFeBnWkMbotjZ8tJlTPdgdbs9XjOOg/UsEGnH4JBWd1Ikw/xWPvuuyELXs6/OqKDzfB BxRtyriTzuNelFax1l1cHp3JoxfrG7sd1+QDS8sVPzg7WtyVBMcfLgG3bkhtK0oRT2cl 1UihRhlSK2WVvYB/NSwSpHMzCKHMyyZAnBi1/LHf97ZdaIU5EuSFLeqvM58i+cFcUw6X SlWxxt1yIuMzCxNWCzxvo+nY4o+1XSXmxlYqlH6od+i+ITsQldsT/zW2AnV/0CIEa+pP 0pZg== 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=fjr6VsCXE/x8E/UigyoFfXOlatfjUvy0HOG/EWEq9/E=; b=JpBsEz0Ror8597FQVsKrd0vqFhzjXgUIRW+Va5nHrnW2vrYBxhPifCiBAe0II9ka6q GrxduHnXrxrXcZ457iVDYYSf9lBtKf9dN4gaMTItuFJVEaZltSaS1PE0xkBo2FjppTvW GmKAvZ1Mw+B0wp/EbzxbDG35kXDHMbWLdqbsVRPMvbfxkUzA+ZwUvnq2+9TNYKTCJNV/ OhNouuvuvMFbXDJ7NCDXUf2q82eNIn9/PU8dBj8UafXCjf8aWqTo1yKGFVvJNDy8EoIV R5OKKLRKPlWTr7CSgJ7FK8RAXVZ325kalyefFfT4tHncp6jDZGw+MaEsXtDnftEGUgpn Y0lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=AqnHNsD1; 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 cl16si16561795plb.7.2019.06.04.14.28.43; Tue, 04 Jun 2019 14:28:59 -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=@linux-foundation.org header.s=google header.b=AqnHNsD1; 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 S1726541AbfFDV1D (ORCPT + 99 others); Tue, 4 Jun 2019 17:27:03 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:45528 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726179AbfFDV1D (ORCPT ); Tue, 4 Jun 2019 17:27:03 -0400 Received: by mail-lf1-f68.google.com with SMTP id u10so10504598lfm.12 for ; Tue, 04 Jun 2019 14:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fjr6VsCXE/x8E/UigyoFfXOlatfjUvy0HOG/EWEq9/E=; b=AqnHNsD1VskjlimA3YwkF5JNU3DvSRUk55MoR6ni75AS44QkMcJCvxHI3dSdlI6y5J mKW0Es7RWq6sAXJ9MeVUOaPQSf8pexTFCehFbQMkkbeBhb+EWYhswZLPdoe2U/wgnvPd T/eBCFdkAAdh/w7SO0Y9hNdRXoDDz3+5dAwXw= 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=fjr6VsCXE/x8E/UigyoFfXOlatfjUvy0HOG/EWEq9/E=; b=sFK5NbsDtwWIG/OHI2aDkp14PoT/cZttTfsz7x+youDTtd0NZte3jjaWUwMB3iwcQz OKjBXHxdLHKSL5T4XGmrXb2UjgbORgi0Q/6ozt79hULLI0jgA1aKBzIoISjS4cNNOFU3 3XHgmCZKKcVYSKWQRIng2EAeGiib4x6nJ+AMwMgUAham/3mK8J9Ri4wKAhPir60gNagv cFdS8ETWzaEa7ZFQkZwhzPUhq8t3+TTcRkoTZinDHCkSWV32Z2ZwgaJBB+Faon3qPnQ7 MzEdrMKhf1iJ4bzBRabm9KNqBjGcxNwuH7+eKACs0EICV/jHVUdZgxF2Wky+otIabCV8 3U6g== X-Gm-Message-State: APjAAAVtmo+owZjNDdK5J5OK+JON4wDX56LkAERwNnPDjMS2kyIMojq+ P7LZ1AXtDUVDj0uhVYMmibt4usuAuVA= X-Received: by 2002:a19:2948:: with SMTP id p69mr17512979lfp.160.1559683620631; Tue, 04 Jun 2019 14:27:00 -0700 (PDT) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com. [209.85.167.53]) by smtp.gmail.com with ESMTPSA id m25sm2914933lfp.97.2019.06.04.14.26.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 14:26:59 -0700 (PDT) Received: by mail-lf1-f53.google.com with SMTP id j29so3627662lfk.10 for ; Tue, 04 Jun 2019 14:26:59 -0700 (PDT) X-Received: by 2002:a19:ae01:: with SMTP id f1mr17362076lfc.29.1559683618741; Tue, 04 Jun 2019 14:26:58 -0700 (PDT) MIME-Version: 1.0 References: <20190522032144.10995-1-deepa.kernel@gmail.com> <20190529161157.GA27659@redhat.com> <20190604134117.GA29963@redhat.com> In-Reply-To: <20190604134117.GA29963@redhat.com> From: Linus Torvalds Date: Tue, 4 Jun 2019 14:26:42 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] signal: remove the wrong signal_pending() check in restore_user_sigmask() To: Oleg Nesterov Cc: Andrew Morton , Deepa Dinamani , Linux List Kernel Mailing , Arnd Bergmann , Davidlohr Bueso , Jens Axboe , Davidlohr Bueso , e@80x24.org, Jason Baron , linux-fsdevel , linux-aio@kvack.org, omar.kilani@gmail.com, Thomas Gleixner , stable , Al Viro , "Eric W. Biederman" , David Laight 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 On Tue, Jun 4, 2019 at 6:41 AM Oleg Nesterov wrote: > > This is the minimal fix for stable, I'll send cleanups later. Ugh. I htink this is correct, but I wish we had a better and more intuitive interface. In particular, since restore_user_sigmask() basically wants to check for "signal_pending()" anyway (to decide if the mask should be restored by signal handling or by that function), I really get the feeling that a lot of these patterns like > - restore_user_sigmask(ksig.sigmask, &sigsaved); > - if (signal_pending(current) && !ret) > + > + interrupted = signal_pending(current); > + restore_user_sigmask(ksig.sigmask, &sigsaved, interrupted); > + if (interrupted && !ret) > ret = -ERESTARTNOHAND; are wrong to begin with, and we really should aim for an interface which says "tell me whether you completed the system call, and I'll give you an error return if not". How about we make restore_user_sigmask() take two return codes: the 'ret' we already have, and the return we would get if there is a signal pending and w're currently returning zero. IOW, I think the above could become ret = restore_user_sigmask(ksig.sigmask, &sigsaved, ret, -ERESTARTHAND); instead if we just made the right interface decision. Hmm? Linus