Skip to contentSkip to conversation

kgdb: fix potential out-of-bounds access

PATCH In review Brian Norris 1 participant 2 messages Jan 12, 2015 1 message not in the archive KGDB / KDB /debug_core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kgdb: fix potential out-of-bounds access

CPU arrays (e.g., kgdb_info[]) are indexed from 0 (inclusive) to NR_CPUS (exclusive).

Pointed out by Coverity, CID 1262269

---
Untested

 kernel/debug/kdb/kdb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/debug/kdb/kdb_main.c +1 -1
index f191bddf64b8..53f051853f14 100644
@@ -2256,7 +2256,7 @@ static int kdb_cpu(int argc, const char **argv)
 	/*
 	 * Validate cpunum
 	 */
-	if ((cpunum > NR_CPUS) || !kgdb_info[cpunum].enter_kgdb)
+	if ((cpunum >= NR_CPUS) || !kgdb_info[cpunum].enter_kgdb)
 		return KDB_BADCPUNUM;
 
 	dbg_switch_cpu = cpunum;
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): [email protected]