BPF List
 help / color / mirror / Atom feed
* [PATCH v2 bpf-next 0/2] enforce W^X for trampoline and dispatcher
@ 2022-09-26 18:47 Song Liu
  2022-09-26 18:47 ` [PATCH v2 bpf-next 1/2] bpf: use bpf_prog_pack for bpf_dispatcher Song Liu
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Song Liu @ 2022-09-26 18:47 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, john.fastabend, kpsingh, kernel-team, haoluo,
	jlayton, bjorn, Song Liu

Changes v1 => v2:
1. Update arch_prepare_bpf_dispatcher to use a RO image and a RW buffer.
   (Alexei) Note: I haven't found an existing test to cover this part, so
   this part was tested manually (comparing the generated dispatcher is
   the same).

Jeff Layton reported CPA W^X warning linux-next [1]. It turns out to be
W^X issue with bpf trampoline and bpf dispatcher. Fix these by:

1. Use bpf_prog_pack for bpf_dispatcher;
2. Set memory permission properly with bpf trampoline.

[1] https://lore.kernel.org/lkml/c84cc27c1a5031a003039748c3c099732a718aec.camel@kernel.org/

Song Liu (2):
  bpf: use bpf_prog_pack for bpf_dispatcher
  bpf: Enforce W^X for bpf trampoline

 arch/x86/net/bpf_jit_comp.c | 16 ++++++++--------
 include/linux/bpf.h         |  4 ++--
 include/linux/filter.h      |  5 +++++
 kernel/bpf/core.c           |  9 +++++++--
 kernel/bpf/dispatcher.c     | 27 +++++++++++++++++++++------
 kernel/bpf/trampoline.c     | 22 +++++-----------------
 6 files changed, 48 insertions(+), 35 deletions(-)

--
2.30.2

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-28 16:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-26 18:47 [PATCH v2 bpf-next 0/2] enforce W^X for trampoline and dispatcher Song Liu
2022-09-26 18:47 ` [PATCH v2 bpf-next 1/2] bpf: use bpf_prog_pack for bpf_dispatcher Song Liu
2022-09-26 18:47 ` [PATCH v2 bpf-next 2/2] bpf: Enforce W^X for bpf trampoline Song Liu
2022-09-27  3:50 ` [PATCH v2 bpf-next 0/2] enforce W^X for trampoline and dispatcher patchwork-bot+netdevbpf
2022-09-27 12:16 ` Jeff Layton
2022-09-28  9:42 ` Jesper Dangaard Brouer
2022-09-28 16:23   ` Song Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox