aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile/kernel
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2013-08-10 12:22:43 -0400
committerChris Metcalf <cmetcalf@tilera.com>2013-08-30 11:56:54 -0400
commit4036c7d3542ce82ea343bf95dd05ca46aefba9aa (patch)
treed33fda13124e904569510e438ec4b525a31b8097 /arch/tile/kernel
parent6fbeee29a2b87574527897c3ded1f92e236518c7 (diff)
tile: don't call show_regs_print_info() with corrupt current
We use the validate_current() API to make sure that "current" seems plausible before using it. With the new show_regs_print_info() API, we want to check that current is OK before calling it, since otherwise we will end up in a recursive panic. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch/tile/kernel')
-rw-r--r--arch/tile/kernel/process.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c
index 663289b803fc..44cdc4aa59e8 100644
--- a/arch/tile/kernel/process.c
+++ b/arch/tile/kernel/process.c
@@ -226,19 +226,20 @@ int get_unalign_ctl(struct task_struct *tsk, unsigned long adr)
226 (unsigned int __user *)adr); 226 (unsigned int __user *)adr);
227} 227}
228 228
229static struct task_struct corrupt_current = { .comm = "<corrupt>" };
230
229/* 231/*
230 * Return "current" if it looks plausible, or else a pointer to a dummy. 232 * Return "current" if it looks plausible, or else a pointer to a dummy.
231 * This can be helpful if we are just trying to emit a clean panic. 233 * This can be helpful if we are just trying to emit a clean panic.
232 */ 234 */
233struct task_struct *validate_current(void) 235struct task_struct *validate_current(void)
234{ 236{
235 static struct task_struct corrupt = { .comm = "<corrupt>" };
236 struct task_struct *tsk = current; 237 struct task_struct *tsk = current;
237 if (unlikely((unsigned long)tsk < PAGE_OFFSET || 238 if (unlikely((unsigned long)tsk < PAGE_OFFSET ||
238 (high_memory && (void *)tsk > high_memory) || 239 (high_memory && (void *)tsk > high_memory) ||
239 ((unsigned long)tsk & (__alignof__(*tsk) - 1)) != 0)) { 240 ((unsigned long)tsk & (__alignof__(*tsk) - 1)) != 0)) {
240 pr_err("Corrupt 'current' %p (sp %#lx)\n", tsk, stack_pointer); 241 pr_err("Corrupt 'current' %p (sp %#lx)\n", tsk, stack_pointer);
241 tsk = &corrupt; 242 tsk = &corrupt_current;
242 } 243 }
243 return tsk; 244 return tsk;
244} 245}
@@ -589,7 +590,8 @@ void show_regs(struct pt_regs *regs)
589 int i; 590 int i;
590 591
591 pr_err("\n"); 592 pr_err("\n");
592 show_regs_print_info(KERN_ERR); 593 if (tsk != &corrupt_current)
594 show_regs_print_info(KERN_ERR);
593#ifdef __tilegx__ 595#ifdef __tilegx__
594 for (i = 0; i < 17; i++) 596 for (i = 0; i < 17; i++)
595 pr_err(" r%-2d: "REGFMT" r%-2d: "REGFMT" r%-2d: "REGFMT"\n", 597 pr_err(" r%-2d: "REGFMT" r%-2d: "REGFMT" r%-2d: "REGFMT"\n",