提交 c1a1e3e4 编写于 作者: Y Yaqi Chen 提交者: Zheng Zengkai

samples/bpf: Fix broken tracex1 due to kprobe argument change

stable inclusion
from stable-5.10.38
commit 799c3950680a748355bc62f835ab5608b99c2288
bugzilla: 51875
CVE: NA

--------------------------------

[ Upstream commit 137733d0 ]

>From commit c0bbbdc3 ("__netif_receive_skb_core: pass skb by
reference"), the first argument passed into __netif_receive_skb_core
has changed to reference of a skb pointer.

This commit fixes by using bpf_probe_read_kernel.
Signed-off-by: NYaqi Chen <chendotjs@gmail.com>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
Acked-by: NYonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210416154803.37157-1-chendotjs@gmail.comSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 176bee05
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
SEC("kprobe/__netif_receive_skb_core") SEC("kprobe/__netif_receive_skb_core")
int bpf_prog1(struct pt_regs *ctx) int bpf_prog1(struct pt_regs *ctx)
{ {
/* attaches to kprobe netif_receive_skb, /* attaches to kprobe __netif_receive_skb_core,
* looks for packets on loobpack device and prints them * looks for packets on loobpack device and prints them
*/ */
char devname[IFNAMSIZ]; char devname[IFNAMSIZ];
...@@ -35,7 +35,7 @@ int bpf_prog1(struct pt_regs *ctx) ...@@ -35,7 +35,7 @@ int bpf_prog1(struct pt_regs *ctx)
int len; int len;
/* non-portable! works for the given kernel only */ /* non-portable! works for the given kernel only */
skb = (struct sk_buff *) PT_REGS_PARM1(ctx); bpf_probe_read_kernel(&skb, sizeof(skb), (void *)PT_REGS_PARM1(ctx));
dev = _(skb->dev); dev = _(skb->dev);
len = _(skb->len); len = _(skb->len);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册