diff options
author | Jason Wessel <jason.wessel@windriver.com> | 2009-12-11 09:43:13 -0500 |
---|---|---|
committer | Jason Wessel <jason.wessel@windriver.com> | 2009-12-11 09:43:13 -0500 |
commit | 84667d4849b0e0a939a76f9f62d45fa3b4d59692 (patch) | |
tree | 5765d861dc39cf52863ac569211a43355ef3fc29 /kernel/kgdb.c | |
parent | a5d09d68335bb8422d5e7050c9f03f99ba6cfebd (diff) |
kgdb: Read buffer overflow
Roel Kluin reported an error found with Parfait. Where we want to
ensure that that kgdb_info[-1] never gets accessed.
Also check to ensure any negative tid does not exceed the size of the
shadow CPU array, else report critical debug context because it is an
internal kgdb failure.
Reported-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Diffstat (limited to 'kernel/kgdb.c')
-rw-r--r-- | kernel/kgdb.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/kgdb.c b/kernel/kgdb.c index 7d7014634022..29357a9ccfb2 100644 --- a/kernel/kgdb.c +++ b/kernel/kgdb.c | |||
@@ -541,12 +541,17 @@ static struct task_struct *getthread(struct pt_regs *regs, int tid) | |||
541 | */ | 541 | */ |
542 | if (tid == 0 || tid == -1) | 542 | if (tid == 0 || tid == -1) |
543 | tid = -atomic_read(&kgdb_active) - 2; | 543 | tid = -atomic_read(&kgdb_active) - 2; |
544 | if (tid < 0) { | 544 | if (tid < -1 && tid > -NR_CPUS - 2) { |
545 | if (kgdb_info[-tid - 2].task) | 545 | if (kgdb_info[-tid - 2].task) |
546 | return kgdb_info[-tid - 2].task; | 546 | return kgdb_info[-tid - 2].task; |
547 | else | 547 | else |
548 | return idle_task(-tid - 2); | 548 | return idle_task(-tid - 2); |
549 | } | 549 | } |
550 | if (tid <= 0) { | ||
551 | printk(KERN_ERR "KGDB: Internal thread select error\n"); | ||
552 | dump_stack(); | ||
553 | return NULL; | ||
554 | } | ||
550 | 555 | ||
551 | /* | 556 | /* |
552 | * find_task_by_pid_ns() does not take the tasklist lock anymore | 557 | * find_task_by_pid_ns() does not take the tasklist lock anymore |