linux/arch/powerpc/lib/checksum_wrappers.c
Christophe Leroy 164dc6ce36 powerpc/net: Switch csum_and_copy_{to/from}_user to user_access block
Use user_access_begin() instead of the
might_sleep/access_ok/allow_access sequence.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/2dee286d2d6dc9a27d99e31ac564bad4fae2cb49.1615398498.git.christophe.leroy@csgroup.eu
2021-03-26 23:19:43 +11:00

42 lines
891 B
C

// SPDX-License-Identifier: GPL-2.0-or-later
/*
*
* Copyright (C) IBM Corporation, 2010
*
* Author: Anton Blanchard <anton@au.ibm.com>
*/
#include <linux/export.h>
#include <linux/compiler.h>
#include <linux/types.h>
#include <asm/checksum.h>
#include <linux/uaccess.h>
__wsum csum_and_copy_from_user(const void __user *src, void *dst,
int len)
{
__wsum csum;
if (unlikely(!user_read_access_begin(src, len)))
return 0;
csum = csum_partial_copy_generic((void __force *)src, dst, len);
user_read_access_end();
return csum;
}
EXPORT_SYMBOL(csum_and_copy_from_user);
__wsum csum_and_copy_to_user(const void *src, void __user *dst, int len)
{
__wsum csum;
if (unlikely(!user_write_access_begin(dst, len)))
return 0;
csum = csum_partial_copy_generic(src, (void __force *)dst, len);
user_write_access_end();
return csum;
}
EXPORT_SYMBOL(csum_and_copy_to_user);