Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1529670ybt; Mon, 15 Jun 2020 02:41:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/sb9vohLS5Te6yAjvNbd+FOnEgcfeA3+dIuJCg0J+AWGa6j7I47b+tJ/CpYPt8iKWCcl2 X-Received: by 2002:a05:6402:148d:: with SMTP id e13mr23626727edv.200.1592214067916; Mon, 15 Jun 2020 02:41:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592214067; cv=none; d=google.com; s=arc-20160816; b=qRVpX/b70KBxQI/Ou3ghmkuJ544ZQRLnjPDblfqrBXDp+RmWPi0ya8YZPSmnEDfn/z Va1K+XoZz/y38TV4Iex0mnFv0LsnrPDVJriVwSpTe5xCXxmXu+Hn7ULGGf00HdbPcnfP rmQDC9wzxGn2i8+5qqx7cwpsnLDNISfEWrGG9X0j97nM1WW6geAf3TTwmbVgU3QsSCnU vSzDsv/D0kwWAWcE9UM6nk7DzYn99LqNeIovMAsSZVrVSfVpUv9Y+nRbujr72OjsM/9J /vuhksaI69yEn9w/hwqsUv6OvU0lpe9gsXZSWuYnoZIy8jo1zesZuvoOx1Jx8P4rQY9I mPvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=22kS9L9B/ois1Ha/GYEYnbqzF7cTylSOmt/vj8WNXQQ=; b=ck/+3Wd+2OVvVP4HqR08IDEd/9JoqAdXCvh4NRBoT21VmmjUKV6QlIAgtoyFrHBezy /Or2HXGrtBXF9k3zkkMq7l3FMe7mWoKYcOd9/GeZgVVLF5Jh6X1NJu6aFZT/svqcBFFT uxTmum2mM5aECuEmju4vl6JIdOicHoVfM7YoOceBv/VIuqhesP68yYeL15IIWtgxplKC QJ547ChtyxqmZew3oSQlF9mrWLCrSvHKokwiPLCEctrXFjBEMQvzlCWwbJVgvRgxjYPt gOh4lBLjZV5JGFyIwgwbnPpEm5G1BmhozX8IHRaWLDZNZMs0ii8ZDWvHxnDZpxzDhbTo Euuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dPc0cv+H; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s10si8601280ejf.167.2020.06.15.02.40.45; Mon, 15 Jun 2020 02:41:07 -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=@google.com header.s=20161025 header.b=dPc0cv+H; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729065AbgFOJgv (ORCPT + 99 others); Mon, 15 Jun 2020 05:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728815AbgFOJgu (ORCPT ); Mon, 15 Jun 2020 05:36:50 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 706DCC05BD43 for ; Mon, 15 Jun 2020 02:36:50 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id q19so18353234lji.2 for ; Mon, 15 Jun 2020 02:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=22kS9L9B/ois1Ha/GYEYnbqzF7cTylSOmt/vj8WNXQQ=; b=dPc0cv+HsIER0Sn1puUNnpOALEmOKBQNe6madCuFxhjtZBOpyXgMvgLh5RX+5VlOG6 nUj95LeZLpM+kpYtC51SOF1tteYW7eQUBYNBIt95FZ0xrPOqSHSmcdZgSB6wPl49xeOb A6ngEucZtEp6Fn/xm/vVIa3HFC92bDUnPs2jYfFmPz472qaN8JCp/mW7uSs70hdk+E12 z+oWtIRwRemkKEBYGiDiMonGbb0LKWFo1BMVZKBwHh2M6AX96gQG1WXvpzVHM3GaKKmV /SSUpYFjmf+rR6ZJRZJrjTgZqRahuOHotlWMtzzKEEYGr5XqXbm7F+8Uo8tRldgAS675 KfvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=22kS9L9B/ois1Ha/GYEYnbqzF7cTylSOmt/vj8WNXQQ=; b=eJsVdp/trelFaNeqq/ejHCoysUBK7RFj2IEiZd53nf1dibUdNHR0PEKTpIT4dxxXWr ThM9ejnzkDzHW1gvpSm+gfJQfOQ75eshxtnihcC6sS6QCrJQraQlGMKl8GMG6DQbFdWR dnT4TV5/Xzw6C/f0LZIY5FoQ+AngiFKqWmLMWqItaBNryWY7O+IsouPriHUzOIeGz1zn Nzr2o23kTxdZJxGjhze77h2NkosZhjMoTXiF7dWzEDY5py78eY9Epm359ps5GFMVuoHO SVBbbcqU08b9ITcYNOPSo03JMBl5uiSuTHjlsxenPXCybiTjtF3CWFwnkMwM11GbX6ws Lm2g== X-Gm-Message-State: AOAM5326Q1FOS6VYGE1yeh6BBGXyC//pPOxeWtIA+XoNas4A3ID6tIiH KM/5Cvi9N8Bq7L0HKMmXgsoLrOxOhbNujURz2mTY/A== X-Received: by 2002:a2e:541e:: with SMTP id i30mr11434276ljb.156.1592213808587; Mon, 15 Jun 2020 02:36:48 -0700 (PDT) MIME-Version: 1.0 References: <20200613072609.5919-1-sargun@sargun.me> In-Reply-To: <20200613072609.5919-1-sargun@sargun.me> From: Jann Horn Date: Mon, 15 Jun 2020 11:36:22 +0200 Message-ID: Subject: Re: [RFC PATCH] seccomp: Add extensibility mechanism to read notifications To: Sargun Dhillon Cc: Kees Cook , kernel list , Tycho Andersen , Aleksa Sarai , Christian Brauner , Linux Containers , Linux API Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 13, 2020 at 9:26 AM Sargun Dhillon wrote: > This introduces an extensibility mechanism to receive seccomp > notifications. It uses read(2), as opposed to using an ioctl. The listener > must be first configured to write the notification via the > SECCOMP_IOCTL_NOTIF_CONFIG ioctl with the fields that the user is > interested in. > > This is different than the old SECCOMP_IOCTL_NOTIF_RECV method as it allows > for more flexibility. It allows the user to opt into certain fields, and > not others. This is nice for users who want to opt into some fields like > thread group leader. In the future, this mechanism can be used to expose > file descriptors to users, Please don't touch the caller's file descriptor table from read/write handlers, only from ioctl handlers. A process should always be able to read from files supplied by an untrusted user without having to worry about new entries mysteriously popping up in its fd table. > such as a representation of the process's > memory. It also has good forwards and backwards compatibility guarantees. > Users with programs compiled against newer headers will work fine on older > kernels as long as they don't opt into any sizes, or optional fields that > are only available on newer kernels. > > The ioctl method relies on an extensible struct[1]. This extensible struct > is slightly misleading[2] as the ioctl number changes when we extend it. > This breaks backwards compatibility with older kernels even if we're not > asking for any fields that we do not need. In order to deal with this, the > ioctl number would need to be dynamic, or the user would need to pass the > size they're expecting, and we would need to implemented "extended syscall" > semantics in ioctl. This potentially causes issue to future work of > kernel-assisted copying for ioctl user buffers. I don't see the issue. Can't you replace "switch (cmd)" with "switch (cmd & ~IOCSIZE_MASK)" and then check the size separately?