1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) IBM Corporation, 2010
6 * Author: Anton Blanchard <anton@au.ibm.com>
8 #include <linux/export.h>
9 #include <linux/compiler.h>
10 #include <linux/types.h>
11 #include <asm/checksum.h>
12 #include <linux/uaccess.h>
14 __wsum
csum_and_copy_from_user(const void __user
*src
, void *dst
,
21 if (unlikely(!access_ok(src
, len
)))
24 allow_read_from_user(src
, len
);
26 csum
= csum_partial_copy_generic((void __force
*)src
, dst
, len
);
28 prevent_read_from_user(src
, len
);
31 EXPORT_SYMBOL(csum_and_copy_from_user
);
33 __wsum
csum_and_copy_to_user(const void *src
, void __user
*dst
, int len
)
38 if (unlikely(!access_ok(dst
, len
)))
41 allow_write_to_user(dst
, len
);
43 csum
= csum_partial_copy_generic(src
, (void __force
*)dst
, len
);
45 prevent_write_to_user(dst
, len
);
48 EXPORT_SYMBOL(csum_and_copy_to_user
);