Skip to content

Commit 1d02b44

Browse files
rddunlaprostedt
authored andcommitted
tracing: Fix return value of __setup handlers
__setup() handlers should generally return 1 to indicate that the boot options have been handled. Using invalid option values causes the entire kernel boot option string to be reported as Unknown and added to init's environment strings, polluting it. Unknown kernel command line parameters "BOOT_IMAGE=/boot/bzImage-517rc6 kprobe_event=p,syscall_any,$arg1 trace_options=quiet trace_clock=jiffies", will be passed to user space. Run /sbin/init as init process with arguments: /sbin/init with environment: HOME=/ TERM=linux BOOT_IMAGE=/boot/bzImage-517rc6 kprobe_event=p,syscall_any,$arg1 trace_options=quiet trace_clock=jiffies Return 1 from the __setup() handlers so that init's environment is not polluted with kernel boot options. Link: lore.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Cc: [email protected] Fixes: 7bcfaf5 ("tracing: Add trace_options kernel command line parameter") Fixes: e1e232c ("tracing: Add trace_clock=<clock> kernel parameter") Fixes: 970988e ("tracing/kprobe: Add kprobe_event= boot parameter") Signed-off-by: Randy Dunlap <[email protected]> Reported-by: Igor Zhbanov <[email protected]> Acked-by: Masami Hiramatsu <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 1d1898f commit 1d02b44

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

kernel/trace/trace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static char trace_boot_options_buf[MAX_TRACER_SIZE] __initdata;
235235
static int __init set_trace_boot_options(char *str)
236236
{
237237
strlcpy(trace_boot_options_buf, str, MAX_TRACER_SIZE);
238-
return 0;
238+
return 1;
239239
}
240240
__setup("trace_options=", set_trace_boot_options);
241241

@@ -246,7 +246,7 @@ static int __init set_trace_boot_clock(char *str)
246246
{
247247
strlcpy(trace_boot_clock_buf, str, MAX_TRACER_SIZE);
248248
trace_boot_clock = trace_boot_clock_buf;
249-
return 0;
249+
return 1;
250250
}
251251
__setup("trace_clock=", set_trace_boot_clock);
252252

kernel/trace/trace_kprobe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static int __init set_kprobe_boot_events(char *str)
3232
strlcpy(kprobe_boot_events_buf, str, COMMAND_LINE_SIZE);
3333
disable_tracing_selftest("running kprobe events");
3434

35-
return 0;
35+
return 1;
3636
}
3737
__setup("kprobe_event=", set_kprobe_boot_events);
3838

0 commit comments

Comments
 (0)