Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp12033557imu; Tue, 1 Jan 2019 12:29:51 -0800 (PST) X-Google-Smtp-Source: ALg8bN4xGj0ImEoDc7+wy7bmZm8rPNkrl5YF7yENwCbpWmbXiZk204aMd2fr1Prg39mGISc+bXGp X-Received: by 2002:a17:902:bf0c:: with SMTP id bi12mr41722225plb.0.1546374591141; Tue, 01 Jan 2019 12:29:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546374591; cv=none; d=google.com; s=arc-20160816; b=gLRp00aNh7rUBR/VdyCkcdgKnJeCZrdqPMifqOzo8BcznO9KPWLBClx5Kb2HYNGgmt BRpwRQ0J4qR7kmpHWwTn98mG1gt3U7TSb3GcwBtRCd2P/WF54J3yo/Abtcvx40RZZ+Ln k1US+rZGelj5iAeUbg4yTwpMSUrHdeBsJCN6H++6CIIAeKd5RDtV/EBKhZApSaEuBS+U WcXpsNmOu6fJmEozHiVDQz7PcTr5vXR7IGgc9gTmgLTftDTscfPbmxe0TAw+5I8WGLp1 ec4WCkVO76IR2xb8LDlZpj+/4hMGHfbNaw8VXiCb3KGZXc246nDzYdA74tXosVLP2hGq yROw== 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=w7pItN/TgGDS120Jv2BYgixL7Yn3Dn3aVenhcvPtmJQ=; b=ekTUqPCogNZkMWwGHegyqrzoHloNJfp4hPI1pS9yCTdZ8q1bYEvBmGaM5S6Rwx+PlI WddjfeAVZwFOOWYXQaUKFIr6RZzisy1tzxFD1bkpRZ+3K0GHjMPBrfiFibKV9hJ0NTbu iPOMrxX1Fp8N3yowRCAu63VoXipt3iT19l454BaRGXxQ7R+sBWB0Tx+MOSA489Jx6/H4 VAqXM5NEAHzOqe5jJkDxIJwjgD9LMI8wF2+TY2/RoOQQhaY8bfLlnPnUh7Hx1FDtMM1+ +WvH3TieuUillvk0ati8lgqpCnU+yxmr+3/DfC7D2uPUjhp/jn7JU6y05jm8Fww0T9HP 15BA== 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 d5si46347629pla.361.2019.01.01.12.29.15; Tue, 01 Jan 2019 12:29:51 -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 S1729022AbfAARCG (ORCPT + 99 others); Tue, 1 Jan 2019 12:02:06 -0500 Received: from mail.hallyn.com ([178.63.66.53]:47180 "EHLO mail.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727224AbfAARCF (ORCPT ); Tue, 1 Jan 2019 12:02:05 -0500 Received: by mail.hallyn.com (Postfix, from userid 1001) id 68CC1AC2; Tue, 1 Jan 2019 11:02:03 -0600 (CST) Date: Tue, 1 Jan 2019 11:02:03 -0600 From: "Serge E. Hallyn" To: Christian Brauner Cc: "Serge E. Hallyn" , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, luto@kernel.org, arnd@arndb.de, keescook@chromium.org, akpm@linux-foundation.org, jannh@google.com, oleg@redhat.com, cyphar@cyphar.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, dancol@google.com, timmurray@google.com, fweimer@redhat.com, tglx@linutronix.de, x86@kernel.org, ebiederm@xmission.com Subject: Re: [PATCH v6 2/2] selftests: add tests for pidfd_send_signal() Message-ID: <20190101170203.GA15661@mail.hallyn.com> References: <20181229222756.30027-1-christian@brauner.io> <20181229222756.30027-2-christian@brauner.io> <20181230210245.GA30252@mail.hallyn.com> <20181230232711.7aayb7vnhogbv4co@brauner.io> <20190101150743.ikrrfcogqec2oqeh@brauner.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190101150743.ikrrfcogqec2oqeh@brauner.io> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 01, 2019 at 04:07:44PM +0100, Christian Brauner wrote: > On Mon, Dec 31, 2018 at 12:27:13AM +0100, Christian Brauner wrote: > > On Sun, Dec 30, 2018 at 03:02:45PM -0600, Serge Hallyn wrote: > > > On Sat, Dec 29, 2018 at 11:27:56PM +0100, Christian Brauner wrote: > > > > As suggested by Andrew Morton in [1] add selftests for the new > > > > sys_pidfd_send_signal() syscall. > > > > This tests whether we can send a signal to an existing process and whether > > > > sending a signal to a process that has already exited fails with ESRCH. > > > > > > > > [1]: https://lore.kernel.org/lkml/20181228152012.dbf0508c2508138efc5f2bbe@linux-foundation.org/ > > > > > > > > Cc: Arnd Bergmann > > > > Cc: "Eric W. Biederman" > > > > Cc: Kees Cook > > > > Cc: Serge Hallyn > > > > > > Acked-by: Serge Hallyn > > > > > > Not saying you need to do this, but it would be neat if you could test > > > sending to a pid which has been recycled :) > > > > Yeah, I thought about it but it's a little weird code. First of all, we > > can't set /proc/sys/kernel/pid_max to a very low value since this is a > > system wide setting. So we need to recycle a lot via fork(). Something > > along the lines of: > > - unshare pid namespace > > - fork to create pid 1 in new pid namespace > > - cycle with fork() until pid > 300 since pids lower than 300 are > > reserved by the kernel. > > (That means if we simply use the first fork() after we created pid 1 we > > would never be able to recycle the pid since we skip over it. :)) > > - get pidfd to the pid > 300 we just created > > - wait on the pid > 300 > > - cycle via fork() until we have reached the same pid > 300 again > > - send SIGSTOP to that recycled process > > - test that we cannot send SIGCONT to this SIGSTOPed task via the pidfd we > > received before > > - send SIGCONT to the SIGSTOPed recycled pid and exit > > Ok, I have something like this in my tree now that tests for pid > recycling. I'm going to send it out tomorrow since I reckon Andrew and > others will be off today. > But fwiw it sits in https://github.com/brauner/linux/commits/2018-12-02/procfds Thanks, that shows off the advantages of the new syscall :) -serge