kernel/kernel-std/debian/patches/0038-samples-bpf-use-kprobe-and-urandom_read_iter.patch
Wentao Zhang 8ae537061f samples/bpf: use kprobe and urandom_read_iter
14c174633f34 ("random: remove unused tracepoints") removed all the
tracepoints from drivers/char/random.c, one of which,
random:urandom_read.

1b388e7765f2 ("random: convert to using fops->read_iter()") replaced
kernel function urandom_read with urandom_read_iter.
Therefore, kprobe on urandom_read is not working any more:

Fix breakage by replacing tracepoint with kprobing and replacing
urandom_read with urandom_read_iter.

TEST PLAN:
PASS: build-pkgs -c -p linux
PASS: build-pkgs -c -p linux-rt
PASS: make -j 16 M=samples/bpf
PASS: sudo samples/bpf/test_overhead

Closes-Bug: 1999136

Change-Id: Idac88160050abaa7ebe7098a54792650f2d691cd
Signed-off-by: Wentao Zhang <wentao.zhang@windriver.com>
2022-12-13 10:39:49 +08:00

68 lines
2.2 KiB
Diff

From 3e65002714f5b4d20ab30b01a58ddb0e243a74ac Mon Sep 17 00:00:00 2001
From: Wentao Zhang <wentao.zhang@windriver.com>
Date: Thu, 8 Dec 2022 11:55:17 +0800
Subject: [PATCH] samples/bpf: use kprobe and urandom_read_iter
14c174633f34 ("random: remove unused tracepoints") removed all the
tracepoints from drivers/char/random.c, one of which,
random:urandom_read.
1b388e7765f2 ("random: convert to using fops->read_iter()") replaced
kernel function urandom_read with urandom_read_iter.
Therefore, kprobe on urandom_read is not working any more.
Use kprobing to replace the tracepoint and use urandom_read_iter
to replace urandom_read to fix the breakage.
Fixes: 1b388e7765f2 ("random: convert to using fops->read_iter()")
Fixes: 14c174633f34 ("random: remove unused tracepoints")
Signed-off-by: Wentao Zhang <wentao.zhang@windriver.com>
---
samples/bpf/test_overhead_kprobe_kern.c | 2 +-
samples/bpf/test_overhead_raw_tp_kern.c | 2 +-
samples/bpf/test_overhead_tp_kern.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/samples/bpf/test_overhead_kprobe_kern.c b/samples/bpf/test_overhead_kprobe_kern.c
index f6d593e47..2dcb4ba0e 100644
--- a/samples/bpf/test_overhead_kprobe_kern.c
+++ b/samples/bpf/test_overhead_kprobe_kern.c
@@ -38,7 +38,7 @@ int prog(struct pt_regs *ctx)
return 0;
}
-SEC("kprobe/urandom_read")
+SEC("kprobe/urandom_read_iter")
int prog2(struct pt_regs *ctx)
{
return 0;
diff --git a/samples/bpf/test_overhead_raw_tp_kern.c b/samples/bpf/test_overhead_raw_tp_kern.c
index 8763181a3..34a5aba61 100644
--- a/samples/bpf/test_overhead_raw_tp_kern.c
+++ b/samples/bpf/test_overhead_raw_tp_kern.c
@@ -9,7 +9,7 @@ int prog(struct bpf_raw_tracepoint_args *ctx)
return 0;
}
-SEC("raw_tracepoint/urandom_read")
+SEC("kprobe/urandom_read_iter")
int prog2(struct bpf_raw_tracepoint_args *ctx)
{
return 0;
diff --git a/samples/bpf/test_overhead_tp_kern.c b/samples/bpf/test_overhead_tp_kern.c
index eaa32693f..d5f7abb4c 100644
--- a/samples/bpf/test_overhead_tp_kern.c
+++ b/samples/bpf/test_overhead_tp_kern.c
@@ -28,7 +28,7 @@ struct urandom_read {
int pool_left;
int input_left;
};
-SEC("tracepoint/random/urandom_read")
+SEC("kprobe/urandom_read_iter")
int prog2(struct urandom_read *ctx)
{
return 0;
--
2.25.1