[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK8P3a1nLz2FDxw28DBXVma9E2saWpGtt+y6tYm4jros6TUF6w@mail.gmail.com>
Date: Fri, 13 Dec 2019 10:12:29 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Guoyun Sun <sunguoyun@...ngson.cn>
Cc: Ralf Baechle <ralf@...ux-mips.org>,
Paul Burton <paulburton@...nel.org>,
James Hogan <jhogan@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Christian Brauner <christian.brauner@...ntu.com>,
Heiko Carstens <heiko.carstens@...ibm.com>,
David Howells <dhowells@...hat.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Catalin Marinas <catalin.marinas@....com>,
"open list:BROADCOM NVRAM DRIVER" <linux-mips@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Tiezhu Yang <yangtiezhu@...ngson.cn>,
Xuefeng Li <lixuefeng@...ngson.cn>
Subject: Re: [PATCH V2] MIPS: Add get_thread_area syscall
On Fri, Dec 13, 2019 at 9:30 AM Guoyun Sun <sunguoyun@...ngson.cn> wrote:
Thanks for fixing the numbers. On second look, I saw another problem:
> diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
> index c333e57..20bf4c5 100644
> --- a/arch/mips/kernel/syscall.c
> +++ b/arch/mips/kernel/syscall.c
> @@ -94,6 +94,16 @@ SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> return 0;
> }
>
> +SYSCALL_DEFINE1(get_thread_area, unsigned long __user *, u_info)
> +{
> + struct thread_info *ti = task_thread_info(current);
> +
> + if (copy_to_user(u_info, &(ti->tp_value), sizeof(ti->tp_value)))
> + return -EFAULT;
> +
> + return 0;
> +}
> +
This won't work for compat mode, when tp_value is a different size
in kernel and user space. You could either add a COMPAT_SYSCALL_DEFINE1()
variant, or handle it like
if (in_compat_syscall())
return put_user(ti->tp_value, (__u32 *)u_info);
return put_user(ti->tp_value, u_info);
Arnd
Powered by blists - more mailing lists