mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"H.J. Lu" <hjl.tools@gmail.com>,
	x86@kernel.org, Christoph Hellwig <hch@lst.de>,
	Josh Poimboeuf <jpoimboe@redhat.com>
Subject: Re: [PATCH] x86/dumpstack: Dump user space code correctly again
Date: Thu, 23 Jul 2020 10:19:00 +0200	[thread overview]
Message-ID: <20200723081900.GA16138@lst.de> (raw)
In-Reply-To: <87h7tz306w.fsf@nanos.tec.linutronix.de>

On Wed, Jul 22, 2020 at 07:54:15PM +0200, Thomas Gleixner wrote:
> Subject: x86/dumpstack: Dump user space code correctly again
> From: Thomas Gleixner <tglx@linutronix.de>
> Date: Wed, 22 Jul 2020 10:39:54 +0200
> 
> H.J. reported that post 5.7 a segfault of a user space task does not longer
> dump the Code bytes when /proc/sys/debug/exception-trace is enabled. It
> prints 'Code: Bad RIP value.' instead.
> 
> This was broken by a recent change which made probe_kernel_read() reject
> non-kernel addresses.
> 
> Update show_opcodes() so it retrieves user space opcodes via
> copy_from_user_nmi().
> 
> Fixes: 98a23609b103 ("maccess: always use strict semantics for probe_kernel_read")
> Reported-by: H.J. Lu <hjl.tools@gmail.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Looks good, and also cleans up the code nicely:

Reviewed-by: Christoph Hellwig <hch@lst.de>

But one question below:

> +	/*
> +	 * Make sure userspace isn't trying to trick us into dumping kernel
> +	 * memory by pointing the userspace instruction pointer at it.
> +	 */
> +	if (__chk_range_not_ok(src, nbytes, TASK_SIZE_MAX))
> +		return -EINVAL;
> +
> +	return copy_from_user_nmi(buf, (void __user *)src, nbytes);

copy_from_user_nmi already contains a:

	if (__range_not_ok(from, n, TASK_SIZE))
		return n;

what is the reason it checks for TASK_SIZE vs TASK_SIZE_MAX, and why
do we need both checks?

  parent reply	other threads:[~2020-07-23  8:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-208655-6666@https.bugzilla.kernel.org/>
     [not found] ` <87h7tz306w.fsf@nanos.tec.linutronix.de>
2020-07-22 18:04   ` H.J. Lu
2020-07-22 19:47     ` Thomas Gleixner
2020-07-22 21:22       ` H.J. Lu
2020-07-22 21:55   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2020-07-23  8:19   ` Christoph Hellwig [this message]
2020-07-23 11:05     ` [PATCH] " Thomas Gleixner

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=20200723081900.GA16138@lst.de \
    --to=hch@lst.de \
    --cc=hjl.tools@gmail.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --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

Powered by JetHome