2009-03-26 17:22:19

by Vitaly Mayatskih

[permalink] [raw]
Subject: [PATCH] ftrace: advance readpos in trace_seq_to_user() by really read bytes

If tracer will not provide input buffer of enough size, he will never
see data between cnt and len bytes.

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 17bb88d..0217615 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -477,7 +477,7 @@ ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
if (ret)
return -EFAULT;

- s->readpos += len;
+ s->readpos += cnt;
return cnt;
}


--
wbr, Vitaly


2009-03-26 18:13:41

by Pekka Paalanen

[permalink] [raw]
Subject: Re: [PATCH] ftrace: advance readpos in trace_seq_to_user() by really read bytes

On Thu, 26 Mar 2009 18:22:18 +0100
Vitaly Mayatskikh <[email protected]> wrote:

> If tracer will not provide input buffer of enough size, he will never
> see data between cnt and len bytes.
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 17bb88d..0217615 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -477,7 +477,7 @@ ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
> if (ret)
> return -EFAULT;
>
> - s->readpos += len;
> + s->readpos += cnt;
> return cnt;
> }

This fix seems to be already included in tip/master:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git

It's not in Linus' master, but I guess it's on its way there.

Thanks.

--
Pekka Paalanen
http://www.iki.fi/pq/

2009-03-26 18:54:59

by Vitaly Mayatskih

[permalink] [raw]
Subject: Re: [PATCH] ftrace: advance readpos in trace_seq_to_user() by really read bytes

At Thu, 26 Mar 2009 20:13:24 +0200, Pekka Paalanen wrote:

> This fix seems to be already included in tip/master:
> git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git
>
> It's not in Linus' master, but I guess it's on its way there.

Yes, fix is there. Thanks for pointing.
--
wbr, Vitaly