Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6960586ybi; Wed, 5 Jun 2019 09:00:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDnLAh1Tj6zwzp1blqTzGXriXaJT4qvqPrKkn9dUjWVT9RmqJsbeySPXkmPC6aCg/KAgax X-Received: by 2002:a62:ea0a:: with SMTP id t10mr46964814pfh.236.1559750412600; Wed, 05 Jun 2019 09:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559750412; cv=none; d=google.com; s=arc-20160816; b=a4zGCTsLcHMq+RbAX4/nh533PfC2L6MgkX0PYFI9u9LNH3xsF9Pq3i3UsLKvWpBOXh 4nCfctgyeM2KC5YgfCcZ+kxdaapcPYhfIZBZHAWxAoB4cX4w7qhYhBL+I0rLhL6/3k8Z oHsqcEgQ86+WvjTlCFbZSD5cQk1F+M/cupBsDjvefwh/EnyN03RFbjwRf01ASaoHrMQk cVUktTO9pZ6PrF0p4CHj6UnstUsE/kV5B+7Ms2sariV+mJVCoHwIcDwnmvKL9mL8b9Bt C7Nhvt2Q4hzO7n+uK7uX9YJTV7dcRIXMzIc7GHiC0Byxeq8L1iw0ZeCXnO0J2j2M4+83 9NWw== 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=qENOKjaB7ql/tiSeanJZU0wQNPYnPTV9bRESoPWXGJw=; b=H5Y+GuwiEx9+esDnZi2nqOJPOJHo/hczlTseKc+1X87rNKoCefTkbxJbsuDA+7dRQK IyWv3dlt1XuuiZHw+3mS0B8z4za2wCuFgQ6qKK8efdqTtGE0GttLKw+k29tjLl6YzXZz xNfGd65MEQjr7rQVmvO5h8Bc/Ol8Znvouazd0oMIqJ40OMK8HFe8XaSKihgzG3SJL0ri 1NnKOrHJE/2XFjpZpT7lNLJqD7Zlr6TcUSWgSjZW6FsC9oeIX68gMHrmNm8Y7AfkSTcb UBik87BR5cniWk/kknhqBVndh4rqHkGq9HBc7Gwe5VUMjiuOVjBSwpmJcUCPDkXYOr42 nqPA== 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 z28si9866074pga.488.2019.06.05.08.59.54; Wed, 05 Jun 2019 09:00: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 S1728575AbfFEP61 (ORCPT + 99 others); Wed, 5 Jun 2019 11:58:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51476 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728386AbfFEP61 (ORCPT ); Wed, 5 Jun 2019 11:58:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C57F81F0D; Wed, 5 Jun 2019 15:58:12 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.159]) by smtp.corp.redhat.com (Postfix) with SMTP id B16BA80B9; Wed, 5 Jun 2019 15:58:02 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 5 Jun 2019 17:58:11 +0200 (CEST) Date: Wed, 5 Jun 2019 17:58:01 +0200 From: Oleg Nesterov To: Andrew Morton , Deepa Dinamani Cc: linux-kernel@vger.kernel.org, arnd@arndb.de, dbueso@suse.de, axboe@kernel.dk, dave@stgolabs.net, e@80x24.org, jbaron@akamai.com, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, omar.kilani@gmail.com, tglx@linutronix.de, stable@vger.kernel.org, Al Viro , "Eric W. Biederman" , Linus Torvalds , David Laight Subject: [PATCH -mm 0/1] signal: simplify set_user_sigmask/restore_user_sigmask Message-ID: <20190605155801.GA25165@redhat.com> References: <20190522032144.10995-1-deepa.kernel@gmail.com> <20190529161157.GA27659@redhat.com> <20190604134117.GA29963@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190604134117.GA29963@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 05 Jun 2019 15:58:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On top of signal-remove-the-wrong-signal_pending-check-in-restore_user_sigmask.patch Let me repeat, every file touched by this patch needs more cleanups, fs/aio.c looks wrong with or without the recent changes. Lets discuss this later. To simplify the review, please see the code with this patch applied. I am using epoll_pwait() as an example because it looks very simple. Note that this patch moves WARN_ON(!TIF_SIGPENDING) from set_restore_sigmask() to restore_unless(). int set_user_sigmask(const sigset_t __user *umask, size_t sigsetsize) { sigset_t *kmask; if (!umask) return 0; if (sigsetsize != sizeof(sigset_t)) return -EINVAL; if (copy_from_user(kmask, umask, sizeof(sigset_t))) return -EFAULT; set_restore_sigmask(); current->saved_sigmask = current->blocked; set_current_blocked(kmask); return 0; } static inline void restore_saved_sigmask_unless(bool interrupted) { if (interrupted) WARN_ON(!test_thread_flag(TIF_SIGPENDING)); else restore_saved_sigmask(); } SYSCALL_DEFINE6(epoll_pwait, int, epfd, struct epoll_event __user *, events, int, maxevents, int, timeout, const sigset_t __user *, sigmask, size_t, sigsetsize) { int error; /* * If the caller wants a certain signal mask to be set during the wait, * we apply it here. */ error = set_user_sigmask(sigmask, sigsetsize); if (error) return error; error = do_epoll_wait(epfd, events, maxevents, timeout); restore_saved_sigmask_unless(error == -EINTR); return error; } Oleg.