Re: [PATCH v2 2/3] lib, uaccess: add failure injection to usercopy functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 28, 2020 at 02:13:43PM +0000, albert.linde@xxxxxxxxx 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.



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux