* [PATCH] RISC-V: Fix raw_copy_{to,from}_user()
@ 2018-11-15 0:27 Olof Johansson
2018-11-15 0:27 ` Olof Johansson
2018-11-15 14:59 ` Palmer Dabbelt
0 siblings, 2 replies; 6+ messages in thread
From: Olof Johansson @ 2018-11-15 0:27 UTC (permalink / raw)
To: linux-riscv
Sparse highlighted it, and appears to be a pure bug (from vs to).
./arch/riscv/include/asm/uaccess.h:403:35: warning: incorrect type in argument 1 (different address spaces)
./arch/riscv/include/asm/uaccess.h:403:39: warning: incorrect type in argument 2 (different address spaces)
./arch/riscv/include/asm/uaccess.h:409:37: warning: incorrect type in argument 1 (different address spaces)
./arch/riscv/include/asm/uaccess.h:409:41: warning: incorrect type in argument 2 (different address spaces)
Signed-off-by: Olof Johansson <olof@lixom.net>
---
arch/riscv/include/asm/uaccess.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
index 473cfc84e412f..8c3e3e3c8be12 100644
--- a/arch/riscv/include/asm/uaccess.h
+++ b/arch/riscv/include/asm/uaccess.h
@@ -400,13 +400,13 @@ extern unsigned long __must_check __asm_copy_from_user(void *to,
static inline unsigned long
raw_copy_from_user(void *to, const void __user *from, unsigned long n)
{
- return __asm_copy_to_user(to, from, n);
+ return __asm_copy_from_user(to, from, n);
}
static inline unsigned long
raw_copy_to_user(void __user *to, const void *from, unsigned long n)
{
- return __asm_copy_from_user(to, from, n);
+ return __asm_copy_to_user(to, from, n);
}
extern long strncpy_from_user(char *dest, const char __user *src, long count);
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] RISC-V: Fix raw_copy_{to,from}_user()
2018-11-15 0:27 [PATCH] RISC-V: Fix raw_copy_{to,from}_user() Olof Johansson
@ 2018-11-15 0:27 ` Olof Johansson
2018-11-15 14:59 ` Palmer Dabbelt
1 sibling, 0 replies; 6+ messages in thread
From: Olof Johansson @ 2018-11-15 0:27 UTC (permalink / raw)
To: Palmer Dabbelt; +Cc: Olof Johansson, linux-riscv, Albert Ou, linux-kernel
Sparse highlighted it, and appears to be a pure bug (from vs to).
./arch/riscv/include/asm/uaccess.h:403:35: warning: incorrect type in argument 1 (different address spaces)
./arch/riscv/include/asm/uaccess.h:403:39: warning: incorrect type in argument 2 (different address spaces)
./arch/riscv/include/asm/uaccess.h:409:37: warning: incorrect type in argument 1 (different address spaces)
./arch/riscv/include/asm/uaccess.h:409:41: warning: incorrect type in argument 2 (different address spaces)
Signed-off-by: Olof Johansson <olof@lixom.net>
---
arch/riscv/include/asm/uaccess.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
index 473cfc84e412f..8c3e3e3c8be12 100644
--- a/arch/riscv/include/asm/uaccess.h
+++ b/arch/riscv/include/asm/uaccess.h
@@ -400,13 +400,13 @@ extern unsigned long __must_check __asm_copy_from_user(void *to,
static inline unsigned long
raw_copy_from_user(void *to, const void __user *from, unsigned long n)
{
- return __asm_copy_to_user(to, from, n);
+ return __asm_copy_from_user(to, from, n);
}
static inline unsigned long
raw_copy_to_user(void __user *to, const void *from, unsigned long n)
{
- return __asm_copy_from_user(to, from, n);
+ return __asm_copy_to_user(to, from, n);
}
extern long strncpy_from_user(char *dest, const char __user *src, long count);
--
2.11.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] RISC-V: Fix raw_copy_{to,from}_user()
2018-11-15 0:27 [PATCH] RISC-V: Fix raw_copy_{to,from}_user() Olof Johansson
2018-11-15 0:27 ` Olof Johansson
@ 2018-11-15 14:59 ` Palmer Dabbelt
2018-11-15 14:59 ` Palmer Dabbelt
2018-11-15 20:27 ` Olof Johansson
1 sibling, 2 replies; 6+ messages in thread
From: Palmer Dabbelt @ 2018-11-15 14:59 UTC (permalink / raw)
To: linux-riscv
On Wed, 14 Nov 2018 16:27:55 PST (-0800), Olof Johansson wrote:
> Sparse highlighted it, and appears to be a pure bug (from vs to).
>
> ./arch/riscv/include/asm/uaccess.h:403:35: warning: incorrect type in argument 1 (different address spaces)
> ./arch/riscv/include/asm/uaccess.h:403:39: warning: incorrect type in argument 2 (different address spaces)
> ./arch/riscv/include/asm/uaccess.h:409:37: warning: incorrect type in argument 1 (different address spaces)
> ./arch/riscv/include/asm/uaccess.h:409:41: warning: incorrect type in argument 2 (different address spaces)
>
> Signed-off-by: Olof Johansson <olof@lixom.net>
> ---
> arch/riscv/include/asm/uaccess.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
> index 473cfc84e412f..8c3e3e3c8be12 100644
> --- a/arch/riscv/include/asm/uaccess.h
> +++ b/arch/riscv/include/asm/uaccess.h
> @@ -400,13 +400,13 @@ extern unsigned long __must_check __asm_copy_from_user(void *to,
> static inline unsigned long
> raw_copy_from_user(void *to, const void __user *from, unsigned long n)
> {
> - return __asm_copy_to_user(to, from, n);
> + return __asm_copy_from_user(to, from, n);
> }
>
> static inline unsigned long
> raw_copy_to_user(void __user *to, const void *from, unsigned long n)
> {
> - return __asm_copy_from_user(to, from, n);
> + return __asm_copy_to_user(to, from, n);
> }
>
> extern long strncpy_from_user(char *dest, const char __user *src, long count);
Oh, no idea how I missed that one. This looks like it's been in for a long
time, so I'm surprised anything works at all!
I'm going to add a stable CC and PR this to Linus this week, assuming I get
some time to at least give it a minimal test.
Thanks for catching this!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RISC-V: Fix raw_copy_{to,from}_user()
2018-11-15 14:59 ` Palmer Dabbelt
@ 2018-11-15 14:59 ` Palmer Dabbelt
2018-11-15 20:27 ` Olof Johansson
1 sibling, 0 replies; 6+ messages in thread
From: Palmer Dabbelt @ 2018-11-15 14:59 UTC (permalink / raw)
To: Olof Johansson; +Cc: Olof Johansson, linux-riscv, aou, linux-kernel
On Wed, 14 Nov 2018 16:27:55 PST (-0800), Olof Johansson wrote:
> Sparse highlighted it, and appears to be a pure bug (from vs to).
>
> ./arch/riscv/include/asm/uaccess.h:403:35: warning: incorrect type in argument 1 (different address spaces)
> ./arch/riscv/include/asm/uaccess.h:403:39: warning: incorrect type in argument 2 (different address spaces)
> ./arch/riscv/include/asm/uaccess.h:409:37: warning: incorrect type in argument 1 (different address spaces)
> ./arch/riscv/include/asm/uaccess.h:409:41: warning: incorrect type in argument 2 (different address spaces)
>
> Signed-off-by: Olof Johansson <olof@lixom.net>
> ---
> arch/riscv/include/asm/uaccess.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
> index 473cfc84e412f..8c3e3e3c8be12 100644
> --- a/arch/riscv/include/asm/uaccess.h
> +++ b/arch/riscv/include/asm/uaccess.h
> @@ -400,13 +400,13 @@ extern unsigned long __must_check __asm_copy_from_user(void *to,
> static inline unsigned long
> raw_copy_from_user(void *to, const void __user *from, unsigned long n)
> {
> - return __asm_copy_to_user(to, from, n);
> + return __asm_copy_from_user(to, from, n);
> }
>
> static inline unsigned long
> raw_copy_to_user(void __user *to, const void *from, unsigned long n)
> {
> - return __asm_copy_from_user(to, from, n);
> + return __asm_copy_to_user(to, from, n);
> }
>
> extern long strncpy_from_user(char *dest, const char __user *src, long count);
Oh, no idea how I missed that one. This looks like it's been in for a long
time, so I'm surprised anything works at all!
I'm going to add a stable CC and PR this to Linus this week, assuming I get
some time to at least give it a minimal test.
Thanks for catching this!
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] RISC-V: Fix raw_copy_{to,from}_user()
2018-11-15 14:59 ` Palmer Dabbelt
2018-11-15 14:59 ` Palmer Dabbelt
@ 2018-11-15 20:27 ` Olof Johansson
2018-11-15 20:27 ` Olof Johansson
1 sibling, 1 reply; 6+ messages in thread
From: Olof Johansson @ 2018-11-15 20:27 UTC (permalink / raw)
To: linux-riscv
On Thu, Nov 15, 2018 at 6:59 AM Palmer Dabbelt <palmer@sifive.com> wrote:
>
> On Wed, 14 Nov 2018 16:27:55 PST (-0800), Olof Johansson wrote:
> > Sparse highlighted it, and appears to be a pure bug (from vs to).
> >
> > ./arch/riscv/include/asm/uaccess.h:403:35: warning: incorrect type in argument 1 (different address spaces)
> > ./arch/riscv/include/asm/uaccess.h:403:39: warning: incorrect type in argument 2 (different address spaces)
> > ./arch/riscv/include/asm/uaccess.h:409:37: warning: incorrect type in argument 1 (different address spaces)
> > ./arch/riscv/include/asm/uaccess.h:409:41: warning: incorrect type in argument 2 (different address spaces)
> >
> > Signed-off-by: Olof Johansson <olof@lixom.net>
> > ---
> > arch/riscv/include/asm/uaccess.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
> > index 473cfc84e412f..8c3e3e3c8be12 100644
> > --- a/arch/riscv/include/asm/uaccess.h
> > +++ b/arch/riscv/include/asm/uaccess.h
> > @@ -400,13 +400,13 @@ extern unsigned long __must_check __asm_copy_from_user(void *to,
> > static inline unsigned long
> > raw_copy_from_user(void *to, const void __user *from, unsigned long n)
> > {
> > - return __asm_copy_to_user(to, from, n);
> > + return __asm_copy_from_user(to, from, n);
> > }
> >
> > static inline unsigned long
> > raw_copy_to_user(void __user *to, const void *from, unsigned long n)
> > {
> > - return __asm_copy_from_user(to, from, n);
> > + return __asm_copy_to_user(to, from, n);
> > }
> >
> > extern long strncpy_from_user(char *dest, const char __user *src, long count);
>
> Oh, no idea how I missed that one. This looks like it's been in for a long
> time, so I'm surprised anything works at all!
Actually, it boils down to a memcpy either way, it's just that
exceptions and access control isn't handled right. So as long as you
always do valid copying you'll luck out.
> I'm going to add a stable CC and PR this to Linus this week, assuming I get
> some time to at least give it a minimal test.
>
> Thanks for catching this!
Cool, sounds good.
-Olof
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RISC-V: Fix raw_copy_{to,from}_user()
2018-11-15 20:27 ` Olof Johansson
@ 2018-11-15 20:27 ` Olof Johansson
0 siblings, 0 replies; 6+ messages in thread
From: Olof Johansson @ 2018-11-15 20:27 UTC (permalink / raw)
To: Palmer Dabbelt; +Cc: linux-riscv, Albert Ou, Linux Kernel Mailing List
On Thu, Nov 15, 2018 at 6:59 AM Palmer Dabbelt <palmer@sifive.com> wrote:
>
> On Wed, 14 Nov 2018 16:27:55 PST (-0800), Olof Johansson wrote:
> > Sparse highlighted it, and appears to be a pure bug (from vs to).
> >
> > ./arch/riscv/include/asm/uaccess.h:403:35: warning: incorrect type in argument 1 (different address spaces)
> > ./arch/riscv/include/asm/uaccess.h:403:39: warning: incorrect type in argument 2 (different address spaces)
> > ./arch/riscv/include/asm/uaccess.h:409:37: warning: incorrect type in argument 1 (different address spaces)
> > ./arch/riscv/include/asm/uaccess.h:409:41: warning: incorrect type in argument 2 (different address spaces)
> >
> > Signed-off-by: Olof Johansson <olof@lixom.net>
> > ---
> > arch/riscv/include/asm/uaccess.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
> > index 473cfc84e412f..8c3e3e3c8be12 100644
> > --- a/arch/riscv/include/asm/uaccess.h
> > +++ b/arch/riscv/include/asm/uaccess.h
> > @@ -400,13 +400,13 @@ extern unsigned long __must_check __asm_copy_from_user(void *to,
> > static inline unsigned long
> > raw_copy_from_user(void *to, const void __user *from, unsigned long n)
> > {
> > - return __asm_copy_to_user(to, from, n);
> > + return __asm_copy_from_user(to, from, n);
> > }
> >
> > static inline unsigned long
> > raw_copy_to_user(void __user *to, const void *from, unsigned long n)
> > {
> > - return __asm_copy_from_user(to, from, n);
> > + return __asm_copy_to_user(to, from, n);
> > }
> >
> > extern long strncpy_from_user(char *dest, const char __user *src, long count);
>
> Oh, no idea how I missed that one. This looks like it's been in for a long
> time, so I'm surprised anything works at all!
Actually, it boils down to a memcpy either way, it's just that
exceptions and access control isn't handled right. So as long as you
always do valid copying you'll luck out.
> I'm going to add a stable CC and PR this to Linus this week, assuming I get
> some time to at least give it a minimal test.
>
> Thanks for catching this!
Cool, sounds good.
-Olof
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-11-15 20:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-15 0:27 [PATCH] RISC-V: Fix raw_copy_{to,from}_user() Olof Johansson
2018-11-15 0:27 ` Olof Johansson
2018-11-15 14:59 ` Palmer Dabbelt
2018-11-15 14:59 ` Palmer Dabbelt
2018-11-15 20:27 ` Olof Johansson
2018-11-15 20:27 ` Olof Johansson
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).