linux-mips
[Top] [All Lists]

bug in handle_sys?

To: linux-mips@linux-mips.org
Subject: bug in handle_sys?
From: Fuxin Zhang <fxzhang@ict.ac.cn>
Date: Sun, 28 Mar 2004 23:27:07 -0500
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040122
Hi,

My colleague finds that there is probably a bug in handle_sys:

.align 5
NESTED(handle_sys, PT_SIZE, sp)
.set noat
SAVE_SOME
STI
.set at

lw t1, PT_EPC(sp) # skip syscall on return

sltiu t0, v0, MAX_SYSCALL_NO + 1 # check syscall number
addiu t1, 4 # skip to next instruction
beqz t0, illegal_syscall
sw t1, PT_EPC(sp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This code is not guarded by .set no reorder,so it won't be the delay slot
instruction,thus illegal_syscall with num > MAX_SYSCALL_NO will return with
EPC unchanged. The reason it works is that the syscall number register v0 will
be changed to ENOSYS. ENOSYS is fortunately another illegal syscall number
that will take another illegal_syscall return path.

Newer glibc of debian(2.3.2+?) will generate sys_4246,and that lead to real
problem for mips64. Put the line ahead of the beqz solve it.





<Prev in Thread] Current Thread [Next in Thread>