Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp791257ybm; Fri, 29 May 2020 12:14:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY6OWEZfSE/Sq1iYNzJd+Tp+5nxtT4iauuzh99hzIf2kqfIQltT1oK7zKRFIObZsAATFL+ X-Received: by 2002:a17:906:17d1:: with SMTP id u17mr8861300eje.242.1590779653969; Fri, 29 May 2020 12:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590779653; cv=none; d=google.com; s=arc-20160816; b=pizeQYmAmr1CEubWl/QtaXf4oU/e4CjbcjZE7lA933pLJJDVUAMGYIgNU5cQxNJe2N NKuKE9GcwHqMo2DeoV4WLUHCcaUG8HqzLyQsrAnlqKB81uKa5BVt7RWqvWHEQLLapJ+1 zICWId6XDXAXKoGyGjcsB8E4Es7zps7h/mAja6jUrKALpEQC2D7BJw1aTyedX8zLFnDI o/5SAQq41adjJhCXf+um7CR+3snwPrM4134ISZsXtN6N5oW/W+G1Ml/wlTEfzf6lG/ky u6OB6VJTrLjF0mTs8nIK/ulNCguGgFWaZ+4OvrlREqukffyT75vnfKPPvl+cixNzXaO0 NmQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=decs9gKQoFUz0IqtIufOW8Or3y9LkMuKp232OBe14mU=; b=Nqb+2vaiGDYerzlzLzxHk9iG83DiwMAyADYqWDXs2XS97exQoafwqi7p9ZlAHgWttr TuavlmMWgrG8/mizCvWYfxX/x3MHrxnbXLfrY7qYA/1YEJNWReowi2zEKJGn2uzczyNV CFg+GPd22EL3zaStCNHYvRh2pUqAJW6UjAA1Gn/LAy89l1XMhDrQvndTNqJtVivBWVqw acSeh0rLRSJOeqqE0/J6XmxABBZGIjqysJ7qo3/ymL3QkDPqMWaeHriSYxjzr26bTX07 GEfSgERgHiAJvYJtyPry8k3VAt03sqwIO8sjfmZqzesr9ywkNA1/YcnhkWbkK/MbliY4 rKMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=eWDAuFvh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d7si2848867edz.12.2020.05.29.12.13.50; Fri, 29 May 2020 12:14:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=eWDAuFvh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726901AbgE2TMD (ORCPT + 99 others); Fri, 29 May 2020 15:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726549AbgE2TMC (ORCPT ); Fri, 29 May 2020 15:12:02 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08F4AC08C5C8 for ; Fri, 29 May 2020 12:12:02 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id fs4so1911974pjb.5 for ; Fri, 29 May 2020 12:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho-ws.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=decs9gKQoFUz0IqtIufOW8Or3y9LkMuKp232OBe14mU=; b=eWDAuFvhZ08VeODhDiZrHCV0mEXsZEFVfJD5PJVxkwOzzUNwXhVnUBgtQQ6rFLGkSr /8YSN7+sVQCXA2mmJX/69E3rHjwJpjXHfCugaFZpsVtF4wlgic/bCNL/bp6qKO3cEc0R uX8OsB7tnNqNPrnf6hOoxDQ/nbd7AChkqmjV8JuycZQdlxORs9TYPUtZASzVlWPKxeCw tj+QZhCzKcnCy/D6NI39VojxtI9UGo7jm9HYLBww1TbgvxGYCPrmxY+F6St48W8P8bCb PNqp2lVnzbBnos/ITs+YF3TYIIfHpBrzDvdZ0vXfwj03poUCA4/atK9kfYGNulkPx8nv nRmg== 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:in-reply-to; bh=decs9gKQoFUz0IqtIufOW8Or3y9LkMuKp232OBe14mU=; b=NXNZ72sDN4sck0lAgmS3Gw1U4ev/X9YAsun95YkGu89CbcxkiUT1JhxmmvPsvT5MQP 4jZgKBg25pzmIuYTpzTNOF/HT8GI4dNbL+ZiMmwTmAc94fTDcP6Daydp5MuNvVIYW++0 hyCYYGY2mBAybo1NSmrLu16dBsk3TVxnASteoT1IWmJS7xQIVyf50F/3Kt+md3DJbzFy zM27vRZct8w3EbrIb9bAcbfej+Khns0w3oUvZ6LlzX9QP5bG0h4SsTbpfonsSXgn7ny+ DI3aknfBIyip4iYQ/15izJWEMDCcjjCT9uYOxAuaebWUqg7nBY6KhvA3/bwBGJlntkqM CbSw== X-Gm-Message-State: AOAM5322aWuG+QoYV49vw4HNHgjXZC4HUS0cxZ2I8qU1zTd8ST08ItG3 2vv04brp1x6Xh6nFND9CyS/MqA== X-Received: by 2002:a17:902:9a08:: with SMTP id v8mr9901638plp.90.1590779520978; Fri, 29 May 2020 12:12:00 -0700 (PDT) Received: from cisco ([2001:420:c0c8:1001::961]) by smtp.gmail.com with ESMTPSA id y65sm8038790pfb.76.2020.05.29.12.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 12:12:00 -0700 (PDT) Date: Fri, 29 May 2020 13:12:07 -0600 From: Tycho Andersen To: Sargun Dhillon Cc: Kees Cook , christian.brauner@ubuntu.com, containers@lists.linux-foundation.org, cyphar@cyphar.com, jannh@google.com, jeffv@google.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, palmer@google.com, rsesek@google.com, Matt Denton Subject: Re: [PATCH v2 3/3] selftests/seccomp: Test SECCOMP_IOCTL_NOTIF_ADDFD Message-ID: <20200529191207.GH429721@cisco> References: <20200528110858.3265-1-sargun@sargun.me> <20200528110858.3265-4-sargun@sargun.me> <202005290036.3FEFFDA@keescook> <20200529184606.GB11153@ircssh-2.c.rugged-nimbus-611.internal> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200529184606.GB11153@ircssh-2.c.rugged-nimbus-611.internal> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 29, 2020 at 06:46:07PM +0000, Sargun Dhillon wrote: > On Fri, May 29, 2020 at 12:41:51AM -0700, Kees Cook wrote: > > On Thu, May 28, 2020 at 04:08:58AM -0700, Sargun Dhillon wrote: > > > + EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_SEND, &resp), 0); > > > + > > > + nextid = req.id + 1; > > > + > > > + /* Wait for getppid to be called for the second time */ > > > + sleep(1); > > > > I always rebel at finding "sleep" in tests. ;) Is this needed? IIUC, > > userspace will immediately see EINPROGRESS after the NOTIF_SEND > > finishes, yes? > > > > Otherwise, yes, this looks good. > > > > -- > > Kees Cook > I'm open to better suggestions, but there's a race where if getppid > is not called before the second SECCOMP_IOCTL_NOTIF_ADDFD is called, > you will just get an ENOENT, since the notification ID is not found. Ah, I see. The goal is to test the -EINPROGRESS here. If you use write() instead of getppid(), and write to a socket, will that work? The parent can block for the read, and once some thing has been read it can test for -EINPROGRESS. The user_notification_signal test does something similar. Tycho