History

x86/mpx: Fix off-by-one comparison with nr_registers

In the unlikely event that regno == nr_registers then we get an array overrun on regoff because the invalid register check is currently off-by-one. Fix this with a check that regno is >= nr_registers instead. Detected with static analysis using CoverityScan.

Colin Ian King committed 10 years ago

Commit 9bf148c1 parent bf70e551 file · +1 −1Browse files

Unified · Split

arch/x86/mm/mpx.c+1−1
@@ -123,7 +123,7 @@ static int get_reg_offset(struct insn *insn, struct pt_regs *regs, · 122 unmodified lines
123123 break;
124124 }
125125
126− if (regno > nr_registers) {
126+ if (regno >= nr_registers) {
127127 WARN_ONCE(1, "decoded an instruction with an invalid register");
128128 return -EINVAL;
129129 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t