qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] linux-user: Fix indirect syscall handling for M


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] linux-user: Fix indirect syscall handling for MIPS
Date: Thu, 4 Aug 2011 23:43:31 +0100

On 4 August 2011 23:16, An-Cheng Huang <address@hidden> wrote:
> I ran into the problem of indirect syscalls not working with
> mips-linux-user and found that the number of arguments for sys_syscall
> is 0 in the mips_syscall_args table, which means the "higher" arguments
> (5, 6, 7, and 8) are never obtained from the stack for the do_syscall()
> invocation for indirect syscalls. So the actual syscall will not get the
> correct argument(s) if it needs more than three.

Yes, I noticed this last time I was looking at this code.

> A simpler approach would be to just change the number of arguments for
> sys_syscall to 8 in the mips_syscall_args table so that for indirect
> syscalls the "higher" arguments are always taken from the stack with
> get_user_ual(). However, since there is a comment about "what to do
> if get_user() fails", I don't know if this may cause breakage when the
> arguments are not actually there? If someone can confirm that this is
> harmless, the simple approach is probably better? Thanks.

In fact the Linux kernel will always read all four arguments off the
stack for sys_syscall, regardless:
http://lxr.linux.no/#linux+v3.0/arch/mips/kernel/scall32-o32.S#L188

So setting sys_syscall to 8 is not just easier but actually the Right
Thing. The comment about get_user() is cut-n-paste from various other
places in the file where it applies just as much -- it is no more of
an issue for MIPS or for sys_syscall than for any other architecture
or syscall. [ie it is a bug, but not in practice a very serious one,
and you can ignore it for the purposes of fixing the bug you've found
here.]

Incidentally, you can find the answer to the "what if get_user fails"
question for MIPS here:
http://lxr.linux.no/#linux+v3.0/arch/mips/kernel/scall32-o32.S#L166
...we should set ret to -TARGET_EFAULT and skip the call to do_syscall.

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]