Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3323956ybk; Tue, 19 May 2020 01:34:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxulmI9QBwtBswPw16HqMyyWEf3gqgOiynIwmphaH+ZyNqEea/mnVm+xHxqhrOLjtbWxY+9 X-Received: by 2002:a17:906:68d2:: with SMTP id y18mr18669216ejr.248.1589877295100; Tue, 19 May 2020 01:34:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589877295; cv=none; d=google.com; s=arc-20160816; b=dtEDQS0ogkijRFvllwPN1nyolHnwtKbic1ckgJjCr/2FgsrTdPLiHZwEEDVz72OIbn rfXaC8Gy7hFxep9AlIIFtW9+D3V4BgBqLa00GQJOW9zpyoogEPKt63il3YsXxDfHT+cg 6LrWAccTAukVoAu9IdW2V944SxTegXaLW/fYJdMLL95ZXd2Hn4uMrs0OXT8b3cy4Pwo7 vIimWnQVFM8chElWtnrhLKIepO5weYqPUPcQoNP4+20Adou83u5sJrgc0M9qTxUYAPK1 9/C5+ZKg3bbkOtGPcEIBJBzwtBxIyb9PtBB5HtK1xs5OZnGtolwOxh+9sDsyCpXUgIKK mpqg== 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; bh=xfeBUdrbUy7Snlwh7HnYdus1eJbQ9XoW5raS8wFw7fo=; b=mnPvUYbo8VDYtRS2ufLY4Aumur4/8own39y2DlaKKDdntWd16CETOq2BU5lc4W8FX7 nLFfN90L3gdKNyLeETbUKXL7MdhXfAm9G+qBYg7u1qSTrXqbG6r4LZhFN3XgV71SLOc1 OwI46UvGNf03ZSPnFKehh00wTKTTcddSy8GmdC++vFVJ1o+1Lp6b3hr9nD43dPWBmpZ4 qB0hUfaxpjCY3wMDh6KklEfgSv3mQfjDg7t/hmwh6o2qqthTRo++atg0fXB4mWo0tro2 rgJqtx8HG4AY4SNl7yhQVgixIKGs4gdLJRehTRap5dweBWRXw1/GzmYFQWC3uZphNDuI z7OQ== ARC-Authentication-Results: i=1; mx.google.com; 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 93si7671163edg.247.2020.05.19.01.34.31; Tue, 19 May 2020 01:34:55 -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; 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 S1728553AbgESIau (ORCPT + 99 others); Tue, 19 May 2020 04:30:50 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:38751 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728456AbgESIat (ORCPT ); Tue, 19 May 2020 04:30:49 -0400 Received: from ip5f5af183.dynamic.kabel-deutschland.de ([95.90.241.131] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jaxe9-0002B4-6Y; Tue, 19 May 2020 08:30:45 +0000 Date: Tue, 19 May 2020 10:30:44 +0200 From: Christian Brauner To: Sargun Dhillon Cc: Jann Horn , Kees Cook , Tycho Andersen , Matt Denton , Chris Palmer , Jeffrey Vander Stoep , Linux Containers , Linux API , kernel list Subject: Re: seccomp feature development Message-ID: <20200519083044.lo5d22hdd5nc3dcm@wittgenstein> References: <202005181120.971232B7B@keescook> <20200519072451.GA3128@ircssh-2.c.rugged-nimbus-611.internal> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200519072451.GA3128@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 Tue, May 19, 2020 at 07:24:52AM +0000, Sargun Dhillon wrote: > On Tue, May 19, 2020 at 12:39:39AM +0200, Jann Horn wrote: > > > For user_notif, I think we need something in and around these options: > > > > > > - make a new API that explicitly follows EA struct design > > > (and while read()/write() might be easier[4], I tend to agree with > > > Jann and we need to stick to ioctl(): as Tycho noted, "read/write is > > > for data". Though I wonder if read() could be used for the notifications, > > > which ARE data, and use ioctl() for the responses?) > > > > Just as a note: If we use read() there, we'll never be able to > > transfer things like FDs through that API. (Hm, how did I not get that message? Weird. :)) I hope we won't be able to receive fds through read(). This quickly becomes quite problematic, I think. > > > Although there is no good reason for read being able to receive FDs, there is > precedence for recvmsg being able to do this. Either way, I do not think Right, and recvmsg() is quite dangerous because of that because you need to be extremely careful when e.g. the message is truncated and you want to error out and you need to carefully close all fds and other shenanigans. Also, recvmsg() imho, is a bit different from read simply because it's sort-of a "typed" read; it's plumbed on top of a message protocol and that protocal includes the ability to read fds. read() on the other hand is completely agnostic and doesn't care about the data at all. But that's just how I always conceptualized it... > it's a good idea to recv file descriptors, and instead file descriptors > should be fetched via the pidfd_getfd syscall. +1 > > Injection is more complicated, and for now, I believe that "writes" should > be done via ioctl, or in the future, something like sendmsg might work.