libbpf: bpf_prog_load failed, invalid argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






when i test libbpf-bootstrap examples,bpf syscall failed, errno is 22, strace log as below:


24400 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7fffe7489940, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS}, 116) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7fffe7489ae0, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS}, 128) = 3
24400 bpf(BPF_BTF_LOAD, 0x7fffe74898e0, 28) = 3
24400 bpf(BPF_BTF_LOAD, 0x7fffe74898c0, 28) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_BTF_LOAD, 0x7fffe74898b0, 28) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_BTF_LOAD, 0x7fffe74898e0, 28) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_BTF_LOAD, 0x7fffe74898c0, 28) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_BTF_LOAD, 0x7fffe74898c0, 28) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_BTF_LOAD, 0x7fffe74898c0, 28) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_BTF_LOAD, 0x7fffe74898e0, 28) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_BTF_LOAD, 0x7fffe74898f0, 28) = 3
24400 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7fffe7489850, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="libbpf_nametest"}, 64) = 4
24400 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_ARRAY, key_size=4, value_size=4, max_entries=1, map_flags=0x400 /* BPF_F_??? */, inner_map_fd=0, map_name="libbpf_mmap", map_ifindex=0}, 72) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_ARRAY, key_size=4, value_size=32, max_entries=1, map_flags=0, inner_map_fd=0, map_name="libbpf_global", map_ifindex=0}, 72) = 4
24400 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=5, insns=0x7fffe7489820, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS}, 128) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_TRACEPOINT, insn_cnt=6, insns=0x7fffe74890d0, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS}, 128) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_KPROBE, insn_cnt=18, insns=0x1b7b580, license="Dual BSD/GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(4, 19, 0), prog_flags=0, prog_name="do_unlinkat", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS}, 128) = -1 EINVAL (Invalid argument)
24400 bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_KPROBE, insn_cnt=18, insns=0x1b7b580, license="Dual BSD/GPL", log_level=1, log_size=16777215, log_buf="", kern_version=KERNEL_VERSION(4, 19, 0), prog_flags=0, prog_name="do_unlinkat", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS}, 128) = -1 EINVAL (Invalid argument)
24400 +++ exited with 22 +++


kernel information is "Linux admin-PC 4.19.0-amd64-desktop #5404 SMP Fri Dec 23 17:25:30 CST 2022 x86_64 GNU/Linux"
ebpf source code:
```c

// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/* Copyright (c) 2021 Sartura */
#define BPF_NO_GLOBAL_DATA
#define BPF_NO_PRESERVE_ACCESS_INDEX
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>


char LICENSE[] SEC("license") = "Dual BSD/GPL";


SEC("kprobe/do_unlinkat")
int BPF_KPROBE(do_unlinkat, int dfd, struct filename *name)
{
	pid_t pid;
	const char *filename;


	pid = bpf_get_current_pid_tgid() >> 32;
	filename = BPF_CORE_READ(name, name);
	bpf_trace_printk("KPROBE ENTRY pid = %d, filename = %s\n", pid, filename);
	return 0;
}


SEC("kretprobe/do_unlinkat")
int BPF_KRETPROBE(do_unlinkat_exit, long ret)
{
	pid_t pid;


	pid = bpf_get_current_pid_tgid() >> 32;
	bpf_trace_printk("KPROBE EXIT: pid = %d, ret = %ld\n", pid, ret);
	return 0;
}


```




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux