On Fri, Aug 28, 2020 at 02:13:43PM +0000, [email protected] wrote:
> @@ -82,6 +83,8 @@ __copy_from_user_inatomic(void *to, const void __user
> *from, unsigned long n)
> static __always_inline __must_check unsigned long
> __copy_from_user(void *to, const void __user *from, unsigned long n)
> {
> + if (should_fail_usercopy())
> + return n;
> might_fault();
> instrument_copy_from_user(to, from, n);
> check_object_size(to, n, false);
> @@ -124,7 +131,7 @@ _copy_from_user(void *to, const void __user *from,
> unsigned long n)
> {
> unsigned long res = n;
> might_fault();
> - if (likely(access_ok(from, n))) {
> + if (!should_fail_usercopy() && likely(access_ok(from, n))) {
> instrument_copy_from_user(to, from, n);
> res = raw_copy_from_user(to, from, n);
> }
You're inconsistent with your order against might_fault() throughout the
patch. After is the right place.