Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1388786iob; Fri, 29 Apr 2022 04:31:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1Lxm7lCdQP70sSKRdgB7NEbvB6869vE+y3gQg2EbtJlRtR9isuke7uGlT6uFPcNzEawTg X-Received: by 2002:ac2:544a:0:b0:471:f568:59d6 with SMTP id d10-20020ac2544a000000b00471f56859d6mr23168499lfn.492.1651231917507; Fri, 29 Apr 2022 04:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651231917; cv=none; d=google.com; s=arc-20160816; b=pG8MvCaQGvP6ad79LHFoP2+rRdO3Sp1K3klLrNHeIQiD+HvTB66uoqiYa9IMIqFu0E lPmslu3NJ3OCDOnZqoEWgPibnl1xYt76WnKj+Id0wnnbaPf0k+MTuGC3E4Q2csL+o3QP TqofvtppquRczm4w1ovza8sd/aHAtR9pLbBIz+p06xuXaLz/jjdifFJxoiFcpENidAb5 uwGHdlta2gk4nobWCqIEmo5sCXeFYfMD3IaWiYgOsE6XXG9V8U+B7K/7w9wGQFRvAE8q GuGhwfRPnb/hrce0VZIrMJN7VGee19t+Z4vg6505GJwCqEEV0A9MjMzUO9aSvn0dwhf7 OwSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=zddeKWyxC/TAt6LDXLxofwc+G7l0sx6z+g7NouKJEpY=; b=SYSZqCvEau1JV86PYnkC9p/dcXi5SNT9IM0yazQJaLTxGUB4m/wgJABWDxwM6/F7b0 Q9r0TA3j4cTe2w5utNsg9pP+ZmCnOcJfyGzS7M2r4eZYxitebOmY/QKwkHvLmIfqVBJ8 ctut77aFm4nMNinp4oFuI1i7NYHxgk89VIZh09FSaduiAokrNmKQUGKRglt7N5sZYbQJ Li2apk0cZefPFvNBp9LLMyqy5VlV4HCAe/OCv58wQVbSSEIX5Uf3EFhUvac5+4xK5v3S 45dsat14BQ2qiNQo6xCrWQqHe8Wr58pbs7UUradpu7ojb3Rf9/umlEeMxLdSgSCJbfUL Y0mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm3 header.b=XmJyvgZY; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=IgEBqwoi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x15-20020a0565123f8f00b0044a155b027dsi7426979lfa.193.2022.04.29.04.31.27; Fri, 29 Apr 2022 04:31:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm3 header.b=XmJyvgZY; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=IgEBqwoi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346881AbiD1NUC (ORCPT + 99 others); Thu, 28 Apr 2022 09:20:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235700AbiD1NTZ (ORCPT ); Thu, 28 Apr 2022 09:19:25 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 545753B57C; Thu, 28 Apr 2022 06:15:56 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id D93E35C0107; Thu, 28 Apr 2022 09:15:53 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 28 Apr 2022 09:15:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho.pizza; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1651151753; x=1651238153; bh=zddeKWyxC/ TAt6LDXLxofwc+G7l0sx6z+g7NouKJEpY=; b=XmJyvgZYy9VnIeFSXqe6ON9sGj SUWWb886ONya30ixz9byMgApEglKBPm2RzI4wRIyyDHRJAYzRvTgayuzQAikeQCT 3ngIKtsePx99rDKawU9bPkVOboVNdQNJTBaiqgWWQPeGGd5oPXjIQVakIL1qf8Zd HM4lc180HPJZZWGNfYOZTjt4+TBYo/OjaESZ83VDsk9gVQyBSGinuX/cJsraKsmo YkeWN4JBjq2M6/5TkGgipNb1+Y83lL7ljqsWGNIvA/6C+Z6bBqkxp0/dT11+OKyI 6ur7nL0NOTdvYHB7e0R30wB4b5PjzDUoriYY920qZOMwaBNPlGfWDM/ec+Bg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651151753; x= 1651238153; bh=zddeKWyxC/TAt6LDXLxofwc+G7l0sx6z+g7NouKJEpY=; b=I gEBqwoihU7BZ0GC2y1S+qih7WZL4iySYd6Qg+QEPbyCiHymKVZekKQQDwAk20QtU 046UCTfKSLM+cQIsoqrK8Ui2iJQFe1w8C3/K6nL+uaim8aedz+4as+vr5HnnzXSE v9VgNFYbfSxtHgyoO4KNXbL5jOcJQ+QMt/j7qr944pDVZOKFgN4kUpQ5cJL5laKV cf/epzYtpQ4Tuf+K/GcGcPgGBvqFXd2DEs2dPX0eo3qhq0zt6Fk0+cviLS1yhxni p+uFOrhzJU0Gsy2tzXwsrybH8RIUVF6tWC9gb5K+a8BuZ1VhfIkiFemZRKHL+aLz tIPzHJlHPvol9KoKkOGjw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudejgdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefvhigthhho ucetnhguvghrshgvnhcuoehthigthhhosehthigthhhordhpihiiiigrqeenucggtffrrg htthgvrhhnpeeutedttefgjeefffehffffkeejueevieefudelgeejuddtfeffteeklefh leelteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hthigthhhosehthigthhhordhpihiiiigr X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 28 Apr 2022 09:15:52 -0400 (EDT) Date: Thu, 28 Apr 2022 07:15:51 -0600 From: Tycho Andersen To: Sargun Dhillon Cc: Kees Cook , LKML , Andy Lutomirski , Christian Brauner , linux-kselftest@vger.kernel.org Subject: Re: [PATCH 2/2] selftests/seccomp: Ensure that notifications come in FIFO order Message-ID: References: <20220428015447.13661-1-sargun@sargun.me> <20220428015447.13661-2-sargun@sargun.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220428015447.13661-2-sargun@sargun.me> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 27, 2022 at 06:54:47PM -0700, Sargun Dhillon wrote: > + /* Start children, and them generate notifications */ ^^ - they maybe? > + for (i = 0; i < ARRAY_SIZE(pids); i++) { > + pid = fork(); > + if (pid == 0) { > + ret = syscall(__NR_getppid); > + exit(ret != USER_NOTIF_MAGIC); > + } > + pids[i] = pid; > + } > + > + /* This spins until all of the children are sleeping */ > +restart_wait: > + for (i = 0; i < ARRAY_SIZE(pids); i++) { > + if (get_proc_stat(pids[i]) != 'S') { > + nanosleep(&delay, NULL); > + goto restart_wait; > + } > + } I wonder if we should/can combine this loop with the previous one, and wait for the child to sleep in getppid() before we fork the next one. Otherwise isn't racy in the case that your loop continues to the next iteration before the child processes are scheduled, so things might be out of order? Maybe I'm missing something. In any case, this change seems reasonable to me. Tycho