public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Alexandre Chartre <alexandre.chartre@oracle.com>,
	kernel test robot <rong.a.chen@intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	lkp@lists.01.org, Thomas Gleixner <tglx@linutronix.de>,
	ltp@lists.linux.it
Subject: Re: [LTP] [x86/entry] 2bbc68f837: ltp.ptrace08.fail
Date: Wed, 12 Aug 2020 11:31:14 +0200	[thread overview]
Message-ID: <20200812093114.GA13676@yuki.lan> (raw)
In-Reply-To: <CALCETrVX=wxRrv0qw-Enbyg5CEQsy5TigbNt7sSs=MDO6uAnMw@mail.gmail.com>

Hi!
> do_debug is a bit of a red herring here.  ptrace should not be able to
> put a breakpoint on a kernel address, period.  I would just pick a
> fixed address that's in the kernel text range or even just in the
> pre-KASLR text range and make sure it gets rejected.  Maybe try a few
> different addresses for good measure.

I've looked at the code and it seems like this would be a bit more
complicated since the breakpoint is set by an accident in a race and the
call still fails. Which is why the test triggers the breakpoint and
causes infinite loop in the kernel...

I guess that we could instead read back the address with
PTRACE_PEEKUSER, so something as:


break_addr = ptrace(PTRACE_PEEKUSER, child_pid,
                    (void *)offsetof(struct user, u_debugreg[0]),
                    NULL);

if (break_addr == kernel_addr)
	tst_res(TFAIL, "ptrace() set break on a kernel address");

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2020-08-12  9:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200616075533.GL5653@shao2-debian>
2020-06-16  8:44 ` [x86/entry] 2bbc68f837: ltp.ptrace08.fail Thomas Gleixner
2020-06-16 12:24   ` [LKP] " Rong Chen
     [not found]   ` <8E41B15F-D567-4C52-94E9-367015480345@amacapital.net>
2020-06-16 13:27     ` Peter Zijlstra
2020-06-17 13:17       ` [LTP] " Cyril Hrubis
2020-06-18 18:20         ` Andy Lutomirski
2020-08-12  9:31           ` Cyril Hrubis [this message]
2020-08-14 14:58             ` Cyril Hrubis
2020-08-14 16:42               ` Andy Lutomirski
2020-06-18 20:02         ` Thomas Gleixner
2020-06-22 10:16           ` [LKP] " Naresh Kamboju
2020-06-16 14:57     ` 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=20200812093114.GA13676@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=alexandre.chartre@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@lists.01.org \
    --cc=ltp@lists.linux.it \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rong.a.chen@intel.com \
    --cc=tglx@linutronix.de \
    /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