public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [x86/entry] 2bbc68f837: ltp.ptrace08.fail
Date: Fri, 14 Aug 2020 16:58:23 +0200	[thread overview]
Message-ID: <20200814145823.GA13646@yuki.lan> (raw)
In-Reply-To: <20200812093114.GA13676@yuki.lan>

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");

So this works actually nicely, even better than the original code.

Any hints on how to select a fixed address in the kernel range as you
pointed out in one of the previous emails? I guess that this would end
up as a per-architecture mess of ifdefs if we wanted to hardcode it.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2020-08-14 14:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16  7:55 [LTP] [x86/entry] 2bbc68f837: ltp.ptrace08.fail kernel test robot
2020-06-16  8:44 ` Thomas Gleixner
2020-06-16 12:24   ` [LTP] [LKP] " Rong Chen
2020-06-16 13:22   ` [LTP] " Andy Lutomirski
2020-06-16 13:27     ` Peter Zijlstra
2020-06-17 13:17       ` Cyril Hrubis
2020-06-18 18:20         ` Andy Lutomirski
2020-08-12  9:31           ` Cyril Hrubis
2020-08-14 14:58             ` Cyril Hrubis [this message]
2020-08-14 16:42               ` Andy Lutomirski
2020-06-18 20:02         ` Thomas Gleixner
2020-06-22 10:16           ` [LTP] [LKP] " Naresh Kamboju
2020-06-16 14:57     ` [LTP] " 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=20200814145823.GA13646@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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