Skip to content

enforce W^X for trampoline and dispatcher

Song Liu bpf linux-mm 2 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 3 repliesApplied 2/2
  2. v12 patches 5 repliesSuperseded

Changes in v2 from the cover letter

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).

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: use bpf_prog_pack for bpf_dispatcherarch/x86/net/bpf_jit_comp.c include/linux/bpf.h include/linux/filter.h +2 more+43 -170 repliesApplied
2/2bpf: Enforce W^X for bpf trampolineinclude/linux/bpf.h kernel/bpf/trampoline.c+5 -180 repliesApplied

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by.

PatchJeff Layton
SeriesT-b
1/2
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 bpf-next 0/2] enforce W^X for trampoline and dispatcher

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/[email protected]/

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