diff mbox series

[PATCHv3,10/17] arm64: uaccess: simplify __copy_user_flushcache()

Message ID 20201026133156.44186-11-mark.rutland@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64: remove set_fs() and friends | expand

Commit Message

Mark Rutland Oct. 26, 2020, 1:31 p.m. UTC
Currently __copy_user_flushcache() open-codes raw_copy_from_user(), and
doesn't use uaccess_mask_ptr() on the user address. Let's have it call
raw_copy_from_user(), which is both a simplification and ensures that
user pointers are masked under speculation.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/lib/uaccess_flushcache.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Robin Murphy Oct. 27, 2020, 5:33 p.m. UTC | #1
On 2020-10-26 13:31, Mark Rutland wrote:
> Currently __copy_user_flushcache() open-codes raw_copy_from_user(), and
> doesn't use uaccess_mask_ptr() on the user address. Let's have it call
> raw_copy_from_user(), which is both a simplification and ensures that
> user pointers are masked under speculation.

I think this originally stems from the fact that "raw_*" were merely 
generic aliases for "__arch_*" at the time. Then whichever chump 
subsequently implemented uaccess_mask_ptr() for arm64 clearly did a 
terrible job... ;)

> There should be no functional change as a result of this patch.

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Will Deacon <will@kernel.org>
> ---
>   arch/arm64/lib/uaccess_flushcache.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/lib/uaccess_flushcache.c b/arch/arm64/lib/uaccess_flushcache.c
> index bfa30b75b2b8e..c83bb5a4aad2c 100644
> --- a/arch/arm64/lib/uaccess_flushcache.c
> +++ b/arch/arm64/lib/uaccess_flushcache.c
> @@ -30,9 +30,7 @@ unsigned long __copy_user_flushcache(void *to, const void __user *from,
>   {
>   	unsigned long rc;
>   
> -	uaccess_enable_not_uao();
> -	rc = __arch_copy_from_user(to, from, n);
> -	uaccess_disable_not_uao();
> +	rc = raw_copy_from_user(to, from, n);
>   
>   	/* See above */
>   	__clean_dcache_area_pop(to, n - rc);
>
Mark Rutland Nov. 2, 2020, 10:14 a.m. UTC | #2
On Tue, Oct 27, 2020 at 05:33:31PM +0000, Robin Murphy wrote:
> On 2020-10-26 13:31, Mark Rutland wrote:
> > Currently __copy_user_flushcache() open-codes raw_copy_from_user(), and
> > doesn't use uaccess_mask_ptr() on the user address. Let's have it call
> > raw_copy_from_user(), which is both a simplification and ensures that
> > user pointers are masked under speculation.
> 
> I think this originally stems from the fact that "raw_*" were merely generic
> aliases for "__arch_*" at the time. Then whichever chump subsequently
> implemented uaccess_mask_ptr() for arm64 clearly did a terrible job... ;)

:)

> > There should be no functional change as a result of this patch.
> 
> Reviewed-by: Robin Murphy <robin.murphy@arm.com>

Thanks!

Mark.

> 
> > Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> > Cc: Catalin Marinas <catalin.marinas@arm.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Cc: Robin Murphy <robin.murphy@arm.com>
> > Cc: Will Deacon <will@kernel.org>
> > ---
> >   arch/arm64/lib/uaccess_flushcache.c | 4 +---
> >   1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/arch/arm64/lib/uaccess_flushcache.c b/arch/arm64/lib/uaccess_flushcache.c
> > index bfa30b75b2b8e..c83bb5a4aad2c 100644
> > --- a/arch/arm64/lib/uaccess_flushcache.c
> > +++ b/arch/arm64/lib/uaccess_flushcache.c
> > @@ -30,9 +30,7 @@ unsigned long __copy_user_flushcache(void *to, const void __user *from,
> >   {
> >   	unsigned long rc;
> > -	uaccess_enable_not_uao();
> > -	rc = __arch_copy_from_user(to, from, n);
> > -	uaccess_disable_not_uao();
> > +	rc = raw_copy_from_user(to, from, n);
> >   	/* See above */
> >   	__clean_dcache_area_pop(to, n - rc);
> >
diff mbox series

Patch

diff --git a/arch/arm64/lib/uaccess_flushcache.c b/arch/arm64/lib/uaccess_flushcache.c
index bfa30b75b2b8e..c83bb5a4aad2c 100644
--- a/arch/arm64/lib/uaccess_flushcache.c
+++ b/arch/arm64/lib/uaccess_flushcache.c
@@ -30,9 +30,7 @@  unsigned long __copy_user_flushcache(void *to, const void __user *from,
 {
 	unsigned long rc;
 
-	uaccess_enable_not_uao();
-	rc = __arch_copy_from_user(to, from, n);
-	uaccess_disable_not_uao();
+	rc = raw_copy_from_user(to, from, n);
 
 	/* See above */
 	__clean_dcache_area_pop(to, n - rc);