Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp390395ybx; Wed, 6 Nov 2019 02:17:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwF/eYgL8/Ph4r7dNcOh9H6hVO8VBVqhvIy4t8cLUL2i+plx02W2dwVAnAWkpT7LVJcR7Ml X-Received: by 2002:a50:9fcb:: with SMTP id c69mr1676156edf.163.1573035449191; Wed, 06 Nov 2019 02:17:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573035449; cv=none; d=google.com; s=arc-20160816; b=QaBBT/cotxv/vFzTISbsudA2ltGwgArs4yiKKbZrrKdNJd3Cm5TKVscYjgqkMKB/54 pIYU4gXFt9iNnXbRgtg7Np7crkP16TYMdrnqYjljnp0eJ4WjQ37UTPqaNzBIuB5DYAna vtZaOR9RR36rgwvGGf7jOY/I8QSp7Qz/tzhP/3jLGYHY7kiz9Z8XbKS/ekFn2PlLIdks 8erMYu0SgG3m6Q1KPZO8b0nwR95U2kqlIa1ePmQgEB+uszkHFAB/s9rreMaBIawNfohE H4QXYpnIz0s3GntBd7MSrxBA8XAgKWxXygu+rXWuLowglAgp3pOXYFBfegOPL+aGeQZf HQyg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=LWhaWOk3qJ6PhGYnB7tu0nDt84GiXSttuOOylRuzwNc=; b=YIiviRNRYBJoost70IwCJsdWRoRuEi7OXwn+aaYYSzGhaqyI6TG3OffWfJZw9NKUCW Rjgf6WJeqwddoekkqkBFQGD5MCNbNeWtkHzipnj6rbI9JMuST+GQo2AqA4aQJZOf6lEe HB/pSDtItUJESpInP8bLAFESZQ9jAmMVkxj8cxQsLfyt4zGPYK0DE5syKQfcjh3xoxgx Kafv9OiilZf/iwCD4CTaM6VDsVbhe1pLrMKbxPEk+ZO3vRtCvlOgVSnN/R4iE1ub4TKg 3xvavbSLlk09ZbMDikoG7fFozQ7qdPq+5nRSVYiDwBrdoKes3Z80So+JiYGqaOS0YiIO WeIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ObNh5sfX; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si15530977ejq.52.2019.11.06.02.17.05; Wed, 06 Nov 2019 02:17:29 -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=@chromium.org header.s=google header.b=ObNh5sfX; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730019AbfKFKQQ (ORCPT + 99 others); Wed, 6 Nov 2019 05:16:16 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46344 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729964AbfKFKQQ (ORCPT ); Wed, 6 Nov 2019 05:16:16 -0500 Received: by mail-pf1-f196.google.com with SMTP id 193so17195671pfc.13 for ; Wed, 06 Nov 2019 02:16:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=LWhaWOk3qJ6PhGYnB7tu0nDt84GiXSttuOOylRuzwNc=; b=ObNh5sfXqEx18MUAaYvkcPImWOLTjuhO7VKVPtL2nZEQG+EET68NKQivKeOwF6Dm4g FGQDbUs1KTCi3/lY8t5Ij25W0NdnN6/CYRsQAMYKOsHYM5yhWFQ+A7x1Z+fYLo/UeL+r rId5mISetQvkVdgiBepwWG09mM8m0nqrmzFrE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=LWhaWOk3qJ6PhGYnB7tu0nDt84GiXSttuOOylRuzwNc=; b=iFqJNplQZPl0TYgZwSGvG+aMnjDcPET4M649v2o8bwRXqEDVotjfCT0LX5Vlz2gLW0 cqdQ1FMM667eBnfmG1fGW5aQlM397Jf/GMXYHT9++F0LaWN2FNHS0UX0JZwX8Y21NEpy AeoUaOV2WQEnZDQ54sMfojxNFdQ9YdkOob9KgepAwf50XQ5v5gGqelAZmLxH0mD4PDCu /v415F1vbOm71g4LD/V0vtHyfnUfi64dlkbj47Ao3Xf/u6oRQn7XDEnxyHaRC75dSP+Q sIlLHGpKzrFmHsrYiNCmUxeXRSPN6LaEY46gJOz/Baqyy3UtrExD7iGwJL7F2bMJewQz cv6g== X-Gm-Message-State: APjAAAVzL8A/NPIZqhd8rjyMx5RbhLUuJ8gnde2yyENmgVnEGdRvYjeA h2EN+DYXPWgILBSF1KU222xq1g== X-Received: by 2002:a17:90a:901:: with SMTP id n1mr2761705pjn.113.1573035375469; Wed, 06 Nov 2019 02:16:15 -0800 (PST) Received: from chromium.org ([122.173.128.252]) by smtp.gmail.com with ESMTPSA id y36sm21074021pgk.66.2019.11.06.02.16.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2019 02:16:14 -0800 (PST) From: KP Singh X-Google-Original-From: KP Singh Date: Wed, 6 Nov 2019 15:45:58 +0530 To: =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= Cc: Alexei Starovoitov , linux-kernel@vger.kernel.org, Alexei Starovoitov , Andy Lutomirski , Casey Schaufler , Daniel Borkmann , David Drysdale , Florent Revest , James Morris , Jann Horn , John Johansen , Jonathan Corbet , Kees Cook , Michael Kerrisk , =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= , Paul Moore , Sargun Dhillon , "Serge E . Hallyn" , Shuah Khan , Stephen Smalley , Tejun Heo , Tetsuo Handa , Tycho Andersen , Will Drewry , bpf@vger.kernel.org, kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-security-module@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH bpf-next v13 4/7] landlock: Add ptrace LSM hooks Message-ID: <20191106101558.GA19467@chromium.org> References: <20191104172146.30797-1-mic@digikod.net> <20191104172146.30797-5-mic@digikod.net> <20191105171824.dfve44gjiftpnvy7@ast-mbp.dhcp.thefacebook.com> <23acf523-dbc4-855b-ca49-2bbfa5e7117e@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <23acf523-dbc4-855b-ca49-2bbfa5e7117e@digikod.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05-Nov 19:01, Micka?l Sala?n wrote: > > On 05/11/2019 18:18, Alexei Starovoitov wrote: > > On Mon, Nov 04, 2019 at 06:21:43PM +0100, Micka?l Sala?n wrote: > >> Add a first Landlock hook that can be used to enforce a security policy > >> or to audit some process activities. For a sandboxing use-case, it is > >> needed to inform the kernel if a task can legitimately debug another. > >> ptrace(2) can also be used by an attacker to impersonate another task > >> and remain undetected while performing malicious activities. > >> > >> Using ptrace(2) and related features on a target process can lead to a > >> privilege escalation. A sandboxed task must then be able to tell the > >> kernel if another task is more privileged, via ptrace_may_access(). > >> > >> Signed-off-by: Micka?l Sala?n > > ... > >> +static int check_ptrace(struct landlock_domain *domain, > >> + struct task_struct *tracer, struct task_struct *tracee) > >> +{ > >> + struct landlock_hook_ctx_ptrace ctx_ptrace = { > >> + .prog_ctx = { > >> + .tracer = (uintptr_t)tracer, > >> + .tracee = (uintptr_t)tracee, > >> + }, > >> + }; > > > > So you're passing two kernel pointers obfuscated as u64 into bpf program > > yet claiming that the end goal is to make landlock unprivileged?! > > The most basic security hole in the tool that is aiming to provide security. > > How could you used these pointers without dedicated BPF helpers? This > context items are typed as PTR_TO_TASK and can't be used without a > dedicated helper able to deal with ARG_PTR_TO_TASK. Moreover, pointer > arithmetic is explicitly forbidden (and I added tests for that). Did I > miss something? > > > > > I think the only way bpf-based LSM can land is both landlock and KRSI > > developers work together on a design that solves all use cases. > > As I said in a previous cover letter [1], that would be great. I think > that the current Landlock bases (almost everything from this series > except the seccomp interface) should meet both needs, but I would like > to have the point of view of the KRSI developers. As I mentioned we are willing to collaborate but the current landlock patches does not meet the needs for KRSI: * One program type per use-case (eg. LANDLOCK_PROG_PTRACE) as opposed to a single program type. This is something that KRSI proposed in it's initial design [1] and the new common "eBPF + LSM" based approach [2] would maintain as well. * Landlock chooses to have multiple LSM hooks per landlock hook which is more restrictive. It's not easy to write precise MAC and Audit policies for a privileged LSM based on this and this ends up bloating the context that needs to be maintained and requires avoidable boilerplate work in the kernel. [1] https://lore.kernel.org/patchwork/project/lkml/list/?series=410101 [2] https://lore.kernel.org/bpf/20191106100655.GA18815@chromium.org/T/#u - KP Singh > > [1] https://lore.kernel.org/lkml/20191029171505.6650-1-mic@digikod.net/ > > > BPF is capable > > to be a superset of all existing LSMs whereas landlock and KRSI propsals today > > are custom solutions to specific security concerns. BPF subsystem was extended > > with custom things in the past. In networking we have lwt, skb, tc, xdp, sk > > program types with a lot of overlapping functionality. We couldn't figure out > > how to generalize them into single 'networking' program. Now we can and we > > should. Accepting two partially overlapping bpf-based LSMs would be repeating > > the same mistake again. > > I'll let the LSM maintainers comment on whether BPF could be a superset > of all LSM, but given the complexity of an access-control system, I have > some doubts though. Anyway, we need to start somewhere and then iterate. > This patch series is a first step.