tracing: some fixes for 2.6.31
cover tracing: some fixes for 2.6.31
Some small but not trival fixes for 2.6.31:
[PATCH 1/4] tracing: fix a typo in tracing_cpumask_write() [PATCH 2/4] tracing: replace a GFP_ATOMIC with GFP_KERNEL allocation [PATCH 3/4] tracing/filters: operand can be negative [PATCH 4/4] tracing/filters: strloc should be unsigned short
--- kernel/trace/trace.c | 8 ++++---- kernel/trace/trace_events_filter.c | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-)
PATCH 1/4 tracing: fix a typo in tracing_cpumask_write()
It's tracing_cpumask_new that should be kfree()ed.
This causes tracing_cpumask to be freed due to the typo:
# echo z > tracing_cpumask bash: echo: write error: Invalid argument
And subsequent reads/writes to tracing_cpuamsk will access this already-freed tracing_cpumask, thus may lead to crash.
[ Impact: fix leak and crash when writing invalid val to tracing_cpumask ]
--- kernel/trace/trace.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace.c +3 -3
@@ -2191,11 +2191,12 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,if (!alloc_cpumask_var (&tracing_cpumask_new,GFP_KERNEL ))return -ENOMEM ; -mutex_lock (&tracing_cpumask_update_lock); err =cpumask_parse_user (ubuf, count, tracing_cpumask_new);if (err) goto err_unlock; +mutex_lock (&tracing_cpumask_update_lock); +local_irq_disable ();__raw_spin_lock (&ftrace_max_lock);for_each_tracing_cpu (cpu) {
@@ -2223,8 +2224,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,return count; err_unlock: -mutex_unlock (&tracing_cpumask_update_lock); -free_cpumask_var (tracing_cpumask); +free_cpumask_var (tracing_cpumask_new);return err; }
Signature · 1 line
1.5.4.rc3
PATCH 2/4 tracing: replace a GFP_ATOMIC with GFP_KERNEL allocation
In reply to Li ZefanAtomic allocation is not needed here.
[ Impact: clean up ]
--- kernel/trace/trace.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/trace.c +1 -1
@@ -3627,7 +3627,7 @@ tracing_stats_read(struct file *filp, char __user *ubuf,struct trace_seq *s;unsigned long cnt; - s =kmalloc (sizeof (*s),GFP_ATOMIC ); + s =kmalloc (sizeof (*s),GFP_KERNEL );if (!s)return ENOMEM ;
Signature · 1 line
1.5.4.rc3
PATCH 3/4 tracing/filters: operand can be negative
In reply to Li ZefanThis should be a bug:
# cat format
name: foo_bar
ID: 71
format:
...
field:int bar; offset:24; size:4;
# echo 'bar < 0' > filter
# echo 'bar < -1' > filter
bash: echo: write error: Invalid argument[ Impact: fix to allow negative operand in filer expr ]
--- kernel/trace/trace_events_filter.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
kernel/trace/trace_events_filter.c +6 -1
@@ -546,6 +546,7 @@ static int filter_add_pred(struct filter_parse_state *ps,filter_pred_fn_t fn;unsigned long long val;int string_type; +int ret; pred->fn = filter_pred_none;
@@ -581,7 +582,11 @@ static int filter_add_pred(struct filter_parse_state *ps, pred->not =1 ;return filter_add_pred_fn (ps, call, pred, fn); }else { -if (strict_strtoull (pred->str_val,0 , &val)) { +if (field->is_signed) + ret =strict_strtoll (pred->str_val,0 , &val); +else + ret =strict_strtoull (pred->str_val,0 , &val); +if (ret) {parse_error (ps,FILT_ERR_ILLEGAL_INTVAL ,0 );return -EINVAL ; }
Signature · 1 line
1.5.4.rc3
PATCH 4/4 tracing/filters: strloc should be unsigned short
In reply to Li ZefanI forgot to update filter code accordingly in "tracing/events: change the type of __str_loc_item to unsigned short" (commt b0aae68cc5508f3c2fbf728988c954db4c8b8a53)
It can cause system crash:
# echo 1 > tracing/events/irq/irq_handler_entry/enable # echo 'name == eth0' > tracing/events/irq/irq_handler_entry/filter
[ Impact: fix crash while filtering on __string() field ]
--- kernel/trace/trace_events_filter.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/trace_events_filter.c +1 -1
@@ -178,7 +178,7 @@ static int filter_pred_string(struct filter_pred *pred, void *event,static int filter_pred_strloc (struct filter_pred *pred,void *event,int val1,int val2) { -int str_loc = *(int *)(event + pred->offset); +unsigned short str_loc = *(unsigned short *)(event + pred->offset);char *addr = (char *)(event + str_loc);int cmp, match;
Signature · 1 line
1.5.4.rc3
Quoted 12 lines · Li Zefan
Some small but not trival fixes for 2.6.31:
[PATCH 1/4] tracing: fix a typo in
tracing_cpumask_write()[PATCH 2/4] tracing: replace aGFP_ATOMICwithGFP_KERNELallocation [PATCH 3/4] tracing/filters: operand can be negative [PATCH 4/4] tracing/filters: strloc should be unsigned short--- kernel/trace/trace.c | 8 ++++---- kernel/trace/trace_events_filter.c | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-)
the whole series. Thanks!
Steven Rostedt
maintainerQuoted 14 lines · Frederic Weisbecker
Quoted 12 lines · Li Zefan
Some small but not trival fixes for 2.6.31:
[PATCH 1/4] tracing: fix a typo in
tracing_cpumask_write()[PATCH 2/4] tracing: replace aGFP_ATOMICwithGFP_KERNELallocation [PATCH 3/4] tracing/filters: operand can be negative [PATCH 4/4] tracing/filters: strloc should be unsigned short--- kernel/trace/trace.c | 8 ++++---- kernel/trace/trace_events_filter.c | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-)
Quoted 2 lines
the whole series. Thanks!
Yeah, I got a few patches over the weekend, I'll go and pull these and the others in.
Thanks,
-- Steve
[tip:tracing/urgent] tracing: fix a typo in tracing_cpumask_write()
In reply to Li ZefanCommit-ID: 215368e8e59023d6a0abdda896923018d74fdf7f Gitweb: http://git.kernel.org/tip/215368e8e59023d6a0abdda896923018d74fdf7f Author: Li Zefan <[email protected]> AuthorDate: Mon, 15 Jun 2009 10:56:42 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Mon, 15 Jun 2009 11:37:12 -0400
tracing: fix a typo in tracing_cpumask_write()
It's tracing_cpumask_new that should be kfree()ed.
This causes tracing_cpumask to be freed due to the typo:
# echo z > tracing_cpumask bash: echo: write error: Invalid argument
And subsequent reads/writes to tracing_cpuamsk will access this already-freed tracing_cpumask, thus may lead to crash.
[ Impact: fix leak and crash when writing invalid val to tracing_cpumask ]
LKML-Reference: <[email protected]>
--- kernel/trace/trace.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace.c +3 -3
@@ -2191,11 +2191,12 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,if (!alloc_cpumask_var (&tracing_cpumask_new,GFP_KERNEL ))return -ENOMEM ; -mutex_lock (&tracing_cpumask_update_lock); err =cpumask_parse_user (ubuf, count, tracing_cpumask_new);if (err) goto err_unlock; +mutex_lock (&tracing_cpumask_update_lock); +local_irq_disable ();__raw_spin_lock (&ftrace_max_lock);for_each_tracing_cpu (cpu) {
@@ -2223,8 +2224,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,return count; err_unlock: -mutex_unlock (&tracing_cpumask_update_lock); -free_cpumask_var (tracing_cpumask); +free_cpumask_var (tracing_cpumask_new);return err; }
[tip:tracing/urgent] tracing: replace a GFP_ATOMIC with GFP_KERNEL allocation
In reply to Li ZefanCommit-ID: e4f2d10f479d18198ebafcb5e124cc3dd8b8817a Gitweb: http://git.kernel.org/tip/e4f2d10f479d18198ebafcb5e124cc3dd8b8817a Author: Li Zefan <[email protected]> AuthorDate: Mon, 15 Jun 2009 10:57:28 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Mon, 15 Jun 2009 11:37:14 -0400
tracing: replace a GFP_ATOMIC with GFP_KERNEL allocation
Atomic allocation is not needed here.
[ Impact: clean up of memory alloction type ]
LKML-Reference: <[email protected]>
--- kernel/trace/trace.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/trace.c +1 -1
@@ -3627,7 +3627,7 @@ tracing_stats_read(struct file *filp, char __user *ubuf,struct trace_seq *s;unsigned long cnt; - s =kmalloc (sizeof (*s),GFP_ATOMIC ); + s =kmalloc (sizeof (*s),GFP_KERNEL );if (!s)return ENOMEM ;
[tip:tracing/urgent] tracing/filters: operand can be negative
In reply to Li ZefanCommit-ID: 5e4904cb633177046bee5d26946a7ac918e642fc Gitweb: http://git.kernel.org/tip/5e4904cb633177046bee5d26946a7ac918e642fc Author: Li Zefan <[email protected]> AuthorDate: Mon, 15 Jun 2009 10:58:39 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Mon, 15 Jun 2009 11:37:16 -0400
tracing/filters: operand can be negative
This should be a bug:
# cat format
name: foo_bar
ID: 71
format:
...
field:int bar; offset:24; size:4;
# echo 'bar < 0' > filter
# echo 'bar < -1' > filter
bash: echo: write error: Invalid argument[ Impact: fix to allow negative operand in filer expr ]
LKML-Reference: <[email protected]>
--- kernel/trace/trace_events_filter.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
kernel/trace/trace_events_filter.c +6 -1
@@ -546,6 +546,7 @@ static int filter_add_pred(struct filter_parse_state *ps,filter_pred_fn_t fn;unsigned long long val;int string_type; +int ret; pred->fn = filter_pred_none;
@@ -581,7 +582,11 @@ static int filter_add_pred(struct filter_parse_state *ps, pred->not =1 ;return filter_add_pred_fn (ps, call, pred, fn); }else { -if (strict_strtoull (pred->str_val,0 , &val)) { +if (field->is_signed) + ret =strict_strtoll (pred->str_val,0 , &val); +else + ret =strict_strtoull (pred->str_val,0 , &val); +if (ret) {parse_error (ps,FILT_ERR_ILLEGAL_INTVAL ,0 );return -EINVAL ; }
[tip:tracing/urgent] tracing/filters: strloc should be unsigned short
In reply to Li ZefanCommit-ID: 0ac2058f686a19fe8ab25c4f3104fc1580dce7cf Gitweb: http://git.kernel.org/tip/0ac2058f686a19fe8ab25c4f3104fc1580dce7cf Author: Li Zefan <[email protected]> AuthorDate: Mon, 15 Jun 2009 10:59:17 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Mon, 15 Jun 2009 11:37:18 -0400
tracing/filters: strloc should be unsigned short
I forgot to update filter code accordingly in "tracing/events: change the type of __str_loc_item to unsigned short" (commt b0aae68cc5508f3c2fbf728988c954db4c8b8a53)
It can cause system crash:
# echo 1 > tracing/events/irq/irq_handler_entry/enable # echo 'name == eth0' > tracing/events/irq/irq_handler_entry/filter
[ Impact: fix crash while filtering on __string() field ]
LKML-Reference: <[email protected]>
--- kernel/trace/trace_events_filter.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/trace/trace_events_filter.c +1 -1
@@ -178,7 +178,7 @@ static int filter_pred_string(struct filter_pred *pred, void *event,static int filter_pred_strloc (struct filter_pred *pred,void *event,int val1,int val2) { -int str_loc = *(int *)(event + pred->offset); +unsigned short str_loc = *(unsigned short *)(event + pred->offset);char *addr = (char *)(event + str_loc);int cmp, match;