microblaze: Fix syscall error recovery for invalid syscall IDs microblaze-4.0-rc4
authorJamie Garside <jamie.garside@york.ac.uk>
Mon, 23 Feb 2015 15:35:35 +0000 (15:35 +0000)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 4 Mar 2015 14:12:27 +0000 (15:12 +0100)
commitc2219eda547813c0c50dba90d9e989ae36cc3ab8
tree79e5d3d4810030c686e84403f274bfd1c952afa5
parent074fa7e76cfff4cd1a60753ee4596510f1b87183
microblaze: Fix syscall error recovery for invalid syscall IDs

This patch fixes two bugs in the Microblaze syscall trap handler when an invalid
syscall ID is used.

First, the range check on line 351 only checks for syscall IDs greater than
__NR_syscalls. A negative syscall ID (either passed to `syscall()` or as returned
by `do_syscall_trace_enter()` on error) will still satisfy this test and cause
the Linux kernel to access an invalid memory location and cause a kernel oops.
This has been fixed by also checking for r12 < 0.

Secondly, the current error recovery at line 378 returns using the wrong register
(r15 instead of r14) and does not restore the previous stack state. This has been
fixed by invoking `ret_from_trap` on error, setting r3 to `-ENOSYS`, similar to
what would happen when calling a valid syscall.

Signed-off-by: Jamie Garside <jamie.garside@york.ac.uk>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
arch/microblaze/kernel/entry.S