Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2341782imm; Thu, 27 Sep 2018 11:11:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV63+sgF+4sk+mwieW+NTCADuP7XQ3OfCG19ys/IYsHp9v68++0P5RHZjw5s2z427Y5VM87xm X-Received: by 2002:a65:6499:: with SMTP id e25-v6mr10967107pgv.224.1538071883037; Thu, 27 Sep 2018 11:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538071883; cv=none; d=google.com; s=arc-20160816; b=Oo5gDFwM0FdJfkhULkr96ZvtXD1kLiqljIEA30VOasDp13fDEzbeA13byH0aZA99uP RIGrsiPoMASoNHeHZWrMxNEn/7AVVhMLzyMCnCFul3fTgOTGC15/lSH6J+XaDffgQXMg T9PbbETvUM3HofuITY6XJ3c56XCdPoxAPwbezvAjEJ0Df9D6FB2TFu/9xmN3DJR+kUdN FDOgqpJQB95hJLqBPR5WoCfyCFMEsr4XQ/wiZxc1xX6UoLBzhLf+EJQcQm1ZAbHVy9Qs NkeZlBDtEEfKM23rGCRAZEgobKJ4dvzPll2kf0AXqgAk2exJpvWKWzgz6AtfSPu/pfjf mt/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=g3nXO2b01c3gJjfiAhZLNr9nLLCLhOURHg4Sg4kcG4s=; b=KpM5sk4SJxUIrwo9UXYeHm1bMW7WYY18mHb06WfQQZB0wurctQ50mLLEfK9DAn5bp4 6+/cciitQ8vuFg4lmXqgTS8JHxUZK5wUfoInJCoJUWI9QHjxc03b0chGR46trIvghwhp j+u6Y8eJ6hZSIJ0s0Ga6z/YxDrO7QsbVlcUMx/nXqhs9u+lGkT9jM9JOEOUifbXiFZos dv7obtee825VekjlBimQkrd+sY0PvMzFKeI8t9sAS5tOvcLzG4S8yyhijAunRma+6y4s AGGDdN7i14SmK0n1mv5xuVLTfDv3AovRy81jjQsXNgFMo4iSziNJSHvbM3rJSiiS8+Wf j1ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=lhgOjqtf; 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 ca2-v6si2795716plb.480.2018.09.27.11.10.41; Thu, 27 Sep 2018 11:11:22 -0700 (PDT) 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=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=lhgOjqtf; 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 S1728298AbeI1A3M (ORCPT + 99 others); Thu, 27 Sep 2018 20:29:12 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39795 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727307AbeI1A3M (ORCPT ); Thu, 27 Sep 2018 20:29:12 -0400 Received: by mail-pf1-f195.google.com with SMTP id j8-v6so2463363pff.6 for ; Thu, 27 Sep 2018 11:09:43 -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:user-agent; bh=g3nXO2b01c3gJjfiAhZLNr9nLLCLhOURHg4Sg4kcG4s=; b=lhgOjqtfP50FOb7jR9pEGHFRtolEYBWkkjgyg6FK+W+vIQqjEDGVk9MTBBcz7Lct46 Xhq9cXSdbARNUu6AOUv5CaNIWbAYXRKWB73sY4SUHASQNBXs3lo47OWVKF9BYOAziDsB opag2ZwWF0Bquy1n9znMpoI7phSNuaTK0SB408YxWCHP8x5MVGZO9xGHWWk0HhGAVNG/ zrBi6ul72CIXcYsfsMLNAYN2QRTgGovl7UzzHIzCwhYJXWfCl95SKmJDDSCzI6NX/rMI 3NY2ZUMwEkmOEPHOQz0Y8ZNPqw46tsavqVRX32RgRHerkPdvqew2VMOflCweeZ1HZa2J y91w== 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:user-agent; bh=g3nXO2b01c3gJjfiAhZLNr9nLLCLhOURHg4Sg4kcG4s=; b=KZSUVcJUTGKRZvtZ+Wa30fuoI2yJqYq3N1iTGYCD0MJQzMbT96GPU9FglA05FLzBKH FOGrtP3TiwaRPzt+sujUy3dZTQI0JUbkFm7Jgq13u1tSVMZYH84QpsQvygljNWweGkaM 4IZAafL6UutVpFhqN04njyFDWAXZbN034mgwJMQxwdXe2la2vSSbyn8oLPRcl5gADyxo UwiWPEyPaJyj66+z9+Z72Ba8b9ncbDrjf99FzGhArhPjaK4vIsxFkxLpBT0gvPWWE2Yi D5Q0AVxI0hLjLwRSI3Av8ghgbThQ8pU59BKbn4dt7Njm6W2Yoy9Bo6r9bXAXZwFm5DTH psYA== X-Gm-Message-State: ABuFfohLWxJG8rio4XIduCpwhCB1lvHOvg4kpwwzisdNYx06dVKL0mge lLi1fdNTtrCj1567e6UUV9J1og== X-Received: by 2002:a65:448a:: with SMTP id l10-v6mr11559978pgq.382.1538071782786; Thu, 27 Sep 2018 11:09:42 -0700 (PDT) Received: from cisco.cisco.com ([128.107.241.165]) by smtp.gmail.com with ESMTPSA id 71-v6sm4018217pfx.182.2018.09.27.11.09.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Sep 2018 11:09:41 -0700 (PDT) Date: Thu, 27 Sep 2018 12:09:39 -0600 From: Tycho Andersen To: Jann Horn Cc: Kees Cook , kernel list , containers@lists.linux-foundation.org, Linux API , Andy Lutomirski , Oleg Nesterov , "Eric W. Biederman" , "Serge E. Hallyn" , Christian Brauner , Tyler Hicks , suda.akihiro@lab.ntt.co.jp, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v7 3/6] seccomp: add a way to get a listener fd from ptrace Message-ID: <20180927180939.GB15491@cisco.cisco.com> References: <20180927151119.9989-1-tycho@tycho.ws> <20180927151119.9989-4-tycho@tycho.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 27, 2018 at 07:35:06PM +0200, Jann Horn wrote: > On Thu, Sep 27, 2018 at 5:11 PM Tycho Andersen wrote: > > > > As an alternative to SECCOMP_FILTER_FLAG_GET_LISTENER, perhaps a ptrace() > > version which can acquire filters is useful. There are at least two reasons > > this is preferable, even though it uses ptrace: > > > > 1. You can control tasks that aren't cooperating with you > > 2. You can control tasks whose filters block sendmsg() and socket(); if the > > task installs a filter which blocks these calls, there's no way with > > SECCOMP_FILTER_FLAG_GET_LISTENER to get the fd out to the privileged task. > [...] > > diff --git a/kernel/ptrace.c b/kernel/ptrace.c > > index 21fec73d45d4..289960ac181b 100644 > > --- a/kernel/ptrace.c > > +++ b/kernel/ptrace.c > > @@ -1096,6 +1096,10 @@ int ptrace_request(struct task_struct *child, long request, > > ret = seccomp_get_metadata(child, addr, datavp); > > break; > > > > + case PTRACE_SECCOMP_NEW_LISTENER: > > + ret = seccomp_new_listener(child, addr); > > + break; > > Actually, could you amend this to also ensure that `data == 0` and > return -EINVAL otherwise? Then if we want to abuse `data` for passing > flags in the future, we don't have to worry about what happens if > someone passes in garbage as `data`. Yes, good idea. Thanks! Tycho