Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-05 Thread Linus Torvalds
On Wed, Feb 5, 2014 at 5:52 AM, Oleg Nesterov wrote: > > Do we really need this change? If not (afaics), the patch can be > much simpler, see below... Right you are. I started out with free_bprm() being non-static, and thought I had to handle other callers. Which is why I made the bprm->filename

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-05 Thread Oleg Nesterov
On 02/04, Linus Torvalds wrote: > > --- a/kernel/kmod.c > +++ b/kernel/kmod.c > @@ -239,7 +239,7 @@ static int call_usermodehelper(void *data) > > commit_creds(new); > > - retval = do_execve(sub_info->path, > + retval = do_execve(getname_kernel(sub_info->path), >

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Linus Torvalds
On Tue, Feb 4, 2014 at 5:10 PM, Al Viro wrote: > > Umm... Interactions with aushit might be interesting. Freudian slip or intentional? :-) > It hooks into getname() and putname(); I'm not up to doing analysis > right now [...] Right you are. I was actually aware of that, but grepping for thing

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Steven Rostedt
On Tue, 4 Feb 2014 21:31:09 -0500 Steven Rostedt wrote: > (probably should keep) > > Reported-by: Igor Zhbanov I should probably state that "IZh" confirmed on IRC that this is indeed the person that reported the issue in the first place. -- Steve -- To unsubscribe from this list: send the li

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Steven Rostedt
On Tue, 4 Feb 2014 16:57:31 -0800 Linus Torvalds wrote: > How does this look? Well, it is lacking a bit of the "ugly factor" but other than that, I ran it through some minor tests (basically just logged in and enabled the sched_process_exec tracepoint and ran a few programs and looked at what w

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Al Viro
On Tue, Feb 04, 2014 at 04:57:31PM -0800, Linus Torvalds wrote: > On Tue, Feb 4, 2014 at 3:42 PM, Steven Rostedt wrote: > > > > New version that moves all the ugliness into a static inline helper > > function. > > Ok, that's better, but I really think we should just use "getname()" > and "putname

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Linus Torvalds
On Tue, Feb 4, 2014 at 3:42 PM, Steven Rostedt wrote: > > New version that moves all the ugliness into a static inline helper > function. Ok, that's better, but I really think we should just use "getname()" and "putname()". That's what the path that *matters* already does (ie the normal execve()

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Steven Rostedt
On Tue, 4 Feb 2014 18:28:52 -0500 Steven Rostedt wrote: > At least this patch keeps the ugliness with the code. I could even > encapsulate that in a static inline function to remove the ugliness out > of exec_binprm(). New version that moves all the ugliness into a static inline helper function

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Steven Rostedt
On Tue, 4 Feb 2014 12:18:53 -0800 Linus Torvalds wrote: > > That's too ugly to live. New patch. Not as ugly. Well, I think this one lacks ugly enough to be worth living for. It's dependent on another patch that adds a helper function for tracepoints, that allows users to implicitly use static_k

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Steven Rostedt
On Tue, 4 Feb 2014 12:18:53 -0800 Linus Torvalds wrote: > We do have bprm->file, and we could get a path from that. It would be > more expensive, but for tracing execve that might be fine. Yes/no? I actually looked at that. But it may duplicate a bit of code. I was thinking perhaps of making he

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Linus Torvalds
On Tue, Feb 4, 2014 at 9:05 AM, Steven Rostedt wrote: > > This works, but is rather ugly. Oh, please, that's a British-level understatement. It's like calling WWII "a small bother". That's too ugly to live. > Looking for any other suggestions here. Do we actually have to use "filename" at all?

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Steven Rostedt
On Tue, 4 Feb 2014 20:00:07 +0100 Oleg Nesterov wrote: > On 02/04, Steven Rostedt wrote: > > > > Now to fix this we need to save the filename before calling > > search_binary_handler(). But we don't want to save it if we are not > > tracing. Why slow everyone else down? > > Yes, but it would be

Re: [RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Oleg Nesterov
On 02/04, Steven Rostedt wrote: > > Now to fix this we need to save the filename before calling > search_binary_handler(). But we don't want to save it if we are not > tracing. Why slow everyone else down? Yes, but it would be much simpler to dup filename unconditionally. Note also that in this c

[RFC][PATCH] exec: Fix use after free of tracepoint trace_sched_process_exec

2014-02-04 Thread Steven Rostedt
Igor reported garbage in a trace that looked like this: login-1718 [000] ...1 1340.195118: sched_process_exec: filename=/bin/login pid=1718 old_pid=1718 systemd-cgroups-2061 [006] ...1 1341.672207: sched_process_exec: filename=/usr/lib/systemd/systemd-cgroups-agent pid=2061 old_p