Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp856337ybi; Wed, 17 Jul 2019 06:02:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJrA+i31tngWhpve3EAKllpIVUC9Q/ximBSNMI8ucv3GvVKuTX08o30pLvApEVjOc9XWlm X-Received: by 2002:a17:902:42a5:: with SMTP id h34mr44363724pld.16.1563368523249; Wed, 17 Jul 2019 06:02:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563368523; cv=none; d=google.com; s=arc-20160816; b=LHZjSA22qhR9LEekzpwXCAlCkXPinDqmGzoj7bxmmNTO3bOP9TzCEnuUgkE9bdtLko wluew0hxl4dvQfrOkW3FQD7U6uYkSCaCUzEKqq/ACxb+5hI8+PG8G2UtiQ/6MIaM0wQC L3PFj736m6iwiME6DHMEPpAdlTGrnksT2Ewki1HQoI2ZZktVKgGKWfGMjp3qGXX886nd Hn9ECFcqFRQIH6p6KzE9Lmkoh7Rv2OT5OKya3eQZ3ZB65gEF5Y2qzXX3e4c4GpzYs/L4 CyYdiuDe5ODW+QAwpFUnOM+X4CJGoJFlUbthyFRarpmqa2UxrJC2O8sBs8uHn5ARKXWu G0fw== 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=/2kZjQOSWU81kHquRCCTS3R2h91VV4bpIT1uTfaQV5o=; b=TdqRZEDM4u1XRG+5JYvRjn5xM9mraQLE/9CGQFOYeAi+5YWtVZ6kRcjptDOiMU8jak kk+V3uD5vHVhxG/yu07Po7LJfdIvwCL/nwNCZpgeTgwna/thcD59PPfTLTbmBZ2srT6U AWOJFLg0QXShjk/kUDg9eKGbLoxZIFzb+g2k3EewCDu7TaT/WaFL7u/o1HvCbTzGiYp9 BTuddN8G5QboOttGn/3EACJYYWEshBp6rokaY6NqeAwl5ORlO6Ui69tALtm9pWoJSur6 jATkHSujkW32BJ7q0e3xdBlxaj1w3u0V3loobgRw84ZTl8mFRhgf+PaTh6IgbreD7fwB cPHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=af1ZzoQS; 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 i9si22254197plb.284.2019.07.17.06.01.45; Wed, 17 Jul 2019 06:02:03 -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=@joelfernandes.org header.s=google header.b=af1ZzoQS; 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 S1726962AbfGQNBX (ORCPT + 99 others); Wed, 17 Jul 2019 09:01:23 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33279 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbfGQNBW (ORCPT ); Wed, 17 Jul 2019 09:01:22 -0400 Received: by mail-pf1-f195.google.com with SMTP id g2so10824784pfq.0 for ; Wed, 17 Jul 2019 06:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/2kZjQOSWU81kHquRCCTS3R2h91VV4bpIT1uTfaQV5o=; b=af1ZzoQSHrqVDDWQrA4VASz5++0JDUGwmcQd31ADjyOhdWK/pICy2eNdyY7iNr5pqV NaPEcXn/twlQE6dChS+rDBe/c9Qno+5OAYnYvg80MvabLRJQ6EOwm2cMF7rJS05j9kSd oZwEH7sW7elIJT6hLNlXxYjzbIuI+PrKdwaWQ= 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=/2kZjQOSWU81kHquRCCTS3R2h91VV4bpIT1uTfaQV5o=; b=Gvjl4Jqwg9tPOK4PyVW6xIu3oCuhBKaBzk+uIf2nGhbvLe8bfjANj1oqzElB+Zf6yg txtIyGCNCPKCBSma+kHO1xRTn60v88/ltmTOtBDVQ8PULJhKAAGHuflTlGImZK5MxZlK thqn9jhu1RdU7KKNweOIBTg9cmBVwzAeDV85HhfYwgHTZ79N3sajZ6PrNxx97Q/ywfDm 4nQNS+JpToNWr5I7rVPGuZ4wquQr4RuyvKw6OLAVjzDg/0YTkd2pqMyZS9LHT0RD5k/Q 940xgJayq4CT7niSaQsRa9o3m5Gv6GqGzk8taFeCrRm1VGqeJmbrKLu+pWlkRnmul+P7 DeUQ== X-Gm-Message-State: APjAAAXkUD+xtl2gET7UwTWbkbvO1zLzTD9DweoAOWK8p3Md59WKnmoR JX6VRba0pAGdn5zen+/bpvw= X-Received: by 2002:a17:90a:8984:: with SMTP id v4mr43650667pjn.133.1563368481782; Wed, 17 Jul 2019 06:01:21 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id l189sm28147054pfl.7.2019.07.17.06.01.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 17 Jul 2019 06:01:20 -0700 (PDT) Date: Wed, 17 Jul 2019 09:01:19 -0400 From: Joel Fernandes To: Alexei Starovoitov Cc: linux-kernel@vger.kernel.org, Adrian Ratiu , Alexei Starovoitov , bpf@vger.kernel.org, Brendan Gregg , connoro@google.com, Daniel Borkmann , duyuchao , Ingo Molnar , jeffv@google.com, Karim Yaghmour , kernel-team@android.com, linux-kselftest@vger.kernel.org, Manali Shukla , Manjo Raja Rao , Martin KaFai Lau , Masami Hiramatsu , Matt Mullins , Michal Gregorczyk , Michal Gregorczyk , Mohammad Husain , namhyung@google.com, namhyung@kernel.org, netdev@vger.kernel.org, paul.chaignon@gmail.com, primiano@google.com, Qais Yousef , Shuah Khan , Song Liu , Srinivas Ramana , Steven Rostedt , Tamir Carmeli , Yonghong Song Subject: Re: [PATCH RFC 0/4] Add support to directly attach BPF program to ftrace Message-ID: <20190717130119.GA138030@google.com> References: <20190710141548.132193-1-joel@joelfernandes.org> <20190716205455.iimn3pqpvsc3k4ry@ast-mbp.dhcp.thefacebook.com> <20190716213050.GA161922@google.com> <20190716222650.tk2coihjtsxszarf@ast-mbp.dhcp.thefacebook.com> <20190716224150.GC172157@google.com> <20190716235500.GA199237@google.com> <20190717012406.lugqemvubixfdd6v@ast-mbp.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190717012406.lugqemvubixfdd6v@ast-mbp.dhcp.thefacebook.com> 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 Tue, Jul 16, 2019 at 06:24:07PM -0700, Alexei Starovoitov wrote: [snip] > > > > > I don't see why a new bpf node for a trace event is a bad idea, really. > > > > > > > > See the patches for kprobe/uprobe FD-based api and the reasons behind it. > > > > tldr: text is racy, doesn't scale, poor security, etc. > > > > > > Is it possible to use perf without CAP_SYS_ADMIN and control security at the > > > per-event level? We are selective about who can access which event, using > > > selinux. That's how our ftrace-based tracers work. Its fine grained per-event > > > control. That's where I was going with the tracefs approach since we get that > > > granularity using the file system. > > android's choice of selinux is not a factor in deciding kernel apis. > It's completely separate discusion wether disallowing particular tracepoints > for given user make sense at all. > Just because you can hack it in via selinux blocking particular > /sys/debug/tracing/ directory and convince yourself that it's somehow > makes android more secure. It doesn't mean that all new api should fit > into this model. Its not like a hack, it is just control of which tracefs node can be accessed and which cannot be since the tracing can run on production systems out in the field and there are several concerns to address like security, privacy etc. It is not just for debugging usecases. We do collect traces out in the field where these issues are real and cannot be ignored. SELinux model is deny everything, and then selectively grant access to what is needed. The VFS and security LSM hooks provide this control quite well. I am not sure if such control is possible through perf hence I asked the question. > I think allowing one tracepoint and disallowing another is pointless > from security point of view. Tracing bpf program can do bpf_probe_read > of anything. I think the assumption here is the user controls the program instructions at runtime, but that's not the case. The BPF program we are loading is not dynamically generated, it is built at build time and it is loaded from a secure verified partition, so even though it can do bpf_probe_read, it is still not something that the user can change. And, we are planning to make it even more secure by making it kernel verify the program at load time as well (you were on some discussions about that a few months ago). thanks, - Joel