public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Song Liu <song@kernel.org>, Song Liu <songliubraving@meta.com>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	X86 ML <x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
	"David S. Miller" <davem@davemloft.net>,
	David Ahern <dsahern@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Sami Tolvanen <samitolvanen@google.com>,
	Kees Cook <keescook@chromium.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	linux-riscv <linux-riscv@lists.infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Network Development <netdev@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	clang-built-linux <llvm@lists.linux.dev>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Joao Moreira <joao@overdrivepizza.com>,
	Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH v2 2/2] x86/cfi,bpf: Fix BPF JIT call
Date: Mon, 4 Dec 2023 18:25:34 +0100	[thread overview]
Message-ID: <ZW4LjmUKj1q6RWdL@krava> (raw)
In-Reply-To: <20231204125239.GA1319@noisy.programming.kicks-ass.net>

On Mon, Dec 04, 2023 at 01:52:39PM +0100, Peter Zijlstra wrote:
> On Mon, Dec 04, 2023 at 12:11:28PM +0100, Peter Zijlstra wrote:
> > On Mon, Dec 04, 2023 at 10:13:34AM +0100, Peter Zijlstra wrote:
> > 
> > > > Just running test_progs it splats right away:
> > > > 
> > > > [   74.047757] kmemleak: Found object by alias at 0xffffffffa0001d80
> > > > [   74.048272] CPU: 14 PID: 104 Comm: kworker/14:0 Tainted: G        W
> > > >  O       6.7.0-rc3-00702-g41c30fec304d-dirty #5241
> > > > [   74.049118] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
> > > > BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
> > > > [   74.050042] Workqueue: events bpf_prog_free_deferred
> > > > [   74.050448] Call Trace:
> > > > [   74.050663]  <TASK>
> > > > [   74.050841]  dump_stack_lvl+0x55/0x80
> > > > [   74.051141]  __find_and_remove_object+0xdb/0x110
> > > > [   74.051521]  kmemleak_free+0x41/0x70
> > > > [   74.051828]  vfree+0x36/0x130
> > > 
> > > Durr, I'll see if I can get that stuff running locally, and otherwise
> > > play with the robot as you suggested. Thanks!
> > 
> > I think it is bpf_jit_binary_pack_hdr(), which is using prog->bpf_func
> > as a start address for the image, instead of jit_data->image.
> > 
> > This used to be true, but now it's offset.
> > 
> > Let me see what to do about that...
> 
> Not the prettiest of things, but the below seems to make the thing
> happy...
> 

hyea,
that boots properly for me but gives crash below when running bpf tests

jirka


