Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp699492imm; Thu, 6 Sep 2018 08:47:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZYxRJYv0FOvrE8j0lBoBCrVfv8aIDT+mpAVniVCSiv9w4Mzhlp5vT5raTbaJj1s9v1kGQ9 X-Received: by 2002:a17:902:5a4e:: with SMTP id f14-v6mr3333502plm.311.1536248867117; Thu, 06 Sep 2018 08:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536248867; cv=none; d=google.com; s=arc-20160816; b=DjDPN7HR42bfdrxSxBlrb9ljnLI8vMTJlR49b/WYvDzlMZ35Y9lbxpAiQP/rfFIAJK 4pZgMH1MRapeKInzwxsVknjVGUueH/TUI14A6okFHG8sOkl/am+1WmZotH/mYY1yijFD pIhlOA+VsH3usWKcIWEwdEXLZ7WtT0Aepwe0kOcYaZd000k5h92Aih+5APJ6c7u+g54r J5gTQAIqofD3W8VmSJhLQjotvCMUx4P8cvIFeoq5JiIK0NNVSRN9jBfOTb4TK/qPWtIS 6V4mZ4683s7xfZ9YNQL+4gW3fL9vYArvW7FLAOtiBiMY38M/jex3YikT0pp85vK6iqlG 1V0Q== 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=SCF/qGOGTlsPnERb2AnClt8bZvvrNKHSZvr5ZA3FL0k=; b=V0dS9zk+bXerah227TvR2zuSHHP8+N0f7dxVJgXcJekbFBumZtANv9gxlXDd0pYcsz eL6wkXb0KS7ZK5GuEFTNhNF+n6mUrBVDTvM2SAVeufskwIybs1Rtm8554ZsZ9gCmjbAJ CTZrb6vrswjlpvOmOMN3gzVTGvgb73+PNPXh9SUiq2dh/7zKFiBnBRI5dLSWsDGmYvPN 55CjauVO593l9xzUtOdoIeAcQa5zxt7J0FS9Gs3MSQCbYueA1wAJt2hclCUDPOUv4w2e MUvMwSam7eeQW+VP4Et+sLxnTCGNj0we7YsMkB+mYFPLMDHbEaoRP8gXIYHJAlwrQIOT j1HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=aa57Wlz1; 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 gn24si5058428plb.43.2018.09.06.08.47.30; Thu, 06 Sep 2018 08:47:47 -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=aa57Wlz1; 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 S1730272AbeIFUV6 (ORCPT + 99 others); Thu, 6 Sep 2018 16:21:58 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:33854 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728047AbeIFUV6 (ORCPT ); Thu, 6 Sep 2018 16:21:58 -0400 Received: by mail-oi0-f66.google.com with SMTP id 13-v6so21494064ois.1 for ; Thu, 06 Sep 2018 08:45:52 -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=SCF/qGOGTlsPnERb2AnClt8bZvvrNKHSZvr5ZA3FL0k=; b=aa57Wlz1qcEqmNezU9oMI1c4IduE1+jZlS4oLQi3GhO8k0luazSwPnf/itreCnQuWC YvBc6yxiLs7EXup3uizv3vOekIITSlftGLa17iQXpH/qiqG8PCSvh50H5psGWi99LR+8 HdVivpK1pcFozuqMzOTsyJLdAwbSw2wl+Fwl9rgjvMvwi6qnDrzIFU/4D9dn2mrb2A/p d8ub7R/71qIZX92wWBLNURWs6h6la6dS2Z9YA+K1nEDJZeGtzLkRlMsi6mjS/u45g+MV rQo1QkOvTZXB2kqehGeOC85po2j8QsLDmBhXUy3mU/EfaRm5j1IJzNw+EYvwjymRwWuf ELxQ== 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=SCF/qGOGTlsPnERb2AnClt8bZvvrNKHSZvr5ZA3FL0k=; b=RsnKFwaqAVN0XeEWjg9czWIMyxrb4PnCssH5kRlH0BMArKA8d4yx6GK4pY5Z9taKcL rtq61q8HrVExBAzripsdkPVxj8oQIvN+AP8eNX1exxWyO02L5voUUHet0rBeYaf6tX4Z Yn2X0M4Wq+A16SqQ7SjfW6lgH7YD1AYdpz36ffGwpBOz1Zu8KKQZRZ1/uiWozjpHUMom 1kdmkvKixpCDgT/CdBBYGrfLF2s/cE2YcDouEQcAkpcfT8nJNqvmN8knGgqmZ0PYUgsA T6DRS5xBt+BFaqL4yb+jG6BQyhsrM9jBoGRxPoVfoQ8G4eDLl7X6L7bnxVvs+3RbbMOu Ws2w== X-Gm-Message-State: APzg51C+EbS7qmB4WHx2v1Qi7TyIbXAwaGep5IdzSMc3fDChi9pZDt4z dptIgEuDIv2dWdothJwF9vIXOWnGFG7ohbdwSA9BYA== X-Received: by 2002:aca:4784:: with SMTP id u126-v6mr3501091oia.229.1536248751783; Thu, 06 Sep 2018 08:45:51 -0700 (PDT) MIME-Version: 1.0 References: <20180906152859.7810-1-tycho@tycho.ws> <20180906152859.7810-4-tycho@tycho.ws> In-Reply-To: <20180906152859.7810-4-tycho@tycho.ws> From: Jann Horn Date: Thu, 6 Sep 2018 17:45:25 +0200 Message-ID: Subject: Re: [PATCH v6 3/5] 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 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 6, 2018 at 5:29 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. [...] > +long seccomp_new_listener(struct task_struct *task, > + unsigned long filter_off) > +{ > + struct seccomp_filter *filter; > + struct file *listener; > + int fd; > + > + if (!capable(CAP_SYS_ADMIN)) > + return -EACCES; > + > + filter = get_nth_filter(task, filter_off); > + if (IS_ERR(filter)) > + return PTR_ERR(filter); > + > + fd = get_unused_fd_flags(0); > + if (fd < 0) { > + __put_seccomp_filter(filter); > + return fd; > + } > + > + listener = init_listener(task, task->seccomp.filter); Did you mean to write something like `init_listener(task, filter)` here?