mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-04 04:44:37 +08:00
9e94fdade4
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> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20201202131558.39270-6-mark.rutland@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
39 lines
906 B
C
39 lines
906 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2017 ARM Ltd.
|
|
*/
|
|
|
|
#include <linux/uaccess.h>
|
|
#include <asm/barrier.h>
|
|
#include <asm/cacheflush.h>
|
|
|
|
void memcpy_flushcache(void *dst, const void *src, size_t cnt)
|
|
{
|
|
/*
|
|
* We assume this should not be called with @dst pointing to
|
|
* non-cacheable memory, such that we don't need an explicit
|
|
* barrier to order the cache maintenance against the memcpy.
|
|
*/
|
|
memcpy(dst, src, cnt);
|
|
__clean_dcache_area_pop(dst, cnt);
|
|
}
|
|
EXPORT_SYMBOL_GPL(memcpy_flushcache);
|
|
|
|
void memcpy_page_flushcache(char *to, struct page *page, size_t offset,
|
|
size_t len)
|
|
{
|
|
memcpy_flushcache(to, page_address(page) + offset, len);
|
|
}
|
|
|
|
unsigned long __copy_user_flushcache(void *to, const void __user *from,
|
|
unsigned long n)
|
|
{
|
|
unsigned long rc;
|
|
|
|
rc = raw_copy_from_user(to, from, n);
|
|
|
|
/* See above */
|
|
__clean_dcache_area_pop(to, n - rc);
|
|
return rc;
|
|
}
|