Open liubogithub opened 6 years ago
BTW, scripts without the global BPF_HASH() works fine, e.g. hello_world.py
I am using a FC26 based system and booted it with latest net-next (also 4.16 rc1, plus some networking specific codes), and I did not see any issues. Probably need to try on FC27 based system.
Could you use debug=8 (or debug=12) (if you use llvm 6.0 or later)? This way, you can dump out byte codes before it calls bpf syscall to load. This way, it will show whether the byte code has any issue or not.
Tried on FC27 with latest net-next, still did not observe the issue. Maybe you can try different compilers?
I got llvm-libs-5.0.1-2.fc27.x86_64 installed currently.
So I managed to get it work by building kernel with f27's config-4.15.2-300.fc27.x86_64, however what I haven't figured out is, that my original config already contains all the items bpf requires as suggested in INSTALL.md:
$ grep -i bpf config.bak
# CONFIG_CGROUP_BPF is not set
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT_ALWAYS_ON=y
# CONFIG_NETFILTER_XT_MATCH_BPF is not set
# CONFIG_NET_CLS_BPF is not set
# CONFIG_NET_ACT_BPF is not set
CONFIG_BPF_JIT=y
# CONFIG_BPF_STREAM_PARSER is not set
CONFIG_HAVE_EBPF_JIT=y
CONFIG_BPF_EVENTS=y
CONFIG_BPF_KPROBE_OVERRIDE=y
And this is the f27's config:
grep -i bpf config-4.15.2-300.fc27.x86_64
CONFIG_CGROUP_BPF=y
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT_ALWAYS_ON=y
CONFIG_NETFILTER_XT_MATCH_BPF=m
CONFIG_NET_CLS_BPF=m
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_JIT=y
CONFIG_BPF_STREAM_PARSER=y
CONFIG_LWTUNNEL_BPF=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_BPF_EVENTS=y
# CONFIG_TEST_BPF is not set
The difference here are CONFIG_CGROUP_BPF and CGROUP_BPF_STREAM_PARSER, but by reading their descriptions I thought they're optional, odd things happen here.
Just tried removing CONFIG_CGROUP_BPF and CGROUP_BPF_STREAM_PARSER, disksnoop.py
still works fine. Agreed that these two options should not impact disksnoop.py and causing invalid instructions.
I'm running out of ideas, now I've got a 'workable' config and a 'non-workable' config, by doing diff I barely found anything could be the cause to the 'invalid argument' failure, probably you can figure it out since you're more experienced in this area?
config.bpf-work config.bpf-nonwork
And the diff are listed here, config.diff
-CONFIG_IRQ_TIME_ACCOUNTING=y
-CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=12
-CONFIG_CGROUP_PIDS=y
-CONFIG_SLAB_FREELIST_RANDOM=y
-CONFIG_SLAB_FREELIST_HARDENED=y
-CONFIG_BLK_DEV_ZONED=y
-CONFIG_BLK_DEV_THROTTLING_LOW=y
-CONFIG_BLK_SED_OPAL=y
-CONFIG_INTEL_RDT=y
-CONFIG_X86_NUMACHIP=y
-CONFIG_XEN_PVH=y
-CONFIG_PREEMPT_COUNT=y
-CONFIG_X86_MCELOG_LEGACY=y
-CONFIG_AMD_MEM_ENCRYPT=y
-CONFIG_ARCH_USE_MEMREMAP_PROT=y
-CONFIG_NODES_SHIFT=10
-CONFIG_HAVE_BOOTMEM_INFO_NODE=y
-CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=y
-CONFIG_MEMORY_HOTREMOVE=y
-CONFIG_CMA=y
-CONFIG_CMA_AREAS=7
-CONFIG_Z3FOLD=y
-CONFIG_ZONE_DEVICE=y
-CONFIG_ARCH_HAS_HMM=y
-CONFIG_MIGRATE_VMA_HELPER=y
-CONFIG_HMM=y
-CONFIG_HMM_MIRROR=y
-CONFIG_DEVICE_PRIVATE=y
-CONFIG_DEVICE_PUBLIC=y
-CONFIG_X86_INTEL_MPX=y
-CONFIG_RANDOMIZE_BASE=y
-CONFIG_X86_NEED_RELOCS=y
-CONFIG_RANDOMIZE_MEMORY=y
-CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING=0xa
-CONFIG_PM_TEST_SUSPEND=y
-CONFIG_XPOWER_PMIC_OPREGION=y
-CONFIG_CPU_FREQ_STAT=y
-CONFIG_CPU_FREQ_GOV_SCHEDUTIL=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ATH_PARSER=y
-CONFIG_EXT4_ENCRYPTION=y
-CONFIG_EXT4_FS_ENCRYPTION=y
-CONFIG_FS_DAX_PMD=y
-CONFIG_FS_ENCRYPTION=y
-CONFIG_PROC_CHILDREN=y
-CONFIG_PAGE_POISONING=y
-CONFIG_PAGE_POISONING_NO_SANITY=y
-CONFIG_SLUB_DEBUG_ON=y
-CONFIG_DEBUG_ATOMIC_SLEEP=y
-CONFIG_FAIL_FUTEX=y
-CONFIG_HWLAT_TRACER=y
-CONFIG_BRANCH_PROFILE_NONE=y
-CONFIG_MMIOTRACE=y
-CONFIG_BUG_ON_DATA_CORRUPTION=y
-CONFIG_IO_STRICT_DEVMEM=y
-CONFIG_EARLY_PRINTK_USB_XDBC=y
-CONFIG_DEBUG_WX=y
-CONFIG_ENCRYPTED_KEYS=y
-CONFIG_KEY_DH_OPERATIONS=y
-CONFIG_HARDENED_USERCOPY=y
-CONFIG_HARDENED_USERCOPY_FALLBACK=y
-CONFIG_FORTIFY_SOURCE=y
-CONFIG_CRYPTO_KPP=y
-CONFIG_CRYPTO_DH=y
-CONFIG_CRYPTO_CTS=y
-CONFIG_CRYPTO_USER_API_AEAD=y
-CONFIG_SECONDARY_TRUSTED_KEYRING=y
-CONFIG_SYSTEM_BLACKLIST_KEYRING=y
-CONFIG_SYSTEM_BLACKLIST_HASH_LIST=""
-CONFIG_IRQ_POLL=y
Hi,
While running disksnoop.py on own built 4.16-rc1+ (the base distro is fedora 27), I got this error, tried to add debug=6 to debug, but it doesn't seem to point out where opcode 00 comes from, any ideas? @yonghong-song