Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp336723imu; Mon, 26 Nov 2018 22:39:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/XtRqjEjxLszJIunnkqCJuUg3uUtbVSbAH3ElKqVLUFUCE+mfIjz6qyoX1M5it5PXVkCWYM X-Received: by 2002:a63:ba19:: with SMTP id k25mr27909470pgf.194.1543300775757; Mon, 26 Nov 2018 22:39:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543300775; cv=none; d=google.com; s=arc-20160816; b=wEZTKsI5DCyFyf6Ez8/Bcn6oqBfjD9SA6InuoVtXPSwZu4FqW+iz60MLWWAP27bBQG ETl1RJuXX0cZLRFbHG+LEE+xecguityLK0Z58pqRFofTPzYEPw0U/WK0lD4IZkslu5+F 13fnn/XGLyouXzHFTzShtIwVlOf2xMhZLx06uwc7CFX7L9kP8kqKzN5aiti9VbIny/nJ r1tCHjrG9c/K+4dKNcaIhLSoSxm2aTYyIdl416R4L2NW6ECZvLDe4p9U3MPCi2GT+jSy jaelPraJpaoi+wo4jTCj8NMEPK6R5KiD6sFaoXFInGnWX0s/Z5GgmWeuIUGehvZ6iKf/ g/Pg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FCOOcHkAfoAGjfJYYFY3kt7fdCfH3+5Z87al/sdnHNI=; b=Ws3guNSMAfDegkUh7EzIPr8NQaWH9Vkm83bIxjK2ZH5IBxn4yX6aZFH0QgWX5WLcl9 ULi0+IECm1gg6yGK64lEOd6ySA3xP1jjPFiCJXCMMzxw/dQt9jCSjX9sM+rzUFLxvBdB bToEDoi9mw2BaM8jj1ZzjLrJebpCtJYCRSK7CfCDiKrGnv2IPk0cqfKoTJsAe43xKjpx baueDVxB0jap3qlmVjuVDnm15T+sO0ZSUw6qhxMfZmSJK5yxuGO6oszvfosATOla4lSo yv69AGInu2qRxUGalCbmiQ6KQjKYB0v8q5tW7miyjPp2oeNzxKSd/Vd05tPbCC5p0/RZ n1NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VnV7TnO3; 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 b2si2566968pgh.475.2018.11.26.22.39.06; Mon, 26 Nov 2018 22:39:35 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VnV7TnO3; 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 S1728821AbeK0Rey (ORCPT + 99 others); Tue, 27 Nov 2018 12:34:54 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:39945 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727684AbeK0Rex (ORCPT ); Tue, 27 Nov 2018 12:34:53 -0500 Received: by mail-pg1-f196.google.com with SMTP id z10so7386907pgp.7 for ; Mon, 26 Nov 2018 22:38:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=FCOOcHkAfoAGjfJYYFY3kt7fdCfH3+5Z87al/sdnHNI=; b=VnV7TnO3TV54TrSNlbNbMpS7TKGug7hrNF3EyS7oZtQDTRZmvLrjYp1uR8d3TuLhvv aMJX9nh61MKW73x/X3h9SxJjmMIpy6WuYKGtcA8LB659gBFQtQUU0anHzxJcLVQKYtD8 XoFvqRR3x9c6OuQ1EBOEEWvmx/RVUb31Z45TPrfqQhViZz1zddYGs6jr7dTuyi93RfkA Gz80NQ1jTl7WisF4R0ZIFv031nxRN+fJ2lA05FTHx5O/ECvscpLechf8p+8ey3PXAjDX pLX8kd/O+Dy00vFwQPEpjilgVf8W079VKudgA01+gumZNPDEmz6ZPYBDsmcbYDVRevVC okxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=FCOOcHkAfoAGjfJYYFY3kt7fdCfH3+5Z87al/sdnHNI=; b=DuJ/egysFJ0UvDbD1yXdlzrkF4pd7KaoN/DaB8A0xhKX4CC16jgozyZNmbbGp+KMuT vuhNIs4U6UEyQy8JtAzhDtWvZNVzng1DUEYPP7Bys9nax0gvqTJRaDHwyfdkUJpLh/ep jgZzF9PeMNue0JITscmuokDGFStv6ijBMVVAFhVh32XsGXqKRB0///nlbLWlLpAzicFE zG/muL4usvciJc9jX3z43PStvNRLRzdY1yTO6M1fycWHFORWC2j2IbvoRlZ0jx7NO82N Xhoj3vrr1yeHqVDtY9ORDcYaJDCA3hpsDWeBxhZKmVKThgcYLuiyh8Hx5r8xA1pWTz1S 0ugw== X-Gm-Message-State: AA+aEWb/VIV1P5Z/2TZwqz34pQ3xXGYlVNjaNwZv55gKTy46EBWEntMp 2FaJkrU5ZJQqkP+fX3S2MXj2Bh+6 X-Received: by 2002:a63:6dc8:: with SMTP id i191mr27130365pgc.215.1543300682949; Mon, 26 Nov 2018 22:38:02 -0800 (PST) Received: from gmail.com (c-73-140-212-29.hsd1.wa.comcast.net. [73.140.212.29]) by smtp.gmail.com with ESMTPSA id r4sm2959982pgn.54.2018.11.26.22.38.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Nov 2018 22:38:02 -0800 (PST) Date: Mon, 26 Nov 2018 22:38:00 -0800 From: Andrei Vagin To: Oleg Nesterov Cc: linux-kernel@vger.kernel.org, "Eric W. Biederman" , Andrew Morton Subject: Re: [PATCH] ptrace: take into account saved_sigmask in PTRACE_{GET,SET}SIGMASK Message-ID: <20181127063758.GA10422@gmail.com> References: <20181120060616.6043-1-avagin@gmail.com> <20181122114751.GA28270@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181122114751.GA28270@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 22, 2018 at 12:47:52PM +0100, Oleg Nesterov wrote: > On 11/19, Andrei Vagin wrote: > > > > case PTRACE_SETSIGMASK: { > > sigset_t new_set; > > @@ -962,6 +971,8 @@ int ptrace_request(struct task_struct *child, long request, > > child->blocked = new_set; > > spin_unlock_irq(&child->sighand->siglock); > > > > + clear_tsk_restore_sigmask(child); > > + > > I am not sure I understand this change... > > I forgot everything I knew about criu, but iiuc PTRACE_SETSIGMASK is used > at "restore" time, doesn't this mean that TIF_RESTORE_SIGMASK/restore_sigmask > can not be set? PTRACE_SETSIGMASK isn't used on restore. On restore, criu generates sigframe and calls sigreturn to restore registers, fpu state, sigmask and resume a process. ?When the kernel constructs a signal frame, it calls sigmask_to_save() to get a process signal mask. With this patch, PTRACE_GETSIGMASK returns the same signal mask what is returned by sigmask_to_save(). In CRIU, we don't need to set TIF_RESTORE_SIGMASK, because all processes are dumped when they are in user-space. > > IOW, could you please explain how PTRACE_SETSIGMASK should be used, and why > it doesn't do something like > CRIU uses PTRACE_SETSIGMASK?when it injects a parasite code into a target process. In this case, we have to be sure that when the process is resumed by PTRACE_CONT, it will not start handling signals and executing signal handlers. > if (test_tsk_restore_sigmask(child)) > child->saved_sigmask = new_set; > else > child->blocked = new_set; > > which looks symmetrical to PTRACE_GETSIGMASK? If we set child->saved_sigmask, the child can start handling signals which are not set in child->blocked. > > Oleg. >