Re: trace_printk issue. Was: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-10-04 Thread Alexei Starovoitov
On 10/3/19 9:41 AM, Steven Rostedt wrote: > On Thu, 3 Oct 2019 09:18:40 -0700 > Alexei Starovoitov wrote: > >> I think dropping last events is just as bad. Is there a mode to overwrite old >> and keep the last N (like perf does) ? > > Well, it drops it by pages. Thus you should always have the l

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-10-03 Thread Alexei Starovoitov
On Thu, Oct 03, 2019 at 03:12:04PM +0900, Masami Hiramatsu wrote: > On Mon, 30 Sep 2019 11:31:29 -0700 > Kees Cook wrote: > > > On Sat, Sep 28, 2019 at 07:37:27PM -0400, Steven Rostedt wrote: > > > On Wed, 28 Aug 2019 21:07:24 -0700 > > > Alexei Starovoitov wrote: > > > > > > > > > > This won’t

Re: trace_printk issue. Was: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-10-03 Thread Steven Rostedt
On Thu, 3 Oct 2019 09:18:40 -0700 Alexei Starovoitov wrote: > I think dropping last events is just as bad. Is there a mode to overwrite old > and keep the last N (like perf does) ? Well, it drops it by pages. Thus you should always have the last page of events. > Peter Wu brought this issue to

