All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] [GIT PULL] tracing: Some minor fixes
@ 2016-01-05 17:17 Steven Rostedt
  2016-01-05 17:17 ` [PATCH 1/2] ftrace/scripts: Fix incorrect use of sprintf in recordmcount Steven Rostedt
  2016-01-05 17:17 ` [PATCH 2/2] tracing: Fix setting of start_index in find_next() Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2016-01-05 17:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linus Torvalds, Ingo Molnar, Andrew Morton


Linus,

Two more fixes.

 1. The recordmcount change had an output that used sprintf() (incorrectly)
    when it should have been a fprintf() to stderr.

 2. The printk_formats file could crash if someone added a trace_printk()
    in the core kernel, and also added one in a module. This does not
    affect production kernels. Only kernels where developers add trace_printk()
    for debugging can crash.

Please pull the latest trace-v4.4-rc4-3 tree, which can be found at:


  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v4.4-rc4-3

Tag SHA1: 88d7ab59dbb2c2dd97158589e7c3b1b44cd792be
Head SHA1: f36d1be2930ede0a1947686e1126ffda5d5ee1bb


Colin Ian King (1):
      ftrace/scripts: Fix incorrect use of sprintf in recordmcount

Qiu Peiyang (1):
      tracing: Fix setting of start_index in find_next()

----
 kernel/trace/trace_printk.c | 1 +
 scripts/recordmcount.c      | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] ftrace/scripts: Fix incorrect use of sprintf in recordmcount
  2016-01-05 17:17 [PATCH 0/2] [GIT PULL] tracing: Some minor fixes Steven Rostedt
@ 2016-01-05 17:17 ` Steven Rostedt
  2016-01-05 17:17 ` [PATCH 2/2] tracing: Fix setting of start_index in find_next() Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2016-01-05 17:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Ingo Molnar, Andrew Morton, Li Bin, Russell King,
	Will Deacon, stable, Colin Ian King

[-- Attachment #1: 0001-ftrace-scripts-Fix-incorrect-use-of-sprintf-in-recor.patch --]
[-- Type: text/plain, Size: 1191 bytes --]

From: Colin Ian King <colin.king@canonical.com>

Fix build warning:

scripts/recordmcount.c:589:4: warning: format not a string
literal and no format arguments [-Wformat-security]
    sprintf("%s: failed\n", file);

Fixes: a50bd43935586 ("ftrace/scripts: Have recordmcount copy the object file")
Link: http://lkml.kernel.org/r/1451516801-16951-1-git-send-email-colin.king@canonical.com

Cc: Li Bin <huawei.libin@huawei.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Will Deacon <will.deacon@arm.com>
Cc: stable@vger.kernel.org # 2.6.37+
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 scripts/recordmcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 301d70b0174f..e167592793a7 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -586,7 +586,7 @@ main(int argc, char *argv[])
 			do_file(file);
 			break;
 		case SJ_FAIL:    /* error in do_file or below */
-			sprintf("%s: failed\n", file);
+			fprintf(stderr, "%s: failed\n", file);
 			++n_error;
 			break;
 		case SJ_SUCCEED:    /* premature success */
-- 
2.6.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] tracing: Fix setting of start_index in find_next()
  2016-01-05 17:17 [PATCH 0/2] [GIT PULL] tracing: Some minor fixes Steven Rostedt
  2016-01-05 17:17 ` [PATCH 1/2] ftrace/scripts: Fix incorrect use of sprintf in recordmcount Steven Rostedt
@ 2016-01-05 17:17 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2016-01-05 17:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Ingo Molnar, Andrew Morton, stable, Qiu Peiyang

[-- Attachment #1: 0002-tracing-Fix-setting-of-start_index-in-find_next.patch --]
[-- Type: text/plain, Size: 2641 bytes --]

From: Qiu Peiyang <peiyangx.qiu@intel.com>

When we do cat /sys/kernel/debug/tracing/printk_formats, we hit kernel
panic at t_show.

general protection fault: 0000 [#1] PREEMPT SMP
CPU: 0 PID: 2957 Comm: sh Tainted: G W  O 3.14.55-x86_64-01062-gd4acdc7 #2
RIP: 0010:[<ffffffff811375b2>]
 [<ffffffff811375b2>] t_show+0x22/0xe0
RSP: 0000:ffff88002b4ebe80  EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000004
RDX: 0000000000000004 RSI: ffffffff81fd26a6 RDI: ffff880032f9f7b1
RBP: ffff88002b4ebe98 R08: 0000000000001000 R09: 000000000000ffec
R10: 0000000000000000 R11: 000000000000000f R12: ffff880004d9b6c0
R13: 7365725f6d706400 R14: ffff880004d9b6c0 R15: ffffffff82020570
FS:  0000000000000000(0000) GS:ffff88003aa00000(0063) knlGS:00000000f776bc40
CS:  0010 DS: 002b ES: 002b CR0: 0000000080050033
CR2: 00000000f6c02ff0 CR3: 000000002c2b3000 CR4: 00000000001007f0
Call Trace:
 [<ffffffff811dc076>] seq_read+0x2f6/0x3e0
 [<ffffffff811b749b>] vfs_read+0x9b/0x160
 [<ffffffff811b7f69>] SyS_read+0x49/0xb0
 [<ffffffff81a3a4b9>] ia32_do_call+0x13/0x13
 ---[ end trace 5bd9eb630614861e ]---
Kernel panic - not syncing: Fatal exception

When the first time find_next calls find_next_mod_format, it should
iterate the trace_bprintk_fmt_list to find the first print format of
the module. However in current code, start_index is smaller than *pos
at first, and code will not iterate the list. Latter container_of will
get the wrong address with former v, which will cause mod_fmt be a
meaningless object and so is the returned mod_fmt->fmt.

This patch will fix it by correcting the start_index. After fixed,
when the first time calls find_next_mod_format, start_index will be
equal to *pos, and code will iterate the trace_bprintk_fmt_list to
get the right module printk format, so is the returned mod_fmt->fmt.

Link: http://lkml.kernel.org/r/5684B900.9000309@intel.com

Cc: stable@vger.kernel.org # 3.12+
Fixes: 102c9323c35a8 "tracing: Add __tracepoint_string() to export string pointers"
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_printk.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c
index 1c2b28536feb..060df67dbdd1 100644
--- a/kernel/trace/trace_printk.c
+++ b/kernel/trace/trace_printk.c
@@ -273,6 +273,7 @@ static const char **find_next(void *v, loff_t *pos)
 	if (*pos < last_index + start_index)
 		return __start___tracepoint_str + (*pos - last_index);
 
+	start_index += last_index;
 	return find_next_mod_format(start_index, v, fmt, pos);
 }
 
-- 
2.6.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-05 17:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-05 17:17 [PATCH 0/2] [GIT PULL] tracing: Some minor fixes Steven Rostedt
2016-01-05 17:17 ` [PATCH 1/2] ftrace/scripts: Fix incorrect use of sprintf in recordmcount Steven Rostedt
2016-01-05 17:17 ` [PATCH 2/2] tracing: Fix setting of start_index in find_next() Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.