lkml.org 
[lkml]   [2020]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v2 2/3] lib, uaccess: add failure injection to usercopy functions
On Fri, Aug 28, 2020 at 02:13:43PM +0000, albert.linde@gmail.com 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.

\
 
 \ /
  Last update: 2020-08-31 18:22    [W:0.050 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site