Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp846927iob; Thu, 28 Apr 2022 12:12:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOLUifUbBiwX0pDrHBbL0dygCB2hlvQULWk83NeTDk0VPtX16YiPgcKl0AKYD4MO5JW7a/ X-Received: by 2002:a2e:9d19:0:b0:24b:4bd:3f68 with SMTP id t25-20020a2e9d19000000b0024b04bd3f68mr21811998lji.418.1651173125777; Thu, 28 Apr 2022 12:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651173125; cv=none; d=google.com; s=arc-20160816; b=a1+92gwfr3J3DKOQc+dKiV/OS2OysNrwayM607lC96Ev0q/HVovAm0JRtlumlY9MaQ mSKdeeuXzqY1RqmRJGYIakC279G55dv9OBEQqREC9BaA6LDgmOfbJsoyj69CHBKQ45Tp HA98nXWF5ucdv9LUhEidhljWgv3oH5/vMJmji/P6sNM5LnGcL08wyq7jSrGlS342bUdl Lq+B4Wiy1o+6S3HY8grDnD+dfQAAsMPEAwJD2ZdyrUBdpkGxLWx4U56hnwlxs6pH1oSh clh8R/GDLzn6JXIVPugGXvaQT3p0lTj4QTTyrfArwPYqLW7vRBbYN0MH6MOvRD6D+2tr 5qVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=4Hm2rO8bTt2LsrgTybQvBlpYVMhdwmj3STvDv/63wWw=; b=Z+iXcuj/91m3RnqKwOS1DTJttsC6Bz0890ARXJ8Nf2rfeRzgZzqjLf/ixVWuszV1CZ 3WJbh0bKZf+jOt1ZJluV2k3fsKGWcwXAz/RLyolB2T8iFiYWuD+nhlIy+ZsSoaRjo4H0 YR9ytVMBoslookA1j7AU6YjswFChq39SwTAHu+ZmWMKCqBLt76ctOPgWPx+v8n31rXQe CHrfwGd4LCnK+h2WFbw1VQpUKJbMEqk+ZzEetzoDScPQjPV7LVz+FzZaeBe56kHYacI8 eI+FDDORG38jWDnmbmTSpMpOWhaQF5589E5HOBFxwkrp1MjeuIch9r3Iq3p9aiZaHoMh rzrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sargun.me header.s=google header.b="k6/8kKFY"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sargun.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a2e8803000000b0024dc1149ec0si5357318ljh.616.2022.04.28.12.11.35; Thu, 28 Apr 2022 12:12:05 -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=@sargun.me header.s=google header.b="k6/8kKFY"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sargun.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235926AbiD1QmF (ORCPT + 99 others); Thu, 28 Apr 2022 12:42:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349713AbiD1QmD (ORCPT ); Thu, 28 Apr 2022 12:42:03 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA18FB1AB0 for ; Thu, 28 Apr 2022 09:38:47 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id e1so2340588ile.2 for ; Thu, 28 Apr 2022 09:38:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sargun.me; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4Hm2rO8bTt2LsrgTybQvBlpYVMhdwmj3STvDv/63wWw=; b=k6/8kKFYbHCbeDhkgAQdKoqsj4vSjtq4LSrR2uZbGDvTsggui/pmFYhkEKOSb6x6I3 p7P8hrksG7ngHqR3RaVwlrmou/QCzNjnHee4V9HpaKFrjwr92Wrl2YIiLn3jE47AU4yO hkrVUXpXWoLGJwg/ikdq3YPEMcoNg3jJi8PEQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4Hm2rO8bTt2LsrgTybQvBlpYVMhdwmj3STvDv/63wWw=; b=CWRzvZ+yla7G87hdn+Kmouize691iRANmPZYi4Y6p3SJgSF2FvvJt9qCmWqKT5miGx 9ziLspNkJjBfa/X6XwCEhw3yjxs+ht/oB1/JyaCpcFkrLcqOYDxsRgvMRaRHNEYhtI5R TdB5z4Y9J0GPPJ/z1t9xXVXusJoUcCItI9eZzUZwb5wuSKoGmImdo0j6GDQbnThoj9Xt oto0JTD2KaouM5ViPjrFR6M4gYxf66lS8oWeeZ6UN4J1eTM6BvVbHyBizDA6iM2bXhdp 2lS1elocENReCi2K0nZx0wCYhPwDzgBm/F/hQoKgfmNm4434/r9J8VYzu7PVhFfsKd6A CLdQ== X-Gm-Message-State: AOAM533SMyjzSISsCrXGWb+YnxXdPOD/hJFWZM4IjiCRy/yOJy9z2uFU rMO1pRX0E6FgAsmIa5nMLvjuHMSNcHhXjrNjJhnzSA== X-Received: by 2002:a05:6e02:12b4:b0:2ca:e755:ee4a with SMTP id f20-20020a056e0212b400b002cae755ee4amr14111503ilr.65.1651163927107; Thu, 28 Apr 2022 09:38:47 -0700 (PDT) MIME-Version: 1.0 References: <20220428015447.13661-1-sargun@sargun.me> <20220428015447.13661-2-sargun@sargun.me> In-Reply-To: From: Sargun Dhillon Date: Thu, 28 Apr 2022 09:38:10 -0700 Message-ID: Subject: Re: [PATCH 2/2] selftests/seccomp: Ensure that notifications come in FIFO order To: Tycho Andersen Cc: Kees Cook , LKML , Andy Lutomirski , Christian Brauner , linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,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 Thu, Apr 28, 2022 at 6:15 AM Tycho Andersen wrote: > > On Wed, Apr 27, 2022 at 06:54:47PM -0700, Sargun Dhillon wrote: > > + /* Start children, and them generate notifications */ > ^^ - they maybe? > Whoops, this was supposed to be: /* Start children, and generate notifications */ > > + 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 It's okay if the child processes are started out of order. The test just verifies that the calls are delivered in FIFO order according to when the syscall was called (not when the process was started), and we do this by just looking at the notification ID. It doesn't care about which process generated the notification.