linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Guoyun Sun <sunguoyun@loongson.cn>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	Paul Burton <paulburton@kernel.org>,
	James Hogan <jhogan@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Christian Brauner <christian.brauner@ubuntu.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	David Howells <dhowells@redhat.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	"open list:BROADCOM NVRAM DRIVER" <linux-mips@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Tiezhu Yang <yangtiezhu@loongson.cn>,
	Xuefeng Li <lixuefeng@loongson.cn>
Subject: Re: [PATCH V2] MIPS: Add get_thread_area syscall
Date: Fri, 13 Dec 2019 10:12:29 +0100	[thread overview]
Message-ID: <CAK8P3a1nLz2FDxw28DBXVma9E2saWpGtt+y6tYm4jros6TUF6w@mail.gmail.com> (raw)
In-Reply-To: <1576225834-16389-1-git-send-email-sunguoyun@loongson.cn>

On Fri, Dec 13, 2019 at 9:30 AM Guoyun Sun <sunguoyun@loongson.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

      reply	other threads:[~2019-12-13  9:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13  8:30 [PATCH V2] MIPS: Add get_thread_area syscall Guoyun Sun
2019-12-13  9:12 ` Arnd Bergmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK8P3a1nLz2FDxw28DBXVma9E2saWpGtt+y6tYm4jros6TUF6w@mail.gmail.com \
    --to=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=dhowells@redhat.com \
    --cc=geert@linux-m68k.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jhogan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=paulburton@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ralf@linux-mips.org \
    --cc=sunguoyun@loongson.cn \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).