Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2309406imm; Thu, 27 Sep 2018 10:38:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV62O0S/BhOVzULarC+lVUS4+N8KPnzE+Je7SWnxjll5d3VnCU12kUjeGEjpb4vrD71+A3dcq X-Received: by 2002:a63:de4b:: with SMTP id y11-v6mr11271819pgi.435.1538069894682; Thu, 27 Sep 2018 10:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538069894; cv=none; d=google.com; s=arc-20160816; b=shrxXeS1CL1ZbVy76B9r42LphBGA0TVaL9B5tf8E6Hd7a2aJnsa31YGWUPPBhY1f3U 26ni673gHU9T+Mj4/QE5B2XWVdGbl+RT1Pm6svMohToytzkIT3tHwUPI4IyTMmwgt/co awwreawuogsqLhs3w642E332WRO2oLeqO7tMDp/HrVEXuHfQgvQ97lw9esiAiVyatlXT l8/7mj9eGFDLQV6hEFW1tbE6B4NdphDt3jFHzogr+HBwb6g1QhFb1t2KVt8cMW/MxrNd Dmp8CszCATw2r0yDEJge5Hq7ku1b12d4EPAeh1gHJYCP7pT3KO2KhvRAJat2Sx6vWA6H kjig== 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=uSpwSWwm4iMk7xqC3ILfh7UMzamZ6WABzvdm9zGzjCI=; b=FkQE6KsOWWN7/iSl8SKiKmrZDaDCxWmDizNswA5leucbuM8syr2AAjcNGOpMYicZ/R u5tmGbEZU/ZdQINHyigsVGF15MoTruYhmyy35dLQEO0HI6HdSbnrWJWo8ciRY/Tp2YOy 2G0lR9KPOoHihkibuiAoUSlXYb+jmpcxeWJLNivTAqPr/51vFFOHc8YVptGq4izVXNXx Rks1yiR0kYgtl7zE7KEuB2wjIrjU96q6HbMZ1UGD2gNoIBL05prtV/QSmFpIKmZtofp4 EtrL73BqpY0p6A5BBgy/BmAUBkhpiyM35qa+obLIwNKqrMsvw8hrQ5Fr6PwQw6CgBqtz +J2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=p6ZZDYsN; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6-v6si2368694pgo.532.2018.09.27.10.37.57; Thu, 27 Sep 2018 10:38:14 -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=@google.com header.s=20161025 header.b=p6ZZDYsN; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728461AbeI0Xyz (ORCPT + 99 others); Thu, 27 Sep 2018 19:54:55 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:37219 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728385AbeI0Xyy (ORCPT ); Thu, 27 Sep 2018 19:54:54 -0400 Received: by mail-ot1-f65.google.com with SMTP id o13-v6so3382177otl.4 for ; Thu, 27 Sep 2018 10:35:33 -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=uSpwSWwm4iMk7xqC3ILfh7UMzamZ6WABzvdm9zGzjCI=; b=p6ZZDYsNsyOUCirEtU4rYHXzhHQ/2idpj43Su2lS6tTJoyTGw1C43drN/W9dSZCU1i sDX3k6ZRxsdMW4koH2TlfC/ahCWQxSYWpg7xVxdfPXo6m3xpOkOJfFSt43aCdwhHViGK N/cd0AWnOISpmjPrAJUvYXkGghk8cpgC8zG0jLM63vmhglbDsn28QG92kDDoJYAP3WY0 xLQZg0Weol586wSVEaWyMABwdK1HnIc9ajbF/1T3ahyIDBnnfTPN39oS9e2Qau4AA9dc KyTYrvbiKPgQkz4LTucv4PZB/4vlF1NTZ8xuszqfGPhLpf0YKyDU9ONelM1ZoEcBtF2P cWhA== 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=uSpwSWwm4iMk7xqC3ILfh7UMzamZ6WABzvdm9zGzjCI=; b=Jk8rjLE21mw/SiCS1GNI6LcSmVWb/6E9u7DEnDyZN1Otz7N6d++vpUrD46B3wJ0Ps8 N2AcVgvk8M9vL6tXnYcHjJlwQZTgh7SGrxeMxxCLHqe52/5L50q+MZupDPVIj15BZYqD QGdy883W8zCMCnOIezhzHLVwV+SPH8NZDh/Tt+g6WgRkMohiOmZxUJZBoCM6MkhCsk5k MAx0LZseHCHKWxkOhFFd1l7LZ9ZFNBk5RUQALHnQlGAhxBUhyTWfLnzFk1Ikj8OCoUf5 r8I0ZRrHuK8CGozXnbHQylMnmcV7Gy4xGVbGlQY4iMgXHBecwId92Hwlxana9tnMxHEU Z0UQ== X-Gm-Message-State: ABuFfogiyxWrh+m8voeuselOrLJyvy6tfgWAuZ55xjZ2BERP9tyRbQpo KAgAk0mnvJjDv56AaTT1rBnp2SCY0z+hoBHMJlb6V/+gLxUk8g== X-Received: by 2002:a9d:2a38:: with SMTP id t53-v6mr7213017ota.35.1538069733166; Thu, 27 Sep 2018 10:35:33 -0700 (PDT) MIME-Version: 1.0 References: <20180927151119.9989-1-tycho@tycho.ws> <20180927151119.9989-4-tycho@tycho.ws> In-Reply-To: <20180927151119.9989-4-tycho@tycho.ws> From: Jann Horn Date: Thu, 27 Sep 2018 19:35:06 +0200 Message-ID: Subject: Re: [PATCH v7 3/6] seccomp: add a way to get a listener fd from ptrace To: Tycho Andersen 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 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 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`.