Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1605045pxk; Fri, 25 Sep 2020 21:37:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFsu1ziWOUlJOF23kYDm5TBkXXNshCZx+AhaktaWKBlUT2zK6DtGvgCNATgDnu+nEqx0/n X-Received: by 2002:a17:906:2301:: with SMTP id l1mr5742688eja.488.1601095049636; Fri, 25 Sep 2020 21:37:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601095049; cv=none; d=google.com; s=arc-20160816; b=M87AZ4VWF/PDwYw3OpaNBttnE+QuKcqSdTa1Q5mhTKudMdK3QxJ3OP9s3BTsxmQN1d 7BBwgDLnGPnCQsnfaUyGVgtlEDeKgDSl9ENJHVxUDxdT0TtHSfBAXXk66/VclSJn2usq KknSLyMCV0thfdjYn2bznmtiJ258NRhehWRW6nOhIGYWxuHDA81dBt/HKjZXaud4agOI /IRJHFsbwZLtMSXC7U6wliUamULbmt8NAINJHesK/vBtpKjluyVpmil4ljzwyv3Cr0ec /ccd3SK/FPNb4Z8Fwv1jAVsFZNgHsYG5Ae3c1dDOPWP2+AgjDHBiKjBNDavSHciwZCiv 7w6Q== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mRcwOzZAXRqD5t0WunR2xZRGQlJgJ5v6Cl490f6L2w4=; b=mKPL5Azz6IGYMB2QC8EK09SataoK5TbDOLpUqKG7D7XrXBc/8c3W6kVq9k99T6iLv8 hsdQV1iSHh10M1GD9eL4tOT8Hng5cYMiKVBd+tp0I/1icmak+cWFOA79hnbBTT+S3OqJ 4yfOcluowAwBipsY7M2umwXPb0QGFT9L3LBVSUD5lqwn9Vb5r2puz5AQg/HaSuq7KabY F5dcuj0zBaUYQnqhsgoY83c7nSyZ7n/XuDCuCbnS9QSEO9Umd+85TLZXJBrX2H+DAMs3 uQE8MmsoBKoMqiYVKMKltzIoCNXfmsRFRUqfZJ0iPGZuseI9X3JkE31xFfKqPOMyI13Y sfpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TWHocp6X; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p9si3089974ejy.150.2020.09.25.21.37.06; Fri, 25 Sep 2020 21:37:29 -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=@chromium.org header.s=google header.b=TWHocp6X; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730036AbgIZEfE (ORCPT + 99 others); Sat, 26 Sep 2020 00:35:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728193AbgIZEfD (ORCPT ); Sat, 26 Sep 2020 00:35:03 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A69E7C0613CE for ; Fri, 25 Sep 2020 21:35:03 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id t14so4144911pgl.10 for ; Fri, 25 Sep 2020 21:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=mRcwOzZAXRqD5t0WunR2xZRGQlJgJ5v6Cl490f6L2w4=; b=TWHocp6Xnlj+Fal/pEAcaz9wDHWf5v8XigHCHnEgYkDAlglQrvdlT3J1d4RmRbUM5G oWQjXg12yMjV+3i57IYSebyR+e7kdcE8TnPGHZXUJLngz9RYIkHXBP8k0L5y0iuLMbmS G8h+pUUY+GNQEWLdLBFvHdE3ncAEFTwNfZnkc= 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:content-transfer-encoding :in-reply-to; bh=mRcwOzZAXRqD5t0WunR2xZRGQlJgJ5v6Cl490f6L2w4=; b=lEHREl8EvyrhkuZn3D+s6jo/XmZgCOgMM/gyX3z0vS9LLv7G0R4TNkhX7B1wKuJRHX HK8U/Spqw+Tuh21bLLkhquuvyopQ7ZrN4O1Z7xaoZ3k9h6wDzANlX+SPJX9NHgSqYbnB 7hyyXxeIpIjI0yerAnaCsJKVJRWwaWH5AVDSg+wbVFb/3GHouek3tGv+DhM6+zl3Ir8w +6ryN6eSVw8ooWeXfbl90qhpZtsY7gk8Bftreh8YZSWXGuX4DxPnEUtyvfoYG0axYmql apz6Cx26E7j5jvypgwe+Z64QgrCHbIe+rAQb0YV8AXGmoRA6ySnria2yGoYxf8FtcvDH +5Sg== X-Gm-Message-State: AOAM532A41aEnEx84h4foIOr6Ki1aeXHOqBoT+LQkSg1bBHxyR+Sy5nP DB8jYfU87akII5W2jOvVH8uq9g== X-Received: by 2002:a65:615a:: with SMTP id o26mr1648183pgv.54.1601094903117; Fri, 25 Sep 2020 21:35:03 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y202sm4057138pfc.179.2020.09.25.21.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2020 21:35:02 -0700 (PDT) Date: Fri, 25 Sep 2020 21:35:01 -0700 From: Kees Cook To: Andy Lutomirski Cc: YiFei Zhu , Linux Containers , YiFei Zhu , bpf , kernel list , Aleksa Sarai , Andrea Arcangeli , Dimitrios Skarlatos , Giuseppe Scrivano , Hubertus Franke , Jack Chen , Jann Horn , Josep Torrellas , Tianyin Xu , Tobin Feldman-Fitzthum , Tycho Andersen , Valentin Rothberg , Will Drewry Subject: Re: [PATCH v2 seccomp 3/6] seccomp/cache: Add "emulator" to check if filter is arg-dependent Message-ID: <202009252134.871EFAB61@keescook> References: <05109FF5-65C9-491E-9D9D-2FECE4F8B2B0@amacapital.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <05109FF5-65C9-491E-9D9D-2FECE4F8B2B0@amacapital.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 25, 2020 at 07:47:47PM -0700, Andy Lutomirski wrote: > > > On Sep 25, 2020, at 6:23 PM, YiFei Zhu wrote: > > > > On Fri, Sep 25, 2020 at 4:07 PM Andy Lutomirski wrote: > >> We'd need at least three states per syscall: unknown, always-allow, > >> and need-to-run-filter. > >> > >> The downsides are less determinism and a bit of an uglier > >> implementation. The upside is that we don't need to loop over all > >> syscalls at load -- instead the time that each operation takes is > >> independent of the total number of syscalls on the system. And we can > >> entirely avoid, say, evaluating the x32 case until the task tries an > >> x32 syscall. > > > > I was really afraid of multiple tasks writing to the bitmaps at once, > > hence I used bitmap-per-task. Now I think about it, if this stays > > lockless, the worst thing that can happen is that a write undo a bit > > set by another task. In this case, if the "known" bit is cleared then > > the worst would be the emulation is run many times. But if the "always > > allow" is cleared but not "known" bit then we have an issue: the > > syscall will always be executed in BPF. > > > > If you interleave the bits, then you can read and write them atomically — both bits for any given syscall will be in the same word. I think we can just hold the spinlock. :) -- Kees Cook