---
[  482.145182][  T699] RIP: 0010:bpf_for_each_array_elem+0xbb/0x120
[  482.145672][  T699] Code: 4c 01 f5 89 5c 24 04 4c 89 e7 48 8d 74 24 04 48 89 ea 4c 89 fd 4c 89 f9 45 31 c0 4d 89 eb 41 ba ef 86 cd 67 45 03 53 f1 74 02 <0f> 0b 41 ff d3 0f 1f 00 48 85 c0 75 0e 48 8d 43 01 41 8b 4c 24 24
[  482.147221][  T699] RSP: 0018:ffffc900017e3e88 EFLAGS: 00010217
[  482.147702][  T699] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffc900017e3ed8
[  482.152162][  T699] RDX: ffff888152eb0210 RSI: ffffc900017e3e8c RDI: ffff888152eb0000
[  482.152770][  T699] RBP: ffffc900017e3ed8 R08: 0000000000000000 R09: 0000000000000000
[  482.153350][  T699] R10: 000000004704ef28 R11: ffffffffa0012774 R12: ffff888152eb0000
[  482.153951][  T699] R13: ffffffffa0012774 R14: ffff888152eb0210 R15: ffffc900017e3ed8
[  482.154554][  T699] FS:  00007fa60d4fdd00(0000) GS:ffff88846d200000(0000) knlGS:0000000000000000
[  482.155138][  T699] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  482.155564][  T699] CR2: 00007fa60d7d8000 CR3: 00000001502a2005 CR4: 0000000000770ef0
[  482.156095][  T699] PKRU: 55555554
[  482.156349][  T699] Call Trace:
[  482.156596][  T699]  <TASK>
[  482.156816][  T699]  ? __die_body+0x68/0xb0
[  482.157138][  T699]  ? die+0xba/0xe0
[  482.157456][  T699]  ? do_trap+0xa5/0x180
[  482.157826][  T699]  ? bpf_for_each_array_elem+0xbb/0x120
[  482.158277][  T699]  ? bpf_for_each_array_elem+0xbb/0x120
[  482.158711][  T699]  ? do_error_trap+0xc4/0x140
[  482.159052][  T699]  ? bpf_for_each_array_elem+0xbb/0x120
[  482.159506][  T699]  ? handle_invalid_op+0x2c/0x40
[  482.159906][  T699]  ? bpf_for_each_array_elem+0xbb/0x120
[  482.160990][  T699]  ? exc_invalid_op+0x38/0x60
[  482.161375][  T699]  ? asm_exc_invalid_op+0x1a/0x20
[  482.161788][  T699]  ? 0xffffffffa0012774
[  482.162149][  T699]  ? 0xffffffffa0012774
[  482.162513][  T699]  ? bpf_for_each_array_elem+0xbb/0x120
[  482.162905][  T699]  bpf_prog_ca45ea7f9cb8ac1a_inner_map+0x94/0x98
[  482.163471][  T699]  bpf_trampoline_6442549234+0x47/0x1000
[  482.163981][  T699]  __x64_sys_getpgid+0x9/0x20
[  482.164770][  T699]  do_syscall_64+0x53/0x110
[  482.165184][  T699]  entry_SYSCALL_64_after_hwframe+0x6e/0x76
[  482.165646][  T699] RIP: 0033:0x7fa60d6c5b4d
[  482.166005][  T699] Code: c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 8b 92 0c 00 f7 d8 64 89 01 48
[  482.169662][  T699] RSP: 002b:00007ffddfcf99e8 EFLAGS: 00000202 ORIG_RAX: 0000000000000079
[  482.170582][  T699] RAX: ffffffffffffffda RBX: 00007ffddfcf9d98 RCX: 00007fa60d6c5b4d
[  482.171376][  T699] RDX: 0000000000000002 RSI: 0000000000000000 RDI: 0000557baa5ab850
[  482.172010][  T699] RBP: 00007ffddfcf9b30 R08: 0000000000000000 R09: 0000000000000000
[  482.172665][  T699] R10: 0000000000000064 R11: 0000000000000202 R12: 0000000000000001
[  482.173359][  T699] R13: 0000000000000000 R14: 00007fa60d80d000 R15: 0000557ba6ab9790
[  482.174014][  T699]  </TASK>
[  482.174289][  T699] Modules linked in: bpf_testmod(OE) intel_rapl_msr intel_rapl_common crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel kvm_intel rapl iTCO_wdt iTCO_vendor_support i2c_i801 i2c_smbus lpc_ich drm loop drm_panel_orientation_quirks zram
[  482.176040][  T699] ---[ end trace 0000000000000000 ]---
[  482.176534][  T699] RIP: 0010:bpf_for_each_array_elem+0xbb/0x120
[  482.177215][  T699] Code: 4c 01 f5 89 5c 24 04 4c 89 e7 48 8d 74 24 04 48 89 ea 4c 89 fd 4c 89 f9 45 31 c0 4d 89 eb 41 ba ef 86 cd 67 45 03 53 f1 74 02 <0f> 0b 41 ff d3 0f 1f 00 48 85 c0 75 0e 48 8d 43 01 41 8b 4c 24 24
[  482.179405][  T699] RSP: 0018:ffffc900017e3e88 EFLAGS: 00010217
[  482.179971][  T699] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffc900017e3ed8
[  482.180615][  T699] RDX: ffff888152eb0210 RSI: ffffc900017e3e8c RDI: ffff888152eb0000
[  482.181195][  T699] RBP: ffffc900017e3ed8 R08: 0000000000000000 R09: 0000000000000000
[  482.181805][  T699] R10: 000000004704ef28 R11: ffffffffa0012774 R12: ffff888152eb0000
[  482.182411][  T699] R13: ffffffffa0012774 R14: ffff888152eb0210 R15: ffffc900017e3ed8
[  482.183043][  T699] FS:  00007fa60d4fdd00(0000) GS:ffff88846d200000(0000) knlGS:0000000000000000
[  482.183753][  T699] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  482.184361][  T699] CR2: 00007fa60d7d8000 CR3: 00000001502a2005 CR4: 0000000000770ef0
[  482.185649][  T699] PKRU: 55555554
[  482.185985][  T699] BUG: sleeping function called from invalid context at include/linux/percpu-rwsem.h:49
[  482.186846][  T699] in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 699, name: test_progs
[  482.187590][  T699] preempt_count: 0, expected: 0
[  482.188055][  T699] RCU nest depth: 1, expected: 0
[  482.188460][  T699] INFO: lockdep is turned off.
[  482.188861][  T699] CPU: 1 PID: 699 Comm: test_progs Tainted: G      D    OE      6.7.0-rc3+ #118 bfe8e46ac948d811e03ae3149ad95ea179efe638
[  482.189821][  T699] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-1.fc38 04/01/2014
[  482.191140][  T699] Call Trace:
[  482.191469][  T699]  <TASK>
[  482.191766][  T699]  dump_stack_lvl+0xbd/0x120
[  482.192222][  T699]  __might_resched+0x24a/0x280
[  482.192694][  T699]  exit_signals+0x31/0x280
[  482.193123][  T699]  do_exit+0x1a6/0xbb0
[  482.193511][  T699]  ? bpf_trampoline_6442549234+0x47/0x1000
[  482.194025][  T699]  make_task_dead+0x94/0x180
[  482.194469][  T699]  rewind_stack_and_make_dead+0x17/0x20
[  482.194968][  T699] RIP: 0033:0x7fa60d6c5b4d
[  482.195399][  T699] Code: c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 8b 92 0c 00 f7 d8 64 89 01 48
[  482.197082][  T699] RSP: 002b:00007ffddfcf99e8 EFLAGS: 00000202 ORIG_RAX: 0000000000000079
[  482.197887][  T699] RAX: ffffffffffffffda RBX: 00007ffddfcf9d98 RCX: 00007fa60d6c5b4d
[  482.198604][  T699] RDX: 0000000000000002 RSI: 0000000000000000 RDI: 0000557baa5ab850
[  482.199327][  T699] RBP: 00007ffddfcf9b30 R08: 0000000000000000 R09: 0000000000000000
[  482.200035][  T699] R10: 0000000000000064 R11: 0000000000000202 R12: 0000000000000001
[  482.200765][  T699] R13: 0000000000000000 R14: 00007fa60d80d000 R15: 0000557ba6ab9790
[  482.201499][  T699]  </TASK>

  reply	other threads:[~2023-12-04 17:25 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 13:36 [PATCH v2 0/2] x86/bpf: Fix FineIBT vs eBPF Peter Zijlstra
2023-11-30 13:36 ` [PATCH v2 1/2] cfi: Flip headers Peter Zijlstra
2023-12-04 19:18   ` Sami Tolvanen
2023-11-30 13:36 ` [PATCH v2 2/2] x86/cfi,bpf: Fix BPF JIT call Peter Zijlstra
2023-12-03 22:56   ` Alexei Starovoitov
2023-12-04  9:13     ` Peter Zijlstra
2023-12-04 11:11       ` Peter Zijlstra
2023-12-04 12:52         ` Peter Zijlstra
2023-12-04 17:25           ` Jiri Olsa [this message]
2023-12-04 18:16             ` Peter Zijlstra
2023-12-04 18:33               ` Peter Zijlstra
2023-12-04 18:58                 ` Sami Tolvanen
2023-12-05  1:18                 ` Alexei Starovoitov
2023-12-06 15:35                   ` Peter Zijlstra
2023-12-06 16:38                   ` Peter Zijlstra
2023-12-06 18:37                     ` Peter Zijlstra
2023-12-06 21:39                       ` Alexei Starovoitov
2023-12-07  9:31                         ` Peter Zijlstra
2023-12-07 22:32                           ` Alexei Starovoitov
2023-12-08 10:29                             ` Peter Zijlstra
2023-12-08 13:40                               ` Peter Zijlstra
2023-12-08 17:21                                 ` Peter Zijlstra
2023-12-08 19:40                                   ` Alexei Starovoitov
2023-12-08 20:27                                     ` Peter Zijlstra
2023-12-08 20:35                                     ` Peter Zijlstra
2023-12-08 20:41                                       ` Alexei Starovoitov
2023-12-08 20:52                                         ` Peter Zijlstra
2023-12-08 20:58                                           ` Alexei Starovoitov
2023-12-08 22:45                                             ` Peter Zijlstra
2023-12-09  4:51                                               ` Alexei Starovoitov
2023-12-08 19:32                                 ` Alexei Starovoitov
2023-12-08 20:18                                   ` Peter Zijlstra
2023-12-08 20:45                                     ` Alexei Starovoitov
2023-12-08 20:56                                       ` Peter Zijlstra
2023-12-08 21:04                                         ` Alexei Starovoitov

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=ZW4LjmUKj1q6RWdL@krava \
    --to=olsajiri@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=ast@kernel.org \
    --cc=bp@alien8.de \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=haoluo@google.com \
    --cc=hpa@zytor.com \
    --cc=joao@overdrivepizza.com \
    --cc=john.fastabend@gmail.com \
    --cc=jpoimboe@kernel.org \
    --cc=keescook@chromium.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=martin.lau@linux.dev \
    --cc=mingo@redhat.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterz@infradead.org \
    --cc=samitolvanen@google.com \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=songliubraving@meta.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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