trace_printk issue. Was: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-10-03 Thread Alexei Starovoitov
On Wed, Oct 02, 2019 at 07:00:27PM -0400, Steven Rostedt wrote: > > > > Both 'trace' and 'trace_pipe' have quirky side effects. > > Like opening 'trace' file will make all parallel trace_printk() to be > > ignored. > > While reading 'trace_pipe' file will clear it. > > >>>

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-10-02 Thread Masami Hiramatsu
On Mon, 30 Sep 2019 11:31:29 -0700 Kees Cook wrote: > On Sat, Sep 28, 2019 at 07:37:27PM -0400, Steven Rostedt wrote: > > On Wed, 28 Aug 2019 21:07:24 -0700 > > Alexei Starovoitov wrote: > > > > > > > > This won’t make me much more comfortable, since CAP_BPF lets it do an > > > > ever-growing

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-10-02 Thread Steven Rostedt
On Wed, 2 Oct 2019 17:18:21 + Alexei Starovoitov wrote: > >> It's an interesting idea, but I don't think it can work. > >> Please see bpf_trace_printk implementation in kernel/trace/bpf_trace.c > >> It's a lot more than string printing. > > > > Well, trace_printk() is just string printing.

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-10-02 Thread Alexei Starovoitov
On 10/1/19 3:47 PM, Steven Rostedt wrote: > On Tue, 1 Oct 2019 22:18:18 + > Alexei Starovoitov wrote: > >>> And then you can just format the string from the bpf_trace_printk() >>> into msg, and then have: >>> >>> trace_bpf_print(msg); >> >> It's an interesting idea, but I don't think it c

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-10-01 Thread Steven Rostedt
On Tue, 1 Oct 2019 22:18:18 + Alexei Starovoitov wrote: > > And then you can just format the string from the bpf_trace_printk() > > into msg, and then have: > > > > trace_bpf_print(msg); > > It's an interesting idea, but I don't think it can work. > Please see bpf_trace_printk impleme

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-10-01 Thread Alexei Starovoitov
On 10/1/19 3:10 PM, Steven Rostedt wrote: > On Mon, 30 Sep 2019 18:22:28 -0700 > Alexei Starovoitov wrote: > >> tracefs is a file system, so clearly file based acls are much better fit >> for all tracefs operations. >> But that is not the case for ftrace overall. >> bpf_trace_printk() calls trace

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-10-01 Thread Steven Rostedt
On Mon, 30 Sep 2019 18:22:28 -0700 Alexei Starovoitov wrote: > tracefs is a file system, so clearly file based acls are much better fit > for all tracefs operations. > But that is not the case for ftrace overall. > bpf_trace_printk() calls trace_printk() that dumps into trace pipe. > Technically

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-09-30 Thread Alexei Starovoitov
On Mon, Sep 30, 2019 at 11:31:29AM -0700, Kees Cook wrote: > On Sat, Sep 28, 2019 at 07:37:27PM -0400, Steven Rostedt wrote: > > On Wed, 28 Aug 2019 21:07:24 -0700 > > Alexei Starovoitov wrote: > > > > > > > > This won’t make me much more comfortable, since CAP_BPF lets it do an > > > > ever-gro

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-09-30 Thread Kees Cook
On Sat, Sep 28, 2019 at 07:37:27PM -0400, Steven Rostedt wrote: > On Wed, 28 Aug 2019 21:07:24 -0700 > Alexei Starovoitov wrote: > > > > > > This won’t make me much more comfortable, since CAP_BPF lets it do an > > > ever-growing set of nasty things. I’d much rather one or both of two > > > thi

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-09-28 Thread Steven Rostedt
On Wed, 28 Aug 2019 21:07:24 -0700 Alexei Starovoitov wrote: > > > > This won’t make me much more comfortable, since CAP_BPF lets it do an > > ever-growing set of nasty things. I’d much rather one or both of two things > > happen: > > > > 1. Give it CAP_TRACING only. It can leak my data, but i

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-29 Thread Steven Rostedt
On Thu, 29 Aug 2019 10:23:10 -0700 Alexei Starovoitov wrote: > > CAP_TRACE_KERNEL: Use all of perf, ftrace, kprobe, etc. > > > > CAP_TRACE_USER: Use all of perf with scope limited to user mode and > > uprobes. > > imo that makes little sense from security pov, since > such CAP_TRACE_KERNEL (

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-29 Thread Steven Rostedt
On Thu, 29 Aug 2019 10:19:24 -0700 Alexei Starovoitov wrote: > On Thu, Aug 29, 2019 at 09:34:34AM -0400, Steven Rostedt wrote: > > > > As the above seems to favor the idea of CAP_TRACING allowing write > > access to tracefs, should we have a CAP_TRACING_RO for just read access > > and limited pe

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-29 Thread Andy Lutomirski
On Thu, Aug 29, 2019 at 10:23 AM Alexei Starovoitov wrote: > > On Thu, Aug 29, 2019 at 08:43:23AM -0700, Andy Lutomirski wrote: > > > > I can imagine splitting it into three capabilities: > > > > CAP_TRACE_KERNEL: learn which kernel functions are called when. This > > would allow perf profiling,

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-29 Thread Alexei Starovoitov
On Thu, Aug 29, 2019 at 08:43:23AM -0700, Andy Lutomirski wrote: > > I can imagine splitting it into three capabilities: > > CAP_TRACE_KERNEL: learn which kernel functions are called when. This > would allow perf profiling, for example, but not sampling of kernel > regs. > > CAP_TRACE_READ_KERN

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-29 Thread Alexei Starovoitov
On Thu, Aug 29, 2019 at 09:34:34AM -0400, Steven Rostedt wrote: > > As the above seems to favor the idea of CAP_TRACING allowing write > access to tracefs, should we have a CAP_TRACING_RO for just read access > and limited perf abilities? read only vs writeable is an attribute of the file system.

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-29 Thread Andy Lutomirski
On Thu, Aug 29, 2019 at 6:34 AM Steven Rostedt wrote: > > On Wed, 28 Aug 2019 15:08:28 -0700 > Alexei Starovoitov wrote: > > > On Wed, Aug 28, 2019 at 09:14:21AM +0200, Peter Zijlstra wrote: > > > On Tue, Aug 27, 2019 at 04:01:08PM -0700, Andy Lutomirski wrote: > > > > > > > > Tracing: > > > > >

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-29 Thread Steven Rostedt
On Wed, 28 Aug 2019 15:08:28 -0700 Alexei Starovoitov wrote: > On Wed, Aug 28, 2019 at 09:14:21AM +0200, Peter Zijlstra wrote: > > On Tue, Aug 27, 2019 at 04:01:08PM -0700, Andy Lutomirski wrote: > > > > > > Tracing: > > > > > > > > CAP_BPF and perf_paranoid_tracepoint_raw() (which is > > > >

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-28 Thread Alexei Starovoitov
On Wed, Aug 28, 2019 at 05:45:47PM -0700, Andy Lutomirski wrote: > > > >> It seems like you are specifically trying to add a new switch to turn > >> as much of BPF as possible on and off. Why? > > > > Didn't I explain it several times already with multiple examples > > from systemd, daemons, bpf

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-28 Thread Andy Lutomirski
> On Aug 28, 2019, at 4:38 PM, Alexei Starovoitov > wrote: > >> On Tue, Aug 27, 2019 at 11:20:19PM -0700, Andy Lutomirski wrote: >> On Tue, Aug 27, 2019 at 9:49 PM Alexei Starovoitov >> wrote: >>> On Tue, Aug 27, 2019 at 07:00:40PM -0700, Andy Lutomirski wrote: Let me put th

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-28 Thread Andy Lutomirski
> On Aug 28, 2019, at 5:45 PM, Andy Lutomirski wrote: > > >>> On Aug 28, 2019, at 3:55 PM, Alexei Starovoitov >>> wrote: >>> >>> On Tue, Aug 27, 2019 at 11:12:29PM -0700, Andy Lutomirski wrote: > > > From the previous discussion, you want to make progress toward solving >

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-28 Thread Andy Lutomirski
> On Aug 28, 2019, at 3:55 PM, Alexei Starovoitov > wrote: > >> On Tue, Aug 27, 2019 at 11:12:29PM -0700, Andy Lutomirski wrote: From the previous discussion, you want to make progress toward solving a lot of problems with CAP_BPF. One of them was making BPF firewal

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-28 Thread Alexei Starovoitov
On Tue, Aug 27, 2019 at 11:20:19PM -0700, Andy Lutomirski wrote: > On Tue, Aug 27, 2019 at 9:49 PM Alexei Starovoitov > wrote: > > > > On Tue, Aug 27, 2019 at 07:00:40PM -0700, Andy Lutomirski wrote: > > > > > > Let me put this a bit differently. Part of the point is that > > > CAP_TRACING should

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-28 Thread Alexei Starovoitov
On Tue, Aug 27, 2019 at 11:12:29PM -0700, Andy Lutomirski wrote: > > > > > > > > From the previous discussion, you want to make progress toward solving > > > a lot of problems with CAP_BPF. One of them was making BPF > > > firewalling more generally useful. By making CAP_BPF grant the ability > >

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-28 Thread Alexei Starovoitov
On Wed, Aug 28, 2019 at 09:14:21AM +0200, Peter Zijlstra wrote: > On Tue, Aug 27, 2019 at 04:01:08PM -0700, Andy Lutomirski wrote: > > > > Tracing: > > > > > > CAP_BPF and perf_paranoid_tracepoint_raw() (which is > > > kernel.perf_event_paranoid == -1) > > > are necessary to: > > That's not trac

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-28 Thread kbuild test robot
Hi Alexei, I love your patch! Yet something to improve: [auto build test ERROR on bpf-next/master] url: https://github.com/0day-ci/linux/commits/Alexei-Starovoitov/bpf-capabilities-introduce-CAP_BPF/20190828-142441 base: https://kernel.googlesource.com/pub/scm/linux/kernel/git/bpf/bpf-nex

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-28 Thread Peter Zijlstra
On Tue, Aug 27, 2019 at 04:01:08PM -0700, Andy Lutomirski wrote: > > Tracing: > > > > CAP_BPF and perf_paranoid_tracepoint_raw() (which is > > kernel.perf_event_paranoid == -1) > > are necessary to: That's not tracing, that's perf. > > +bool cap_bpf_tracing(void) > > +{ > > + return capab

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Andy Lutomirski
On Tue, Aug 27, 2019 at 9:49 PM Alexei Starovoitov wrote: > > On Tue, Aug 27, 2019 at 07:00:40PM -0700, Andy Lutomirski wrote: > > > > Let me put this a bit differently. Part of the point is that > > CAP_TRACING should allow a user or program to trace without being able > > to corrupt the system.

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Andy Lutomirski
On Tue, Aug 27, 2019 at 9:43 PM Alexei Starovoitov wrote: > > On Tue, Aug 27, 2019 at 05:55:41PM -0700, Andy Lutomirski wrote: > > > > I was hoping for something in Documentation/admin-guide, not in a > > changelog that's hard to find. > > eventually yes. > > > > > > > > Changing the capability th

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Alexei Starovoitov
On Tue, Aug 27, 2019 at 07:00:40PM -0700, Andy Lutomirski wrote: > > Let me put this a bit differently. Part of the point is that > CAP_TRACING should allow a user or program to trace without being able > to corrupt the system. CAP_BPF as you’ve proposed it *can* likely > crash the system. Really

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Alexei Starovoitov
On Wed, Aug 28, 2019 at 12:30:41PM +0900, Masami Hiramatsu wrote: > > kprobes can be created in the tracefs filesystem (which is separate from > > debugfs, tracefs just gets automatically mounted > > in /sys/kernel/debug/tracing when debugfs is mounted) from the > > kprobe_events file. /sys/kernel/

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Alexei Starovoitov
On Tue, Aug 27, 2019 at 05:55:41PM -0700, Andy Lutomirski wrote: > > I was hoping for something in Documentation/admin-guide, not in a > changelog that's hard to find. eventually yes. > > > > > Changing the capability that some existing operation requires could > > > break existing programs. Th

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Masami Hiramatsu
On Tue, 27 Aug 2019 19:21:44 -0400 Steven Rostedt wrote: > > Here's my proposal for CAP_TRACING, documentation-style: > > > > --- begin --- > > > > CAP_TRACING enables a task to use various kernel features to trace > > running user programs and the kernel itself. CAP_TRACING also enables > >

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Steven Rostedt
On Tue, 27 Aug 2019 18:12:59 -0700 Andy Lutomirski wrote: > Too many slashes :/ > > A group could work for v1. Maybe all the tools should get updated to use > this path? trace-cmd now does. In fact, if run as root, it will first check if tracefs is mounted, and if not, it will try to mount it

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Andy Lutomirski
> On Aug 27, 2019, at 5:55 PM, Andy Lutomirski wrote: > > On Tue, Aug 27, 2019 at 5:34 PM Alexei Starovoitov > wrote: >> > From the previous discussion, you want to make progress toward solving > a lot of problems with CAP_BPF. One of them was making BPF > firewalling more generally useful. By

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Andy Lutomirski
> On Aug 27, 2019, at 5:44 PM, Steven Rostedt wrote: > > On Tue, 27 Aug 2019 16:34:47 -0700 > Andy Lutomirski wrote: > CAP_TRACING does not override normal permissions on sysfs or debugfs. This means that, unless a new interface for programming kprobes and such is added, it do

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Andy Lutomirski
On Tue, Aug 27, 2019 at 5:34 PM Alexei Starovoitov wrote: > > On Tue, Aug 27, 2019 at 04:01:08PM -0700, Andy Lutomirski wrote: > > [adding some security and tracing folks to cc] > > > > On Tue, Aug 27, 2019 at 1:52 PM Alexei Starovoitov wrote: > > > > > > Introduce CAP_BPF that allows loading all

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Steven Rostedt
On Tue, 27 Aug 2019 16:34:47 -0700 Andy Lutomirski wrote: > > > CAP_TRACING does not override normal permissions on sysfs or debugfs. > > > This means that, unless a new interface for programming kprobes and > > > such is added, it does not directly allow use of kprobes. > > > > kprobes can be

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Alexei Starovoitov
On Tue, Aug 27, 2019 at 07:21:44PM -0400, Steven Rostedt wrote: > > At least for CAP_TRACING (if it were to allow read/write access > to /sys/kernel/tracing), that would be very useful. It would be useful > to those that basically own their machines, and want to trace their > applications all the

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Alexei Starovoitov
On Tue, Aug 27, 2019 at 04:01:08PM -0700, Andy Lutomirski wrote: > [adding some security and tracing folks to cc] > > On Tue, Aug 27, 2019 at 1:52 PM Alexei Starovoitov wrote: > > > > Introduce CAP_BPF that allows loading all types of BPF programs, > > create most map types, load BTF, iterate pro

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Andy Lutomirski
On Tue, Aug 27, 2019 at 4:21 PM Steven Rostedt wrote: > > On Tue, 27 Aug 2019 16:01:08 -0700 > Andy Lutomirski wrote: > > > [adding some security and tracing folks to cc] > > > > On Tue, Aug 27, 2019 at 1:52 PM Alexei Starovoitov wrote: > > > > > > Introduce CAP_BPF that allows loading all types

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Steven Rostedt
On Tue, 27 Aug 2019 16:01:08 -0700 Andy Lutomirski wrote: > [adding some security and tracing folks to cc] > > On Tue, Aug 27, 2019 at 1:52 PM Alexei Starovoitov wrote: > > > > Introduce CAP_BPF that allows loading all types of BPF programs, > > create most map types, load BTF, iterate programs

Re: [PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Andy Lutomirski
[adding some security and tracing folks to cc] On Tue, Aug 27, 2019 at 1:52 PM Alexei Starovoitov wrote: > > Introduce CAP_BPF that allows loading all types of BPF programs, > create most map types, load BTF, iterate programs and maps. > CAP_BPF alone is not enough to attach or run programs. > >

[PATCH bpf-next] bpf, capabilities: introduce CAP_BPF

2019-08-27 Thread Alexei Starovoitov
Introduce CAP_BPF that allows loading all types of BPF programs, create most map types, load BTF, iterate programs and maps. CAP_BPF alone is not enough to attach or run programs. Networking: CAP_BPF and CAP_NET_ADMIN are necessary to: - attach to cgroup-bpf hooks like INET_INGRESS, INET_SOCK_CRE