BPF List
 help / color / mirror / Atom feed
From: Martin Kelly <martin.kelly@crowdstrike.com>
To: "bpf@vger.kernel.org" <bpf@vger.kernel.org>
Cc: "daniel@iogearbox.net" <daniel@iogearbox.net>,
	"ast@kernel.org" <ast@kernel.org>,
	"andrii@kernel.org" <andrii@kernel.org>,
	"john.fastabend@gmail.com" <john.fastabend@gmail.com>
Subject: CONFIG_X86_X32_ABI silently breaks some fentry hooks
Date: Wed, 9 Oct 2024 18:58:53 +0000	[thread overview]
Message-ID: <7136605d24de9b1fc62d02a355ef11c950a94153.camel@crowdstrike.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1680 bytes --]

Hi all, I want to report a very strange issues I found. Specifically,
on latest master, I found that setting CONFIG_X86_X32_ABI=y causes some
fentry BPF hooks to be silently ignored. Most hooks still work fine,
but some do not, and the same function works fine as a kprobe. The
issue appears to be 100% reproducible for a given function hook.

I checked and verified that the hook is not hit according to the BPF
stats (kernel.bpf_stats_enabled=1), and I also didn't see the program
getting run when it should in gdb. As far as I can tell from gdb, the
trampoline code is still getting patched in, but the BPF program is not
later getting invoked.

The steps I used to reproduce are as follows:
- Checkout latest master. I tested with 75b607fab38d ("Merge tag
'sched_ext-for-6.12-rc2-fixes'").
- make localmodconfig or similar, enabling relevant BPF options for
trampolines and BTF. I can send the full config I used if that's
helpful, but I think most config options don't affect this.
- Set CONFIG_X86_X32_ABI=y
- Compile and boot the kernel and run the following bpftrace command:
  bpftrace -e 'kfunc:acct_process { printf("acct_process called\n"); }'
- In another terminal, run some processes, which should normally cause
some output from this command. You should get no output.

Note that a similar command (bpftrace -e 'kfunc:acct_collect {
printf("acct_collect called\n"); }'), hooking a similar function called
in the same code path, still produces output, as does a kprobe of
acct_process (sudo bpftrace -e 'kprobe:acct_process {
printf("acct_process called\n"); }'). Also, with CONFIG_X86_X32_ABI=n,
the acct_process hook works correctly.

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5104 bytes --]

             reply	other threads:[~2024-10-09 19:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-09 18:58 Martin Kelly [this message]
2024-12-06 23:08 ` CONFIG_X86_X32_ABI silently breaks some fentry hooks Martin Kelly

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=7136605d24de9b1fc62d02a355ef11c950a94153.camel@crowdstrike.com \
    --to=martin.kelly@crowdstrike.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    /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