Skip to content

Commit 3433adc

Browse files
committed
ARC: entry: fix off-by-one error in syscall number validation
We have NR_syscall syscalls from [0 .. NR_syscall-1]. However the check for invalid syscall number is "> NR_syscall" as opposed to >=. This off-by-one error erronesously allows "NR_syscall" to be treated as valid syscall causeing out-of-bounds access into syscall-call table ensuing a crash (holes within syscall table have a invalid-entry handler but this is beyond the array implementing the table). This problem showed up on v5.6 kernel when testing glibc 2.33 (v5.10 kernel capable, includng faccessat2 syscall 439). The v5.6 kernel has NR_syscalls=439 (0 to 438). Due to the bug, 439 passed by glibc was not handled as -ENOSYS but processed leading to a crash. Link: foss-for-synopsys-dwc-arc-processors#48 Reported-by: Shahab Vahedi <[email protected]> Cc: <[email protected]> Signed-off-by: Vineet Gupta <[email protected]>
1 parent 8e97bf3 commit 3433adc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/arc/kernel/entry.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ tracesys:
177177

178178
; Do the Sys Call as we normally would.
179179
; Validate the Sys Call number
180-
cmp r8, NR_syscalls
180+
cmp r8, NR_syscalls - 1
181181
mov.hi r0, -ENOSYS
182182
bhi tracesys_exit
183183

@@ -255,7 +255,7 @@ ENTRY(EV_Trap)
255255
;============ Normal syscall case
256256

257257
; syscall num shd not exceed the total system calls avail
258-
cmp r8, NR_syscalls
258+
cmp r8, NR_syscalls - 1
259259
mov.hi r0, -ENOSYS
260260
bhi .Lret_from_system_call
261261

0 commit comments

Comments
 (0)