linux-trace-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: alexandre.ferrieux@orange.com
Cc: linux-trace-users@vger.kernel.org
Subject: Re: Ftrace, KASLR and gdb
Date: Mon, 13 May 2024 12:25:22 -0400	[thread overview]
Message-ID: <20240513122522.5c80ab0f@rorschach.local.home> (raw)
In-Reply-To: <738bfcbf-3f46-4ef4-8f10-057000bf07f6@orange.com>

On Sun, 12 May 2024 00:44:27 +0200
alexandre.ferrieux@orange.com wrote:

> 
> The problem is rather, on the gdb side, with a production kernel (not the one 
> you've just compiled), on a random machine you have a passing access to. First, 
> the kernel itself is compressed (vmlinuz), and in many cases getting the vmlinux 
> is a pain. So, what ELF binary do you pass to gdb ?
> 
> In my case:
> 
>    sym2elf /proc/kallsyms > /tmp/kallsyms.elf
>    gdb /tmp/kallsyms.elf /proc/kcore
>    (gdb) disass vfs_write

Ah, so you are running gdb on the live kernel.

>    ...
> 
> As an added bonus, I see (a snapshot of) globals:
> 
>    (gdb) p *(int *)jiffies
>    $1 = 92299928
> 
> And also I see ftrace's surgical changes if by accident I disassemble a function 
> I currently am sniffing ;-)
> 
>     echo "p:kprobe_tpacket_rcv tpacket_rcv+26 skb=%di:x64" >> kprobe_events
>     (gdb) disass tcpaket_rcv
>     Dump of assembler code for function tpacket_rcv:
>       0xffffffffb9d79e10 <+0>:     endbr64
>       ...
>       0xffffffffb9d79e2a <+26>:    jmp    0xffffffffc1389000 <kprobe_optinsn_page>
> 
> Of course the latter only serves my curiosity; but it shows I'm looking at the 
> "live" code. It matters in other cases of dynamic code, like static branches.

Yep.

> 
> So, is there currently another method to reach the same effect ?

Besides kgdb (usually another machine connected to the live kernel),
this is probably the only way to do what you want.

-- Steve

  reply	other threads:[~2024-05-13 16:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09 12:44 Ftrace, KASLR and gdb alexandre.ferrieux
2024-05-10 18:12 ` Steven Rostedt
2024-05-11 22:44   ` alexandre.ferrieux
2024-05-13 16:25     ` Steven Rostedt [this message]
2024-05-13 18:26       ` alexandre.ferrieux

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=20240513122522.5c80ab0f@rorschach.local.home \
    --to=rostedt@goodmis.org \
    --cc=alexandre.ferrieux@orange.com \
    --cc=linux-trace-users@vger.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;
as well as URLs for NNTP newsgroup(s).