mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: peterz@infradead.org
To: albert.linde@gmail.com
Cc: akpm@linux-foundation.org, bp@alien8.de, mingo@redhat.com,
	corbet@lwn.net, tglx@linutronix.de, arnd@arndb.de,
	akinobu.mita@gmail.com, hpa@zytor.com, viro@zeniv.linux.org.uk,
	glider@google.com, andreyknvl@google.com, dvyukov@google.com,
	elver@google.com, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	x86@kernel.org, Albert van der Linde <alinde@google.com>
Subject: Re: [PATCH v2 2/3] lib, uaccess: add failure injection to usercopy functions
Date: Mon, 31 Aug 2020 18:21:50 +0200	[thread overview]
Message-ID: <20200831162150.GR1362448@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200828141344.2277088-3-alinde@google.com>

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.

  reply	other threads:[~2020-08-31 16:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-28 14:13 [PATCH v2 0/3] add fault injection to user memory access albert.linde
2020-08-28 14:13 ` [PATCH v2 1/3] lib, include/linux: add usercopy failure capability albert.linde
2020-08-28 14:13 ` [PATCH v2 2/3] lib, uaccess: add failure injection to usercopy functions albert.linde
2020-08-31 16:21   ` peterz [this message]
2020-08-28 14:13 ` [PATCH v2 3/3] x86: add failure injection to get/put/clear_user albert.linde
2020-08-31 14:29 ` [PATCH v2 0/3] add fault injection to user memory access Akinobu Mita
2020-08-31 15:49   ` Alexander Potapenko
2020-08-31 16:27     ` Akinobu Mita
2020-08-31 18:31       ` Alexander Potapenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200831162150.GR1362448@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=albert.linde@gmail.com \
    --cc=alinde@google.com \
    --cc=andreyknvl@google.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=corbet@lwn.net \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®