aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2016-10-25 10:51:13 -0400
committerIngo Molnar <mingo@kernel.org>2016-10-25 12:40:37 -0400
commit0ee1dd9f5e7eae4e55f95935b72d4beecb03de9c (patch)
treed552e8dc63d8daac8e472accff99b6710b57348e
parentbb5e5ce545f2031c96f7901cd8d1698ea3ca4c9c (diff)
x86/dumpstack: Remove raw stack dump
For mostly historical reasons, the x86 oops dump shows the raw stack values: ... [registers] Stack: ffff880079af7350 ffff880079905400 0000000000000000 ffffc900008f3ae0 ffffffffa0196610 0000000000000001 00010000ffffffff 0000000087654321 0000000000000002 0000000000000000 0000000000000000 0000000000000000 Call Trace: ... This seems to be an artifact from long ago, and probably isn't needed anymore. It generally just adds noise to the dump, and it can be actively harmful because it leaks kernel addresses. Linus says: "The stack dump actually goes back to forever, and it used to be useful back in 1992 or so. But it used to be useful mainly because stacks were simpler and we didn't have very good call traces anyway. I definitely remember having used them - I just do not remember having used them in the last ten+ years. Of course, it's still true that if you can trigger an oops, you've likely already lost the security game, but since the stack dump is so useless, let's aim to just remove it and make games like the above harder." This also removes the related 'kstack=' cmdline option and the 'kstack_depth_to_print' sysctl. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/e83bd50df52d8fe88e94d2566426ae40d813bf8f.1477405374.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--Documentation/kernel-parameters.txt3
-rw-r--r--Documentation/sysctl/kernel.txt8
-rw-r--r--Documentation/x86/x86_64/boot-options.txt4
-rw-r--r--arch/x86/include/asm/stacktrace.h5
-rw-r--r--arch/x86/kernel/dumpstack.c21
-rw-r--r--arch/x86/kernel/dumpstack_32.c33
-rw-r--r--arch/x86/kernel/dumpstack_64.c53
-rw-r--r--kernel/sysctl.c7
8 files changed, 4 insertions, 130 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 37babf91f2cb..049a9172ed22 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1958,9 +1958,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1958 kmemcheck=2 (one-shot mode) 1958 kmemcheck=2 (one-shot mode)
1959 Default: 2 (one-shot mode) 1959 Default: 2 (one-shot mode)
1960 1960
1961 kstack=N [X86] Print N words from the kernel stack
1962 in oops dumps.
1963
1964 kvm.ignore_msrs=[KVM] Ignore guest accesses to unhandled MSRs. 1961 kvm.ignore_msrs=[KVM] Ignore guest accesses to unhandled MSRs.
1965 Default is 0 (don't ignore, but inject #GP) 1962 Default is 0 (don't ignore, but inject #GP)
1966 1963
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index ffab8b5caa60..065f18478c1c 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -40,7 +40,6 @@ show up in /proc/sys/kernel:
40- hung_task_warnings 40- hung_task_warnings
41- kexec_load_disabled 41- kexec_load_disabled
42- kptr_restrict 42- kptr_restrict
43- kstack_depth_to_print [ X86 only ]
44- l2cr [ PPC only ] 43- l2cr [ PPC only ]
45- modprobe ==> Documentation/debugging-modules.txt 44- modprobe ==> Documentation/debugging-modules.txt
46- modules_disabled 45- modules_disabled
@@ -395,13 +394,6 @@ When kptr_restrict is set to (2), kernel pointers printed using
395 394
396============================================================== 395==============================================================
397 396
398kstack_depth_to_print: (X86 only)
399
400Controls the number of words to print when dumping the raw
401kernel stack.
402
403==============================================================
404
405l2cr: (PPC only) 397l2cr: (PPC only)
406 398
407This flag controls the L2 cache of G3 processor boards. If 399This flag controls the L2 cache of G3 processor boards. If
diff --git a/Documentation/x86/x86_64/boot-options.txt b/Documentation/x86/x86_64/boot-options.txt
index 0965a71f9942..61b611e9eeaf 100644
--- a/Documentation/x86/x86_64/boot-options.txt
+++ b/Documentation/x86/x86_64/boot-options.txt
@@ -277,10 +277,6 @@ IOMMU (input/output memory management unit)
277 space might stop working. Use this option if you have devices that 277 space might stop working. Use this option if you have devices that
278 are accessed from userspace directly on some PCI host bridge. 278 are accessed from userspace directly on some PCI host bridge.
279 279
280Debugging
281
282 kstack=N Print N words from the kernel stack in oops dumps.
283
284Miscellaneous 280Miscellaneous
285 281
286 nogbpages 282 nogbpages
diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
index 37f2e0b377ad..1e375b05cfa8 100644
--- a/arch/x86/include/asm/stacktrace.h
+++ b/arch/x86/include/asm/stacktrace.h
@@ -43,8 +43,6 @@ static inline bool on_stack(struct stack_info *info, void *addr, size_t len)
43 addr + len > begin && addr + len <= end); 43 addr + len > begin && addr + len <= end);
44} 44}
45 45
46extern int kstack_depth_to_print;
47
48#ifdef CONFIG_X86_32 46#ifdef CONFIG_X86_32
49#define STACKSLOTS_PER_LINE 8 47#define STACKSLOTS_PER_LINE 8
50#else 48#else
@@ -86,9 +84,6 @@ get_stack_pointer(struct task_struct *task, struct pt_regs *regs)
86void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, 84void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
87 unsigned long *stack, char *log_lvl); 85 unsigned long *stack, char *log_lvl);
88 86
89void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
90 unsigned long *sp, char *log_lvl);
91
92extern unsigned int code_bytes; 87extern unsigned int code_bytes;
93 88
94/* The form of the top of the frame on the stack */ 89/* The form of the top of the frame on the stack */
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index f967652500fa..499aa6f0fde5 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -22,7 +22,6 @@
22int panic_on_unrecovered_nmi; 22int panic_on_unrecovered_nmi;
23int panic_on_io_nmi; 23int panic_on_io_nmi;
24unsigned int code_bytes = 64; 24unsigned int code_bytes = 64;
25int kstack_depth_to_print = 3 * STACKSLOTS_PER_LINE;
26static int die_counter; 25static int die_counter;
27 26
28bool in_task_stack(unsigned long *stack, struct task_struct *task, 27bool in_task_stack(unsigned long *stack, struct task_struct *task,
@@ -171,12 +170,12 @@ void show_stack(struct task_struct *task, unsigned long *sp)
171 if (!sp && task == current) 170 if (!sp && task == current)
172 sp = get_stack_pointer(current, NULL); 171 sp = get_stack_pointer(current, NULL);
173 172
174 show_stack_log_lvl(task, NULL, sp, KERN_DEFAULT); 173 show_trace_log_lvl(task, NULL, sp, KERN_DEFAULT);
175} 174}
176 175
177void show_stack_regs(struct pt_regs *regs) 176void show_stack_regs(struct pt_regs *regs)
178{ 177{
179 show_stack_log_lvl(current, regs, NULL, KERN_DEFAULT); 178 show_trace_log_lvl(current, regs, NULL, KERN_DEFAULT);
180} 179}
181 180
182static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED; 181static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
@@ -295,22 +294,6 @@ void die(const char *str, struct pt_regs *regs, long err)
295 oops_end(flags, regs, sig); 294 oops_end(flags, regs, sig);
296} 295}
297 296
298static int __init kstack_setup(char *s)
299{
300 ssize_t ret;
301 unsigned long val;
302
303 if (!s)
304 return -EINVAL;
305
306 ret = kstrtoul(s, 0, &val);
307 if (ret)
308 return ret;
309 kstack_depth_to_print = val;
310 return 0;
311}
312early_param("kstack", kstack_setup);
313
314static int __init code_bytes_setup(char *s) 297static int __init code_bytes_setup(char *s)
315{ 298{
316 ssize_t ret; 299 ssize_t ret;
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index 06eb322b5f9f..90cf460d50bd 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -121,36 +121,6 @@ unknown:
121 return -EINVAL; 121 return -EINVAL;
122} 122}
123 123
124void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
125 unsigned long *sp, char *log_lvl)
126{
127 unsigned long *stack;
128 int i;
129
130 if (!try_get_task_stack(task))
131 return;
132
133 sp = sp ? : get_stack_pointer(task, regs);
134
135 stack = sp;
136 for (i = 0; i < kstack_depth_to_print; i++) {
137 if (kstack_end(stack))
138 break;
139 if ((i % STACKSLOTS_PER_LINE) == 0) {
140 if (i != 0)
141 pr_cont("\n");
142 printk("%s %08lx", log_lvl, *stack++);
143 } else
144 pr_cont(" %08lx", *stack++);
145 touch_nmi_watchdog();
146 }
147 pr_cont("\n");
148 show_trace_log_lvl(task, regs, sp, log_lvl);
149
150 put_task_stack(task);
151}
152
153
154void show_regs(struct pt_regs *regs) 124void show_regs(struct pt_regs *regs)
155{ 125{
156 int i; 126 int i;
@@ -168,8 +138,7 @@ void show_regs(struct pt_regs *regs)
168 unsigned char c; 138 unsigned char c;
169 u8 *ip; 139 u8 *ip;
170 140
171 pr_emerg("Stack:\n"); 141 show_trace_log_lvl(current, regs, NULL, KERN_EMERG);
172 show_stack_log_lvl(current, regs, NULL, KERN_EMERG);
173 142
174 pr_emerg("Code:"); 143 pr_emerg("Code:");
175 144
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index 36cf1a498227..310abf4542dc 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -140,56 +140,6 @@ unknown:
140 return -EINVAL; 140 return -EINVAL;
141} 141}
142 142
143void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
144 unsigned long *sp, char *log_lvl)
145{
146 unsigned long *irq_stack_end;
147 unsigned long *irq_stack;
148 unsigned long *stack;
149 int i;
150
151 if (!try_get_task_stack(task))
152 return;
153
154 irq_stack_end = (unsigned long *)this_cpu_read(irq_stack_ptr);
155 irq_stack = irq_stack_end - (IRQ_STACK_SIZE / sizeof(long));
156
157 sp = sp ? : get_stack_pointer(task, regs);
158
159 stack = sp;
160 for (i = 0; i < kstack_depth_to_print; i++) {
161 unsigned long word;
162
163 if (stack >= irq_stack && stack <= irq_stack_end) {
164 if (stack == irq_stack_end) {
165 stack = (unsigned long *) (irq_stack_end[-1]);
166 pr_cont(" <EOI> ");
167 }
168 } else {
169 if (kstack_end(stack))
170 break;
171 }
172
173 if (probe_kernel_address(stack, word))
174 break;
175
176 if ((i % STACKSLOTS_PER_LINE) == 0) {
177 if (i != 0)
178 pr_cont("\n");
179 printk("%s %016lx", log_lvl, word);
180 } else
181 pr_cont(" %016lx", word);
182
183 stack++;
184 touch_nmi_watchdog();
185 }
186
187 pr_cont("\n");
188 show_trace_log_lvl(task, regs, sp, log_lvl);
189
190 put_task_stack(task);
191}
192
193void show_regs(struct pt_regs *regs) 143void show_regs(struct pt_regs *regs)
194{ 144{
195 int i; 145 int i;
@@ -207,8 +157,7 @@ void show_regs(struct pt_regs *regs)
207 unsigned char c; 157 unsigned char c;
208 u8 *ip; 158 u8 *ip;
209 159
210 printk(KERN_DEFAULT "Stack:\n"); 160 show_trace_log_lvl(current, regs, NULL, KERN_DEFAULT);
211 show_stack_log_lvl(current, regs, NULL, KERN_DEFAULT);
212 161
213 printk(KERN_DEFAULT "Code: "); 162 printk(KERN_DEFAULT "Code: ");
214 163
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 706309f9ed84..17a5a8253294 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -990,13 +990,6 @@ static struct ctl_table kern_table[] = {
990 .proc_handler = proc_dointvec, 990 .proc_handler = proc_dointvec,
991 }, 991 },
992 { 992 {
993 .procname = "kstack_depth_to_print",
994 .data = &kstack_depth_to_print,
995 .maxlen = sizeof(int),
996 .mode = 0644,
997 .proc_handler = proc_dointvec,
998 },
999 {
1000 .procname = "io_delay_type", 993 .procname = "io_delay_type",
1001 .data = &io_delay_type, 994 .data = &io_delay_type,
1002 .maxlen = sizeof(int), 995 .maxlen = sizeof(int),