Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp831119imu; Thu, 22 Nov 2018 06:05:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wkmd15IMx28ldm2gxYeAEZE0XDX1YgWFwkXtRQd1hirpCLuZ8nfh9d+9Lf+DlimEZ/AxQ1 X-Received: by 2002:a63:42c1:: with SMTP id p184mr10087726pga.202.1542895519886; Thu, 22 Nov 2018 06:05:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542895519; cv=none; d=google.com; s=arc-20160816; b=lmYp0yyk0jZ5pNuhp4guarRBbPwwmWf9V7FZcX2hTxkoj7WyIipETNayMpBlUY8r9C 6oFHCpK7bWcj0H5OXwBSpAoJjGrdQnUuK9KcZTSqJ9UyuS0Pf5/h28JdryxGl9ZdwaOv oaIb9swB11CYIAkkPBYSwzF0EYDG01WTQwJYimZxujmE8FbW8MHlHvvCrCXsAU/eB8hx qXQ0nlwxwHP6N6/SBtMvyNYdQFoKP8ptPkeh+HaV90fG40kSIzX1Lb1FolHZNlqwzOcE BLtMlaQ1p2Za9X2ABx9regKusRcf6iNdEruseJ/7jstXXBBPVGhzwBri2prhoKWmfgMY ZsZA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=CyvYDAPTnZD8FEpZP36ahfc7gFf9e+lF4JZ03KFziv4=; b=VI2vdzAHSL9MY5R7rCBrVCteSAGMr6ILSNpnazOkIa20jzOzlaziNeAHpwbnGMQ2Fd ck48hurcSQzPihSpOwmi8e9/qOfCYB3bdrbh+tnJB/Ox4lRHrG47P+5v7+Wi38gcisOd D6Vxp5uve3Ioh4yIOthT0H7x6VHfQmm/GOp7bvvK/c+ZQ9WQdwqEIx+74SZrN1Iz8Qwf Kb1J0astRWkZiWCboBvHZ91P7wpaEHvy/1qdZ7meyLwREaWCajd6XinEjMEWVmWIVE4c G9s3i3ibr1MaRkiPaIUeLUj0qpE/LLCIdPpfDb9AXxBhVNwcIZhKlfTx7Iw+YbdhkYou l8SA== 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 m7si49901470pgi.547.2018.11.22.06.05.04; Thu, 22 Nov 2018 06:05:19 -0800 (PST) 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 S1732754AbeKVMyA (ORCPT + 99 others); Thu, 22 Nov 2018 07:54:00 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:51302 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732695AbeKVMyA (ORCPT ); Thu, 22 Nov 2018 07:54:00 -0500 Received: from localhost.localdomain (c-24-6-170-16.hsd1.ca.comcast.net [24.6.170.16]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 80A175B1; Thu, 22 Nov 2018 02:16:51 +0000 (UTC) Date: Wed, 21 Nov 2018 18:16:50 -0800 From: Andrew Morton To: Andrei Vagin Cc: Oleg Nesterov , linux-kernel@vger.kernel.org, "Eric W. Biederman" Subject: Re: [PATCH] ptrace: take into account saved_sigmask in PTRACE_{GET,SET}SIGMASK Message-Id: <20181121181650.8d2d6abcf83b9defb7195cd3@linux-foundation.org> In-Reply-To: <20181120060616.6043-1-avagin@gmail.com> References: <20181120060616.6043-1-avagin@gmail.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 19 Nov 2018 22:06:16 -0800 Andrei Vagin wrote: > There are a few system calls (pselect, ppoll, etc) which replace a task > sigmask while they are running in a kernel-space > > When a task calls one of these syscalls, the kernel saves a current > sigmask in task->saved_sigmask and sets a syscall sigmask. > > On syscall-exit-stop, ptrace traps a task before restoring the > saved_sigmask, so PTRACE_GETSIGMASK returns the syscall sigmask and > PTRACE_SETSIGMASK does nothing, because its sigmask is replaced by > saved_sigmask, when the task returns to user-space. > > This patch fixes this problem. PTRACE_GET_SIGMASK returns saved_sigmask > is it's set. PTRACE_SETSIGMASK drops the TIF_RESTORE_SIGMASK flag. Looks good to me, but what would I know. I'll await input from Eric and/or Oleg (please). > --- a/include/linux/sched/signal.h > +++ b/include/linux/sched/signal.h > @@ -417,10 +417,20 @@ static inline void set_restore_sigmask(void) > set_thread_flag(TIF_RESTORE_SIGMASK); > WARN_ON(!test_thread_flag(TIF_SIGPENDING)); > } > + > +static inline void clear_tsk_restore_sigmask(struct task_struct *tsk) > +{ > + clear_tsk_thread_flag(tsk, TIF_RESTORE_SIGMASK); > +} How irritating is it that this file uses "task" 85 times and "tsk" 19 times? What did that gain us? This patch worsens things. Oh well.