linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] riscv: uaccess: fix __put_kernel_nofault()
@ 2020-11-02  7:30 Changbin Du
  2020-11-03  8:50 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Changbin Du @ 2020-11-02  7:30 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Andrew Morton
  Cc: linux-riscv, linux-kernel, Changbin Du, Christoph Hellwig

The copy_from_kernel_nofault() is broken on riscv because the 'dst' and
'src' are mistakenly reversed in __put_kernel_nofault() macro.

copy_to_kernel_nofault:
...
0xffffffe0003159b8 <+30>:    sd      a4,0(a1) # a1 aka 'src'

Fixes: d464118cdc ("riscv: implement __get_kernel_nofault and __put_user_nofault")
Signed-off-by: Changbin Du <changbin.du@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
---
 arch/riscv/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
index c47e6b35c551..824b2c9da75b 100644
--- a/arch/riscv/include/asm/uaccess.h
+++ b/arch/riscv/include/asm/uaccess.h
@@ -476,7 +476,7 @@ do {									\
 do {									\
 	long __kr_err;							\
 									\
-	__put_user_nocheck(*((type *)(dst)), (type *)(src), __kr_err);	\
+	__put_user_nocheck(*((type *)(src)), (type *)(dst), __kr_err);	\
 	if (unlikely(__kr_err))						\
 		goto err_label;						\
 } while (0)
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] riscv: uaccess: fix __put_kernel_nofault()
  2020-11-02  7:30 [PATCH] riscv: uaccess: fix __put_kernel_nofault() Changbin Du
@ 2020-11-03  8:50 ` Christoph Hellwig
  2020-11-06  6:51 ` Anup Patel
  2020-11-06  7:45 ` Palmer Dabbelt
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-11-03  8:50 UTC (permalink / raw)
  To: Changbin Du
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Andrew Morton,
	linux-riscv, linux-kernel, Christoph Hellwig

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] riscv: uaccess: fix __put_kernel_nofault()
  2020-11-02  7:30 [PATCH] riscv: uaccess: fix __put_kernel_nofault() Changbin Du
  2020-11-03  8:50 ` Christoph Hellwig
@ 2020-11-06  6:51 ` Anup Patel
  2020-11-06  7:45 ` Palmer Dabbelt
  2 siblings, 0 replies; 4+ messages in thread
From: Anup Patel @ 2020-11-06  6:51 UTC (permalink / raw)
  To: Changbin Du, Palmer Dabbelt, Palmer Dabbelt
  Cc: Paul Walmsley, Albert Ou, Andrew Morton, linux-riscv,
	linux-kernel@vger.kernel.org List, Christoph Hellwig

On Mon, Nov 2, 2020 at 1:01 PM Changbin Du <changbin.du@gmail.com> wrote:
>
> The copy_from_kernel_nofault() is broken on riscv because the 'dst' and
> 'src' are mistakenly reversed in __put_kernel_nofault() macro.
>
> copy_to_kernel_nofault:
> ...
> 0xffffffe0003159b8 <+30>:    sd      a4,0(a1) # a1 aka 'src'
>
> Fixes: d464118cdc ("riscv: implement __get_kernel_nofault and __put_user_nofault")
> Signed-off-by: Changbin Du <changbin.du@gmail.com>
> Cc: Christoph Hellwig <hch@lst.de>
> ---
>  arch/riscv/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
> index c47e6b35c551..824b2c9da75b 100644
> --- a/arch/riscv/include/asm/uaccess.h
> +++ b/arch/riscv/include/asm/uaccess.h
> @@ -476,7 +476,7 @@ do {                                                                        \
>  do {                                                                   \
>         long __kr_err;                                                  \
>                                                                         \
> -       __put_user_nocheck(*((type *)(dst)), (type *)(src), __kr_err);  \
> +       __put_user_nocheck(*((type *)(src)), (type *)(dst), __kr_err);  \
>         if (unlikely(__kr_err))                                         \
>                 goto err_label;                                         \
>  } while (0)
> --
> 2.17.1
>
>

Looks good to me.

Tested-by: Anup Patel <anup@brainfault.org>
Reviewed-by: Anup Patel <anup@brainfault.org>

@Palmer Dabbelt , This patch fixes jump label implementation in
Linux-5.10-rc2. In general, this patch fixes all kernel instruction
patching related features. Can you take this for Linux-5.10-rcX ??

Regards,
Anup

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] riscv: uaccess: fix __put_kernel_nofault()
  2020-11-02  7:30 [PATCH] riscv: uaccess: fix __put_kernel_nofault() Changbin Du
  2020-11-03  8:50 ` Christoph Hellwig
  2020-11-06  6:51 ` Anup Patel
@ 2020-11-06  7:45 ` Palmer Dabbelt
  2 siblings, 0 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2020-11-06  7:45 UTC (permalink / raw)
  To: changbin.du
  Cc: Paul Walmsley, aou, akpm, linux-riscv, linux-kernel, changbin.du,
	Christoph Hellwig

On Sun, 01 Nov 2020 23:30:52 PST (-0800), changbin.du@gmail.com wrote:
> The copy_from_kernel_nofault() is broken on riscv because the 'dst' and
> 'src' are mistakenly reversed in __put_kernel_nofault() macro.
>
> copy_to_kernel_nofault:
> ...
> 0xffffffe0003159b8 <+30>:    sd      a4,0(a1) # a1 aka 'src'
>
> Fixes: d464118cdc ("riscv: implement __get_kernel_nofault and __put_user_nofault")
> Signed-off-by: Changbin Du <changbin.du@gmail.com>
> Cc: Christoph Hellwig <hch@lst.de>
> ---
>  arch/riscv/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
> index c47e6b35c551..824b2c9da75b 100644
> --- a/arch/riscv/include/asm/uaccess.h
> +++ b/arch/riscv/include/asm/uaccess.h
> @@ -476,7 +476,7 @@ do {									\
>  do {									\
>  	long __kr_err;							\
>  									\
> -	__put_user_nocheck(*((type *)(dst)), (type *)(src), __kr_err);	\
> +	__put_user_nocheck(*((type *)(src)), (type *)(dst), __kr_err);	\
>  	if (unlikely(__kr_err))						\
>  		goto err_label;						\
>  } while (0)

Thanks, this is on fixes.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-06  7:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-02  7:30 [PATCH] riscv: uaccess: fix __put_kernel_nofault() Changbin Du
2020-11-03  8:50 ` Christoph Hellwig
2020-11-06  6:51 ` Anup Patel
2020-11-06  7:45 ` Palmer Dabbelt

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).