Received: by 10.223.185.116 with SMTP id b49csp953648wrg; Wed, 14 Feb 2018 09:21:18 -0800 (PST) X-Google-Smtp-Source: AH8x227fuwNiD//5IATZ5RlcNLB6DrYHO6e90beCQMBUSIE6wBAxV6RUydCZqjOtHuxpyjodvc2u X-Received: by 10.167.129.129 with SMTP id g1mr2875085pfi.224.1518628878762; Wed, 14 Feb 2018 09:21:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518628878; cv=none; d=google.com; s=arc-20160816; b=tj7xo7oRKMAdEDmJg69ZrgpA2XDNHe900OzAw3uLf/WnqeD2QndZhRPx/i/5hf8ZTd K54j9vN0BCLfFm8mBqdUgk4T9vK2BmbrkSqNW5xSBrYq+WnJs/FQJGfvThX/1Txsvuyw ybIvI/7Gu49O02+STYrYzDPtMRs/N9PRYFK/2TrvPEQ2m7WWLv0LJJ2vsTb4hEeB0+QW PNjZR7qD1Ilzxk9RJqklNPakb2RsqUq5FjczooTU+fmR4D4KvSs8C+EsDn0GRfiz2OqY UnjMme+FUp91XTjzo2weWBf00ZOqJfLQbyfOkkRnjJdDHHLE4/7SMC9qHVXvGQmx+LGG J3rg== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=MWIXg9tMmpwhoRHYDV94qTj7od0VzRB6SYNOg9IMjOo=; b=Fht3AnVVlzCQ0ri1NH4+aKcuNuORxD9dKzV0NsUrHsyisJwZs/MoNA33BtFX2lMHKb pH5nvmkLVfnAMFndKulyDbil849AlEioBIpicmkIsw4MS8MguuBNpLJYMCgYz7ff0c/v HoZI3qmsDOo5BQJqn6VoZiKnI468MKqtaD0hSvt2yDgAlPIeJdckvuEU7glv/M8HjLvD hz3RVQyWKK0+cu2yNsfQB/5jUPoNpJ7CSuafMjFsESg0jV318my3y0FU/UYS1HG8e1k4 Q4ijy2Kc62YWEgnUAQx/trCXD3N1O6wYgUA+BusFG3Z+41uQNEEXuv3ue1ncLK86M5oV NWvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=ClONqVrl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3-v6si1571703plf.289.2018.02.14.09.21.03; Wed, 14 Feb 2018 09:21:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=ClONqVrl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161027AbeBNRUP (ORCPT + 99 others); Wed, 14 Feb 2018 12:20:15 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:55379 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033287AbeBNRUN (ORCPT ); Wed, 14 Feb 2018 12:20:13 -0500 Received: by mail-it0-f67.google.com with SMTP id b66so16120615itd.5 for ; Wed, 14 Feb 2018 09:20:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=MWIXg9tMmpwhoRHYDV94qTj7od0VzRB6SYNOg9IMjOo=; b=ClONqVrlASTC30JHoapjpreO59iQzjSD5nuibfBX2WPBRsCOz39fFy7EbIUN571nyY 5QWRCawbK1VpEaMArFE4FG1yTkJee56aVcF4/SbRBzHBWg3eg0NaJs+2K37siqY01UXG QxMvoUuKfceM9/sCdMABtX72kyHAKUbNkiKSRAKyqbwobwZZG+VN/w4DCbfMvjlRE42M VmVDWj2K0wABAIASoeejaXr+MjyDf0qz7eYpmoXBK4itUhUzXT9R++DLwHlkJTNDMQAc kxgU6KYgikmGeK4jlj/EP8yB0J9vKy9JTnoVlJxHdXz0Dpz3YbbqzLHzb2AHQgi9ByxA 6nHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=MWIXg9tMmpwhoRHYDV94qTj7od0VzRB6SYNOg9IMjOo=; b=kp2FwlH/IYFm9axmXgLh6Kpc9BCYpYrhBPPT2GhxP0kex5xnPHh7YoqC096X/kPB7v Jwdy7QDlPlXoEEUJnot98+SSmLX0E1njueR3wf9ofhRWp3lSqN3/BSkdyehEW61m3ASi IPv7+FuP2MQVLa0J5qbyTd40AkqSC8PDKPOjJcmSeXBCkvJD6NFIWWzGj61yiCnLKi84 wiZH7F4XmvL37XOpHGHlycKTHi2Cfq3qMzg4z55GapcToLY1O0s6J1HtIG04AwDBAoP2 FpkrmujG23MyB176+A75XHnDjzv9pY5GVqMRdUgFfGkipl5zcbjxeydqvBxrj3Qy64sL AC6A== X-Gm-Message-State: APf1xPCHUFsA3ccvW1gq3EHyWGOMwNulfuJWS28FRoTudd13z3fQqbte J3IG0gzYzEO7aZcJVqlURuNyEXqIOLG8nXGzcA6QKQ== X-Received: by 10.36.8.69 with SMTP id 66mr1069927itc.132.1518628812992; Wed, 14 Feb 2018 09:20:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.137.84 with HTTP; Wed, 14 Feb 2018 09:19:52 -0800 (PST) In-Reply-To: <20180214152958.cjgwh2k52zji2jxk@cisco> References: <20180204104946.25559-1-tycho@tycho.ws> <20180204104946.25559-2-tycho@tycho.ws> <20180214152958.cjgwh2k52zji2jxk@cisco> From: Andy Lutomirski Date: Wed, 14 Feb 2018 17:19:52 +0000 Message-ID: Subject: Re: [RFC 1/3] seccomp: add a return code to trap to userspace To: Tycho Andersen Cc: Kees Cook , LKML , Linux Containers , Oleg Nesterov , "Eric W . Biederman" , "Serge E . Hallyn" , Christian Brauner , Tyler Hicks , Akihiro Suda , Tom Hromatka , Sargun Dhillon , Paul Moore 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 Wed, Feb 14, 2018 at 3:29 PM, Tycho Andersen wrote: > Hey Kees, > > Thanks for taking a look! > > On Tue, Feb 13, 2018 at 01:09:20PM -0800, Kees Cook wrote: >> On Sun, Feb 4, 2018 at 2:49 AM, Tycho Andersen wrote: >> > This patch introduces a means for syscalls matched in seccomp to notify >> > some other task that a particular filter has been triggered. >> > >> > The motivation for this is primarily for use with containers. For example, >> > if a container does an init_module(), we obviously don't want to load this >> > untrusted code, which may be compiled for the wrong version of the kernel >> > anyway. Instead, we could parse the module image, figure out which module >> > the container is trying to load and load it on the host. >> > >> > As another example, containers cannot mknod(), since this checks >> > capable(CAP_SYS_ADMIN). However, harmless devices like /dev/null or >> > /dev/zero should be ok for containers to mknod, but we'd like to avoid hard >> > coding some whitelist in the kernel. Another example is mount(), which has >> > many security restrictions for good reason, but configuration or runtime >> > knowledge could potentially be used to relax these restrictions. >> >> Related to the eBPF seccomp thread, can the logic for these things be >> handled entirely by eBPF? My assumption is that you still need to stop >> the process to do something (i.e. do a mknod, or a mount) before >> letting it continue. Is there some "wait for notification" system in >> eBPF? > > I replied in the other thread > (https://patchwork.ozlabs.org/cover/872938/#1856642 for those > following along at home), but no, at least not that I know of. eBPF can call functions. One of those functions could put the caller to sleep. In fact, I think I once proposed doing this for the seccomp logging action as well. >> I wonder if this communication should be netlink, which gives a more >> well-structured way to describe what's on the wire? The reason I ask >> is because if we ever change the seccomp_data structure, we'll now >> have two places where we need to deal with it (the first being within >> the BPF itself). My initial idea was to prefix the communication with >> a size field, then send the structure, and then I had nightmares, and >> realized this was basically netlink reinvented. > > I suggested netlink in LA, and everyone (especially Andy) groaned very > loudly :). I'm happy to switch it to netlink if you like, although i > think memcpy() of structs should be safe here, since the return value > from read or write can indicate the size of things. I could easily get on board with "netlink" (i.e. NLA) messages sent over an fd. I will object strongly to the use of netlink *sockets*. > >> An ERRNO filter would block a USER_NOTIF because it's unconditional. >> TRACE could be either, USER_NOTIF could be either. >> >> This means TRACE rules would be bumped by a USER_NOTIF... hmm. > > Yes, I didn't exactly know what to do here. ERRNO, TRAP, and KILL all > seemed more important than USER_NOTIF, but TRACE didn't. I don't have > a strong opinion about what to do here, because users can adjust their > filters accordingly. Let me know what you prefer. If we switched to eBPF functions, this whole issue goes away.