Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp460385rdb; Thu, 22 Feb 2024 08:54:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX7Y7Nk0N9QIQ1PUFv3E47iHAtW0FljaJ7qhKrHY9KKTrSspQ8l344uJ3ScXmNnf+9RJx3opAhV2K1GiNZdzKyk19BZqXgqJUXECvrjDg== X-Google-Smtp-Source: AGHT+IHi6P0G5PFuipqbCXLqXrpLs0Pm78nA9pRYcslsHDkLNeo2sYGoexOgcK8m6Yljb9+a8xnr X-Received: by 2002:a05:6871:110:b0:21e:816c:3aee with SMTP id y16-20020a056871011000b0021e816c3aeemr18892391oab.19.1708620861257; Thu, 22 Feb 2024 08:54:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708620861; cv=pass; d=google.com; s=arc-20160816; b=Ep6wTa+NNvL/Hc9FpPL3TlBe46PH1msJo4jF6QhX+Nsa//jOnPndgztx/+a+5/0+cb 6uCuLhY7r9bBP3Hu2+kCtKaEjCbKXTM5XiYg7k16AGBV2Z6W+Pj7bNCng74glpinaN4o zptoSCCi07WRwQ4O9Ll2g6ZMIqg5JuOAPku5dFSR8ZGqHz5lUVc1mSuGcZW9SH7Oy0ih zfBP/PiENionX3TES9cXo6cupBOdrOE/N23HP3YfP0MADBvNrjKtFcwh5g25J2L35+d7 8jZ7qKPxRUE+13xx+R/Ux4/zLvrshTW2v4yfi0P0yOoGav3XHoDSD7WNtcpeiZGTliA9 5+vA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature:dkim-signature; bh=hqDRJV0DN2B7E3tvQrfx/1Luut6HMg4FaRuM4DS0KaA=; fh=/TnwUtv4cx7xUAz/8QKYUn9p+KoxEFw1E3N6n7kehA8=; b=NGu6GALuN1mELYbrvBr4n/4vc6nGC6rCIchEhUmXyshvPcsFR5h6Qp7QN0tWqynMRu s0PrLvdB0PGd8bgWA2pY3yIt7sO89dkeAeP+6kmWKlQWSY0vrd90ffl/RUQS7etoQrSC 3C30wiUXo6qDglj/1ZmGQYOXQxyItVwtoqG+TLdaWJstXPPyH7bH3fKAzuvLJCzGBcbi FXXVrsl8VCF8R59r+ttYtBhz8bAu1Fxokdv62FYKjEOgWhbHmIT7OJ4gvl3SIQPbjbnY iJL3IskJFSO0JG7tO8A40kU7lMGDBc8PT8M4jdbAk63Lum5owCSdeUD1hensaywAr/KR WTCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm3 header.b=NlouxiFP; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=oxPaP+Ug; arc=pass (i=1 spf=pass spfdomain=tycho.pizza dkim=pass dkdomain=tycho.pizza dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-76909-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76909-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id cc11-20020a056a02074b00b005e3cdc24c26si6540627pgb.467.2024.02.22.08.54.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 08:54:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76909-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm3 header.b=NlouxiFP; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=oxPaP+Ug; arc=pass (i=1 spf=pass spfdomain=tycho.pizza dkim=pass dkdomain=tycho.pizza dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-76909-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76909-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DDA43285E5B for ; Thu, 22 Feb 2024 16:54:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0EA7A154BE3; Thu, 22 Feb 2024 16:54:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tycho.pizza header.i=@tycho.pizza header.b="NlouxiFP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="oxPaP+Ug" Received: from fout3-smtp.messagingengine.com (fout3-smtp.messagingengine.com [103.168.172.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A448518657 for ; Thu, 22 Feb 2024 16:54:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708620854; cv=none; b=S4ZZqnO71VE1hbAGz3pDCB9V8UlmYJZpjgf6wE4WOUGkOMcBRBcAseHIy1tHZ1aAnXGIQ0RKjgeANEuEBIrB62nDGtVMLHlHcWHODiE4QYsjbn8f75HiA0R1noWRKxPKO+YsiNcaAtYySmG3WK2zfqlqspexAyX1cbvfdsv++Gg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708620854; c=relaxed/simple; bh=vDoQ0aZbTs8ZLCh+uLJfUxNhj3TaGAQaNzYPkZ8iGCk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BKYeYoEpC3jyByxeKVsbInnU1ZKQtxsYrgTsHbC+7y13uM1LPqN3CrbJBm1l04s4Jyt0UwuRljVtR4EB5LDY5nE6oQTtLUwJfF9HbYQ0smF4GZ17Tthcl4Jta1oBPD2Xw3lNnH770T1C82hGPPMhKGAL1grPwEakUMLKhegoS9U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tycho.pizza; spf=pass smtp.mailfrom=tycho.pizza; dkim=pass (2048-bit key) header.d=tycho.pizza header.i=@tycho.pizza header.b=NlouxiFP; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=oxPaP+Ug; arc=none smtp.client-ip=103.168.172.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tycho.pizza Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tycho.pizza Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id A7A261380095; Thu, 22 Feb 2024 11:54:11 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 22 Feb 2024 11:54:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho.pizza; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1708620851; x=1708707251; bh=hqDRJV0DN2 B7E3tvQrfx/1Luut6HMg4FaRuM4DS0KaA=; b=NlouxiFPbV2TARaux11uWq6dUI bkUbvBmcBDmga0gZg8kbx7hMoZ0JMqRPafOXzbRStob+8TdtAMJslENFPKpx3GIh bB97s7TPFaWV2ObNJ7pCUpqFe4giEElT4IZCAraKdPAtlPQlIQvlGGww9zrAuoWb eS9Grx759gJ6nH5ROvk7fxpjR4zQacmw9Dxlwah3SWzO3ZMC6Gr6g9lt3YAog1Sg FSYjgKZA751nffP09YpR7E1yYEfR/HFXCDh3rVbxylqfZhT2W3LN1Cbsgv8QC3mw AeX+c4ffwlSun7t0LpsezotqW4obs0LlfoXqrknsXVxl/3QO8+PWBmYvvcYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1708620851; x=1708707251; bh=hqDRJV0DN2B7E3tvQrfx/1Luut6H Mg4FaRuM4DS0KaA=; b=oxPaP+UgUwiZDlHbKg1ZjeTTxj4TUkjM95HguTL6i3+0 cv6lYdZ9OnmIp2BwjpKH0HsWkVNf+zrbBe2pi74waZKCyyjmSlkLW7DVET5Nt4fq sMVm9+o9DXEmqsMUCq/lpngmtyOz4VCr5S4NyCuOuYkY5Fzdp7sO0jLpDtSccJ4r x4qHp+bNnReK6YOGAhNEFSSaxmalLOY7FcFVfbvWUydvSyOEA4Yjuk07zQuvebmy fUjKegspBImEjX0z009LOiVfcAWUzRARkF6Rk4WE+0erJTSxZ2YdX7SGzy57IDc8 OyrBJkSKwil+Ry4S01G9XFKO3MGkaMyqAaNxnFjf5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeeggdelvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefvhigthhho ucetnhguvghrshgvnhcuoehthigthhhosehthigthhhordhpihiiiigrqeenucggtffrrg htthgvrhhnpeeutedttefgjeefffehffffkeejueevieefudelgeejuddtfeffteeklefh leelteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hthigthhhosehthigthhhordhpihiiiigr X-ME-Proxy: Feedback-ID: i21f147d5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Feb 2024 11:54:10 -0500 (EST) Date: Thu, 22 Feb 2024 09:54:08 -0700 From: Tycho Andersen To: Alexander Mikhalitsyn Cc: brauner@kernel.org, stgraber@stgraber.org, cyphar@cyphar.com, linux-kernel@vger.kernel.org, Christian Brauner Subject: Re: [PATCH v1 2/2] tests/pid_namespace: add pid_max tests Message-ID: References: <20240222160915.315255-1-aleksandr.mikhalitsyn@canonical.com> <20240222160915.315255-3-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240222160915.315255-3-aleksandr.mikhalitsyn@canonical.com> On Thu, Feb 22, 2024 at 05:09:15PM +0100, Alexander Mikhalitsyn wrote: > +static int pid_max_nested_limit_inner(void *data) > +{ > + int fret = -1, nr_procs = 400; > + int fd, ret; > + pid_t pid; > + pid_t pids[1000]; > + > + ret = mount("", "/", NULL, MS_PRIVATE | MS_REC, 0); > + if (ret) { > + fprintf(stderr, "%m - Failed to make rootfs private mount\n"); > + return fret; > + } > + > + umount2("/proc", MNT_DETACH); > + > + ret = mount("proc", "/proc", "proc", 0, NULL); > + if (ret) { > + fprintf(stderr, "%m - Failed to mount proc\n"); > + return fret; > + } > + > + fd = open("/proc/sys/kernel/pid_max", O_RDWR | O_CLOEXEC | O_NOCTTY); > + if (fd < 0) { > + fprintf(stderr, "%m - Failed to open pid_max\n"); > + return fret; > + } > + > + ret = write(fd, "500", sizeof("500") - 1); > + close(fd); > + if (ret < 0) { > + fprintf(stderr, "%m - Failed to write pid_max\n"); > + return fret; > + } > + > + for (nr_procs = 0; nr_procs < 500; nr_procs++) { > + pid = fork(); > + if (pid < 0) > + break; > + > + if (pid == 0) > + exit(EXIT_SUCCESS); > + > + pids[nr_procs] = pid; > + } > + > + if (nr_procs >= 400) { > + fprintf(stderr, "Managed to create processes beyond the configured outer limit\n"); > + goto reap; > + } A small quibble, but I wonder about the semantics here. "You can write whatever you want to this file, but we'll ignore it sometimes" seems weird to me. What if someone (CRIU) wants to spawn a pid numbered 450 in this case? I suppose they read pid_max first, they'll be able to tell it's impossible and can exit(1), but returning E2BIG from write() might be more useful. Tycho