Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1389340 > unrolled thread
| Started by | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| First post | 2016-04-27 18:40 +0200 |
| Last post | 2016-04-27 18:40 +0200 |
| Articles | 6 — 1 participant |
Back to article view | Back to linux.kernel
[for-next][PATCH 0/5] tracing: More updates for 4.7 Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200
[for-next][PATCH 3/5] tracing: Add check for NULL event field when creating hist field Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200
[for-next][PATCH 5/5] tracing: Dont use the address of the buffer array name in copy_from_user Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200
[for-next][PATCH 2/5] tracing: checking for NULL instead of IS_ERR() Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200
[for-next][PATCH 4/5] tracing: Handle tracing_map_alloc_elts() error path correctly Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200
[for-next][PATCH 1/5] tracing: Do not inherit event-fork option for instances Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Date | 2016-04-27 18:40 +0200 |
| Subject | [for-next][PATCH 0/5] tracing: More updates for 4.7 |
| Message-ID | <rsAFk-4bo-9@gated-at.bofh.it> |
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next
Head SHA1: 4afe6495e5cb3c352d95f07512cbb227e607e2ce
Dan Carpenter (1):
tracing: checking for NULL instead of IS_ERR()
Steven Rostedt (Red Hat) (1):
tracing: Do not inherit event-fork option for instances
Tom Zanussi (2):
tracing: Add check for NULL event field when creating hist field
tracing: Handle tracing_map_alloc_elts() error path correctly
Wang Xiaoqiang (1):
tracing: Don't use the address of the buffer array name in copy_from_user
----
kernel/trace/trace.c | 17 +++++++++++++----
kernel/trace/trace_events_hist.c | 3 +++
kernel/trace/tracing_map.c | 10 +++++++---
3 files changed, 23 insertions(+), 7 deletions(-)
[toc] | [next] | [standalone]
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Date | 2016-04-27 18:40 +0200 |
| Subject | [for-next][PATCH 3/5] tracing: Add check for NULL event field when creating hist field |
| Message-ID | <rsAFk-4bo-13@gated-at.bofh.it> |
| In reply to | #1389340 |
From: Tom Zanussi <tom.zanussi@linux.intel.com>
Smatch flagged create_hist_field() as possibly being able to
dereference a NULL pointer, although the current code exits in all
cases where the event field could be NULL, so it's not actually a
problem.
Still, to prevent future changes to the code from overlooking new
cases, make the NULL pointer check explicit and warn once in that
case.
Link: http://lkml.kernel.org/r/cfbc003f534a3e441b4313272fd412310aba6336.1461610073.git.tom.zanussi@linux.intel.com
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace_events_hist.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index f98b6b3a2804..0c05b8a99806 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -371,6 +371,9 @@ static struct hist_field *create_hist_field(struct ftrace_event_field *field,
goto out;
}
+ if (WARN_ON_ONCE(!field))
+ goto out;
+
if (is_string_field(field)) {
flags |= HIST_FIELD_FL_STRING;
--
2.8.0.rc3
[toc] | [prev] | [next] | [standalone]
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Date | 2016-04-27 18:40 +0200 |
| Subject | [for-next][PATCH 5/5] tracing: Dont use the address of the buffer array name in copy_from_user |
| Message-ID | <rsAFk-4bo-19@gated-at.bofh.it> |
| In reply to | #1389340 |
From: Wang Xiaoqiang <wangxq10@lzu.edu.cn>
With the following code snippet:
...
char buf[64];
...
if (copy_from_user(&buf, ubuf, cnt))
...
Even though the value of "&buf" equals "buf", but there is no need
to get the address of the "buf" again. Use "buf" instead of "&buf".
Link: http://lkml.kernel.org/r/20160418152329.18b72bea@debian
Signed-off-by: Wang Xiaoqiang <wangxq10@lzu.edu.cn>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 5e3ad3481e4b..46028d47d252 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3664,7 +3664,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
if (cnt >= sizeof(buf))
return -EINVAL;
- if (copy_from_user(&buf, ubuf, cnt))
+ if (copy_from_user(buf, ubuf, cnt))
return -EFAULT;
buf[cnt] = 0;
@@ -4537,7 +4537,7 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
if (cnt > MAX_TRACER_SIZE)
cnt = MAX_TRACER_SIZE;
- if (copy_from_user(&buf, ubuf, cnt))
+ if (copy_from_user(buf, ubuf, cnt))
return -EFAULT;
buf[cnt] = 0;
@@ -5327,7 +5327,7 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
if (cnt >= sizeof(buf))
return -EINVAL;
- if (copy_from_user(&buf, ubuf, cnt))
+ if (copy_from_user(buf, ubuf, cnt))
return -EFAULT;
buf[cnt] = 0;
--
2.8.0.rc3
[toc] | [prev] | [next] | [standalone]
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Date | 2016-04-27 18:40 +0200 |
| Subject | [for-next][PATCH 2/5] tracing: checking for NULL instead of IS_ERR() |
| Message-ID | <rsAFl-4bo-37@gated-at.bofh.it> |
| In reply to | #1389340 |
From: Dan Carpenter <dan.carpenter@oracle.com>
tracing_map_elt_alloc() returns ERR_PTRs on error, never NULL.
Fixes: 08d43a5fa063 ('tracing: Add lock-free tracing_map')
Link: http://lkml.kernel.org/r/20160423102347.GA11136@mwanda
Acked-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/tracing_map.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c
index e0f172932eca..e7dfc5eec669 100644
--- a/kernel/trace/tracing_map.c
+++ b/kernel/trace/tracing_map.c
@@ -814,7 +814,7 @@ static struct tracing_map_elt *copy_elt(struct tracing_map_elt *elt)
unsigned int i;
dup_elt = tracing_map_elt_alloc(elt->map);
- if (!dup_elt)
+ if (IS_ERR(dup_elt))
return NULL;
if (elt->map->ops && elt->map->ops->elt_copy)
--
2.8.0.rc3
[toc] | [prev] | [next] | [standalone]
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Date | 2016-04-27 18:40 +0200 |
| Subject | [for-next][PATCH 4/5] tracing: Handle tracing_map_alloc_elts() error path correctly |
| Message-ID | <rsAFl-4bo-41@gated-at.bofh.it> |
| In reply to | #1389340 |
From: Tom Zanussi <tom.zanussi@linux.intel.com>
If tracing_map_elt_alloc() fails, it will return ERR_PTR() instead of
NULL, so change the check to IS_ERROR(). We also need to set the
failed entry in the map->elts array to NULL instead of ERR_PTR() so
tracing_map_free_elts() doesn't try freeing an ERR_PTR().
tracing_map_free_elts() should also zero out what it frees so a
reentrant call won't find previously freed elements.
Link: http://lkml.kernel.org/r/f29d03b00bce3aac8cf151a8a30e6c83e5fee66d.1461610073.git.tom.zanussi@linux.intel.com
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/tracing_map.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c
index e7dfc5eec669..0a689bbb78ef 100644
--- a/kernel/trace/tracing_map.c
+++ b/kernel/trace/tracing_map.c
@@ -366,10 +366,13 @@ static void tracing_map_free_elts(struct tracing_map *map)
if (!map->elts)
return;
- for (i = 0; i < map->max_elts; i++)
+ for (i = 0; i < map->max_elts; i++) {
tracing_map_elt_free(*(TRACING_MAP_ELT(map->elts, i)));
+ *(TRACING_MAP_ELT(map->elts, i)) = NULL;
+ }
tracing_map_array_free(map->elts);
+ map->elts = NULL;
}
static int tracing_map_alloc_elts(struct tracing_map *map)
@@ -383,7 +386,8 @@ static int tracing_map_alloc_elts(struct tracing_map *map)
for (i = 0; i < map->max_elts; i++) {
*(TRACING_MAP_ELT(map->elts, i)) = tracing_map_elt_alloc(map);
- if (!(*(TRACING_MAP_ELT(map->elts, i)))) {
+ if (IS_ERR(*(TRACING_MAP_ELT(map->elts, i)))) {
+ *(TRACING_MAP_ELT(map->elts, i)) = NULL;
tracing_map_free_elts(map);
return -ENOMEM;
--
2.8.0.rc3
[toc] | [prev] | [next] | [standalone]
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Date | 2016-04-27 18:40 +0200 |
| Subject | [for-next][PATCH 1/5] tracing: Do not inherit event-fork option for instances |
| Message-ID | <rsAFl-4bo-43@gated-at.bofh.it> |
| In reply to | #1389340 |
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
As the event-fork option requires doing work when enabled and disabled, it
can not be passed down to created instances. The instance must clear this
flag when it is created, and must clear it when its removed.
As more options may be created with this need, a macro ZEROED_TRACE_FLAGS is
created that holds the flags that must not be inherited by the top level
instance, and must be cleared on removal of instances.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 988a35263fdd..5e3ad3481e4b 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -253,6 +253,9 @@ unsigned long long ns2usecs(cycle_t nsec)
#define TOP_LEVEL_TRACE_FLAGS (TRACE_ITER_PRINTK | \
TRACE_ITER_PRINTK_MSGONLY | TRACE_ITER_RECORD_CMD)
+/* trace_flags that are default zero for instances */
+#define ZEROED_TRACE_FLAGS \
+ TRACE_ITER_EVENT_FORK
/*
* The global_trace is the descriptor that holds the tracing
@@ -6710,7 +6713,7 @@ static int instance_mkdir(const char *name)
if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL))
goto out_free_tr;
- tr->trace_flags = global_trace.trace_flags;
+ tr->trace_flags = global_trace.trace_flags & ~ZEROED_TRACE_FLAGS;
cpumask_copy(tr->tracing_cpumask, cpu_all_mask);
@@ -6784,6 +6787,12 @@ static int instance_rmdir(const char *name)
list_del(&tr->list);
+ /* Disable all the flags that were enabled coming in */
+ for (i = 0; i < TRACE_FLAGS_MAX_SIZE; i++) {
+ if ((1 << i) & ZEROED_TRACE_FLAGS)
+ set_tracer_flag(tr, 1 << i, 0);
+ }
+
tracing_set_nop(tr);
event_trace_del_tracer(tr);
ftrace_destroy_function_files(tr);
--
2.8.0.rc3
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web