- 29 8月, 2022 3 次提交
-
-
由 openeuler-ci-bot 提交于
Merge Pull Request from: @sdlzx Fix several bugs of hugetlb enhanced mmap. --- v2: change pr_info to pr_err_ratelimited Link:https://gitee.com/openeuler/kernel/pulls/84 Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>
-
由 Liu Zixian 提交于
euleros inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I5OE36 CVE: NA ------------ Huge page should be released if read_actual_file failed. --- v2: change pr_info to pr_err_ratelimited Fixes:1af4fa6d("hugetlb: support private file map") Signed-off-by: NLiu Zixian <liuzixian4@huawei.com>
-
由 Liu Zixian 提交于
euleros inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I5NS6H CVE: NA ------------ We should call perf_event_mmap after vm_actual_file is set. If we run program with "perf record ./prog", kernel records mmap information (file name, address etc.) in perf_event_mmap which is called in do_mmap. Perf needs this to resolve symbol names. For hugetlb file map, vm_actual_file is set after do_mmap, so we need to call perf_event_mmap again to correct the recorded file name. Fixes:1af4fa6d("hugetlb: support private file map") Signed-off-by: NLiu Zixian <liuzixian4@huawei.com>
-
- 27 8月, 2022 1 次提交
-
-
由 openeuler-ci-bot 提交于
Merge Pull Request from: @zhengzengkai This set introduces CO-RE support in the kernel. There are several reasons to add such support: 1. It's a step toward signed BPF programs. 2. It allows golang like languages that struggle to adopt libbpf to take advantage of CO-RE powers. 3. Currently the field accessed by 'ldx [R1 + 10]' insn is recognized by the verifier purely based on +10 offset. If R1 points to a union the verifier picks one of the fields at this offset. With CO-RE the kernel can disambiguate the field access. Link:https://gitee.com/openeuler/kernel/pulls/70 Reviewed-by: Xie XiuQi <xiexiuqi@huawei.com> Signed-off-by: Xu Kuohai <xukuohai@huawei.com> Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>
-
- 25 8月, 2022 1 次提交
-
-
由 openeuler-ci-bot 提交于
Merge Pull Request from: @yunyingsun This patch set is to add uncore PMU support for Intel Sapphire Rapids platform. It includes generic uncore discovery support and SPR specific uncore event support. 1. Generic uncore discovery support contains: a) Feature patches from upstream 5.13-rc1(5 commits): c4c55e36 perf/x86/intel/uncore: Generic support for the MMIO type of uncore blocks 42839ef4 perf/x86/intel/uncore: Generic support for the PCI type of uncore blocks 6477dc39 perf/x86/intel/uncore: Rename uncore_notifier to uncore_pci_sub_notifier d6c75413 perf/x86/intel/uncore: Generic support for the MSR type of uncore blocks edae1f06 perf/x86/intel/uncore: Parse uncore discovery tables b) To fix rb_find/rb_add implicit declaration errors, adding rbtree helper patches(v5.12-rc1, 7 commits): 798172b1 rbtree, timerqueue: Use rb_add_cached() 5a798725 rbtree, rtmutex: Use rb_add_cached() a905e84e rbtree, uprobes: Use rbtree helpers a3b89864 rbtree, perf: Use new rbtree helpers 8ecca394 rbtree, sched/deadline: Use rb_add_cached() bf9be9a1 rbtree, sched/fair: Use rb_add_cached() 2d24dd57 rbtree: Add generic add and find helpers c) To fix error(too few arguments to function ‘uncore_pci_pmu_register’), add dependent patches(5.12-rc1, 2): 9a7832ce perf/x86/intel/uncore: With > 8 nodes, get pci bus die id from NUMA info ba9506be perf/x86/intel/uncore: Store the logical die id instead of the physical die id. 2. SPR platform specific uncore support contains: a) Feature upstream patches from mainline v5.15-rc1(15 commits): c76826a6 perf/x86/intel/uncore: Support IMC free-running counters on Sapphire Rapids server 0378c93a perf/x86/intel/uncore: Support IIO free-running counters on Sapphire Rapids server 1583971b perf/x86/intel/uncore: Factor out snr_uncore_mmio_map() 8053f2d7 perf/x86/intel/uncore: Add alias PMU name 0d771caf perf/x86/intel/uncore: Add Sapphire Rapids server MDF support 2a8e51ea perf/x86/intel/uncore: Add Sapphire Rapids server M3UPI support da5a9156 perf/x86/intel/uncore: Add Sapphire Rapids server UPI support f57191ed perf/x86/intel/uncore: Add Sapphire Rapids server M2M support 85f2e30f perf/x86/intel/uncore: Add Sapphire Rapids server IMC support 0654dfdc perf/x86/intel/uncore: Add Sapphire Rapids server PCU support f85ef898 perf/x86/intel/uncore: Add Sapphire Rapids server M2PCIe support e199eb51 perf/x86/intel/uncore: Add Sapphire Rapids server IRP support 3ba7095b perf/x86/intel/uncore: Add Sapphire Rapids server IIO support 949b1138 perf/x86/intel/uncore: Add Sapphire Rapids server CHA support c54c53d9 perf/x86/intel/uncore: Add Sapphire Rapids server framework b) Two SPR model name related changes to make above patches apply cleanly(2 commits): (5.14-rc2) 28188cc4 x86/cpu: Fix core name for Sapphire Rapids (5.13-rc1) 53375a5a x86/cpu: Resort and comment Intel models c) Some SPR uncore related bugfixes(6 commits): v5.16-rc1: 4034fb20 perf/x86/intel/uncore: Fix Intel SPR M3UPI event constraints f01d7d55 perf/x86/intel/uncore: Fix Intel SPR M2PCIE event constraints 67c5d443 perf/x86/intel/uncore: Fix Intel SPR IIO event constraints 9d756e40 perf/x86/intel/uncore: Fix Intel SPR CHA event constraints e2bb9fab perf/x86/intel/uncore: Fix invalid unit check v5.13-rc6: 4a0e3ff3 perf/x86/intel/uncore: Fix a kernel WARNING triggered by maxcpus=1 Intel-kernel issue: https://gitee.com/openeuler/intel-kernel/issues/I5BECO Test: With this patch set, on SPR: ``` # cat /sys/devices/uncore_cha_1/alias uncore_type_0_1 # perf stat -a -e uncore_imc_0/event=0x1/ -- sleep 1 Performance counter stats for 'system wide': 2,407,096,566 uncore_imc_0/event=0x1/ 1.002850766 seconds time elapsed # perf stat -a -e uncore_imc_free_running_0/rpq_cycles/ -- sleep 1 Performance counter stats for 'system wide': 13,879,446 uncore_imc_free_running_0/rpq_cycles/ 1.002852701 seconds time elapsed ``` Without this patch set, the "uncore_cha_1" like devices are not available under /sys/devices, and the above like uncore events will be "not supported". Known issue: N/A Default config change: N/A Link:https://gitee.com/openeuler/kernel/pulls/82 Reviewed-by: Zheng Zengkai <zhengzengkai@huawei.com> Reviewed-by: Jun Tian <jun.j.tian@intel.com> Reviewed-by: Liu Chao <liuchao173@huawei.com> Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>
-
- 24 8月, 2022 35 次提交
-
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.19-rc1 commit 966a7509 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=966a7509325395c51c5f6d89e7352b0585e4804b ------------------------------------------------- Fix the bug in bpf_object__relocate_core() which can lead to finding invalid matching BPF program when processing CO-RE relocation. IF matching program is not found, last encountered program will be assumed to be correct program and thus error detection won't detect the problem. Fixes: 9c82a63c ("libbpf: Fix CO-RE relocs against .text section") Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20220426004511.2691730-4-andrii@kernel.org (cherry picked from commit 966a7509) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.18-rc1 commit d3b0b800 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d3b0b80064e0416850f818184b8f7bba9fdf8c40 ------------------------------------------------- When compiling selftests in -O2 mode with GCC1, we get three new compilations warnings about potentially uninitialized variables. Compiler is wrong 2 out of 3 times, but this patch makes GCC11 happy anyways, as it doesn't cost us anything and makes optimized selftests build less annoying. The amazing one is tc_redirect case of token that is malloc()'ed before ASSERT_OK_PTR() check is done on it. Seems like GCC pessimistically assumes that libbpf_get_error() will dereference the contents of the pointer (no it won't), so the only way I found to shut GCC up was to do zero-initializaing calloc(). This one was new to me. For linfo case, GCC didn't realize that linfo_size will be initialized by the function that is returning linfo_size as out parameter. core_reloc.c case was a real bug, we can goto cleanup before initializing obj. But we don't need to do any clean up, so just continue iteration intstead. Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20220211190927.1434329-1-andrii@kernel.org (cherry picked from commit d3b0b800) Signed-off-by: NWang Yufen <wangyufen@huawei.com> Conflicts: tools/testing/selftests/bpf/prog_tests/core_reloc.c tools/testing/selftests/bpf/prog_tests/tc_redirect.c Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 259172bb category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=259172bb6514758ce3be1610c500b51a9f44212a ------------------------------------------------- libbpf's obj->nr_programs includes static and global functions. That number could be higher than the actual number of bpf programs going be loaded by gen_loader. Passing larger nr_programs to bpf_gen__init() doesn't hurt. Those exra stack slots will stay as zero. bpf_gen__finish() needs to check that actual number of progs that gen_loader saw is less than or equal to obj->nr_programs. Fixes: ba05fd36 ("libbpf: Perform map fd cleanup for gen_loader in case of error") Signed-off-by: NAlexei Starovoitov <ast@kernel.org> (cherry picked from commit 259172bb) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Shuyi Cheng 提交于
mainline inclusion from mainline-5.17-rc1 commit 229fae38 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=229fae38d0fc0d6ff58d57cbeb1432da55e58d4f ------------------------------------------------- Fix error: "failed to pin map: Bad file descriptor, path: /sys/fs/bpf/_rodata_str1_1." In the old kernel, the global data map will not be created, see [0]. So we should skip the pinning of the global data map to avoid bpf_object__pin_maps returning error. Therefore, when the map is not created, we mark “map->skipped" as true and then check during relocation and during pinning. Fixes: 16e0c35c ("libbpf: Load global data maps lazily on legacy kernels") Signed-off-by: NShuyi Cheng <chengshuyi@linux.alibaba.com> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> (cherry picked from commit 229fae38) Signed-off-by: NWang Yufen <wangyufen@huawei.com> Conflicts: tools/lib/bpf/libbpf.c Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 29f2e5bd category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=29f2e5bd9439445fe14ba8570b1c9a7ad682df84 ------------------------------------------------- When CONFIG_DEBUG_INFO_BTF_MODULES is not set the following warning can be seen: kernel/bpf/btf.c:6588:13: warning: 'purge_cand_cache' defined but not used [-Wunused-function] Fix it. Fixes: 1e89106d ("bpf: Add bpf_core_add_cands() and wire it into bpf_core_apply_relo_insn().") Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211207014839.6976-1-alexei.starovoitov@gmail.com (cherry picked from commit 29f2e5bd) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 78c1f8d0 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=78c1f8d0634cc35da613d844eda7c849fc50f643 ------------------------------------------------- Reduce bpf_core_apply_relo_insn() stack usage and bump BPF_CORE_SPEC_MAX_LEN limit back to 64. Fixes: 29db4bea ("bpf: Prepare relo_core.c for kernel duty.") Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211203182836.16646-1-alexei.starovoitov@gmail.com (cherry picked from commit 78c1f8d0) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit b8b5cb55 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b8b5cb55f5d3f03cc1479a3768d68173a10359ad ------------------------------------------------- Fix the `int i` declaration inside the for statement. This is non-C89 compliant. See [0] for user report breaking BCC build. [0] https://github.com/libbpf/libbpf/issues/403 Fixes: 18f4fccb ("libbpf: Update gen_loader to emit BTF_KIND_FUNC relocations") Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Acked-by: NKumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/bpf/20211105191055.3324874-1-andrii@kernel.org (cherry picked from commit b8b5cb55) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 098dc533 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=098dc5335a2083223c80d058ab4d23f6ce120b97 ------------------------------------------------- Add 182 CO-RE relocations to verifier scale test. Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-18-alexei.starovoitov@gmail.com (cherry picked from commit 098dc533) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 26b367e3 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=26b367e3663931f2fee5f0786a1eff712e67b0bf ------------------------------------------------- Add a test where randmap() function is appended to three different bpf programs. That action checks struct bpf_core_relo replication logic and offset adjustment in gen loader part of libbpf. Fourth bpf program has 360 CO-RE relocations from vmlinux, bpf_testmod, and non-existing type. It tests candidate cache logic. Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-16-alexei.starovoitov@gmail.com (cherry picked from commit 26b367e3) Signed-off-by: NWang Yufen <wangyufen@huawei.com> Conflicts: tools/testing/selftests/bpf/Makefile Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 650c9dbd category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=650c9dbd101ba7d7180f4e77deb1c273f4ea5ca3 ------------------------------------------------- To exercise CO-RE in the kernel further convert map_ptr_kern test to light skeleton. Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-15-alexei.starovoitov@gmail.com (cherry picked from commit 650c9dbd) Signed-off-by: NWang Yufen <wangyufen@huawei.com> Conflicts: tools/testing/selftests/bpf/Makefile Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit d82fa9b7 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d82fa9b708d7d8a9c275d86c4388d24ecc63206c ------------------------------------------------- Check that hash and array inner maps are properly initialized. Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-14-alexei.starovoitov@gmail.com (cherry picked from commit d82fa9b7) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 19250f5f category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=19250f5fc0c283892a61f3abf9d65e6325f63897 ------------------------------------------------- The gen_loader has to clear attach_kind otherwise the programs without attach_btf_id will fail load if they follow programs with attach_btf_id. Fixes: 67234743 ("libbpf: Generate loader program out of BPF ELF file.") Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-12-alexei.starovoitov@gmail.com (cherry picked from commit 19250f5f) Signed-off-by: NWang Yufen <wangyufen@huawei.com> Conflicts: tools/lib/bpf/gen_loader.c Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit be05c944 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=be05c94476f3cf4fdc29feab4ed1053187323296 ------------------------------------------------- Add ability to initialize inner maps in light skeleton. Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-11-alexei.starovoitov@gmail.com (cherry picked from commit be05c944) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit d0e92887 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d0e928876e30b18411b80fd2445424bc00e95745 ------------------------------------------------- Without lskel the CO-RE relocations are processed by libbpf before any other work is done. Instead, when lskel is needed, remember relocation as RELO_CORE kind. Then when loader prog is generated for a given bpf program pass CO-RE relos of that program to gen loader via bpf_gen__record_relo_core(). The gen loader will remember them as-is and pass it later as-is into the kernel. The normal libbpf flow is to process CO-RE early before call relos happen. In case of gen_loader the core relos have to be added to other relos to be copied together when bpf static function is appended in different places to other main bpf progs. During the copy the append_subprog_relos() will adjust insn_idx for normal relos and for RELO_CORE kind too. When that is done each struct reloc_desc has good relos for specific main prog. Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-10-alexei.starovoitov@gmail.com (cherry picked from commit d0e92887) Signed-off-by: NWang Yufen <wangyufen@huawei.com> Conflicts: tools/lib/bpf/gen_loader.c tools/lib/bpf/libbpf.c Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 1e89106d category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1e89106da25390826608ad6ac0edfb7c9952eff3 ------------------------------------------------- Given BPF program's BTF root type name perform the following steps: . search in vmlinux candidate cache. . if (present in cache and candidate list >= 1) return candidate list. . do a linear search through kernel BTFs for possible candidates. . regardless of number of candidates found populate vmlinux cache. . if (candidate list >= 1) return candidate list. . search in module candidate cache. . if (present in cache) return candidate list (even if list is empty). . do a linear search through BTFs of all kernel modules collecting candidates from all of them. . regardless of number of candidates found populate module cache. . return candidate list. Then wire the result into bpf_core_apply_relo_insn(). When BPF program is trying to CO-RE relocate a type that doesn't exist in either vmlinux BTF or in modules BTFs these steps will perform 2 cache lookups when cache is hit. Note the cache doesn't prevent the abuse by the program that might have lots of relocations that cannot be resolved. Hence cond_resched(). CO-RE in the kernel requires CAP_BPF, since BTF loading requires it. Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-9-alexei.starovoitov@gmail.com (cherry picked from commit 1e89106d) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit 03d5b991 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=03d5b99138dd8c7bfb838396acb180bd515ebf06 ------------------------------------------------- Remove two redundant fields from struct bpf_core_cand. Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-8-alexei.starovoitov@gmail.com (cherry picked from commit 03d5b991) Signed-off-by: NWang Yufen <wangyufen@huawei.com> Conflicts: tools/lib/bpf/libbpf.c Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit fbd94c7a category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fbd94c7afcf99c9f3b1ba1168657ecc428eb2c8d ------------------------------------------------- struct bpf_core_relo is generated by llvm and processed by libbpf. It's a de-facto uapi. With CO-RE in the kernel the struct bpf_core_relo becomes uapi de-jure. Add an ability to pass a set of 'struct bpf_core_relo' to prog_load command and let the kernel perform CO-RE relocations. Note the struct bpf_line_info and struct bpf_func_info have the same layout when passed from LLVM to libbpf and from libbpf to the kernel except "insn_off" fields means "byte offset" when LLVM generates it. Then libbpf converts it to "insn index" to pass to the kernel. The struct bpf_core_relo's "insn_off" field is always "byte offset". Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-6-alexei.starovoitov@gmail.com (cherry picked from commit fbd94c7a) Signed-off-by: NWang Yufen <wangyufen@huawei.com> Conflicts: include/linux/bpf.h Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 46334a0c category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=46334a0cd21bed70d6f1ddef1464f75a0ebe1774 ------------------------------------------------- enum bpf_core_relo_kind is generated by llvm and processed by libbpf. It's a de-facto uapi. With CO-RE in the kernel the bpf_core_relo_kind values become uapi de-jure. Also rename them with BPF_CORE_ prefix to distinguish from conflicting names in bpf_core_read.h. The enums bpf_field_info_kind, bpf_type_id_kind, bpf_type_info_kind, bpf_enum_value_kind are passing different values from bpf program into llvm. Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-5-alexei.starovoitov@gmail.com (cherry picked from commit 46334a0c) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 29db4bea category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=29db4bea1d10b73749d7992c1fc9ac13499e8871 ------------------------------------------------- Make relo_core.c to be compiled for the kernel and for user space libbpf. Note the patch is reducing BPF_CORE_SPEC_MAX_LEN from 64 to 32. This is the maximum number of nested structs and arrays. For example: struct sample { int a; struct { int b[10]; }; }; struct sample *s = ...; int *y = &s->b[5]; This field access is encoded as "0:1:0:5" and spec len is 4. The follow up patch might bump it back to 64. Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-4-alexei.starovoitov@gmail.com (cherry picked from commit 29db4bea) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 8293eb99 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8293eb995f349aed28006792cad4cb48091919dd ------------------------------------------------- Rename btf_member_bit_offset() and btf_member_bitfield_size() to avoid conflicts with similarly named helpers in libbpf's btf.h. Rename the kernel helpers, since libbpf helpers are part of uapi. Suggested-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-3-alexei.starovoitov@gmail.com (cherry picked from commit 8293eb99) Signed-off-by: NWang Yufen <wangyufen@huawei.com> Conflicts: net/ipv4/bpf_tcp_ca.c Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Alexei Starovoitov 提交于
mainline inclusion from mainline-5.17-rc1 commit 74753e14 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=74753e1462e77349525daf9eb60ea21ed92d3a97 ------------------------------------------------- To prepare relo_core.c to be compiled in the kernel and the user space replace btf__type_by_id with btf_type_by_id. In libbpf btf__type_by_id and btf_type_by_id have different behavior. bpf_core_apply_relo_insn() needs behavior of uapi btf__type_by_id vs internal btf_type_by_id, but type_id range check is already done in bpf_core_apply_relo(), so it's safe to replace it everywhere. The kernel btf_type_by_id() does the check anyway. It doesn't hurt. Suggested-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211201181040.23337-2-alexei.starovoitov@gmail.com (cherry picked from commit 74753e14) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Kumar Kartikeya Dwivedi 提交于
mainline inclusion from mainline-5.17-rc1 commit d995816b category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d995816b77eb826e0f6d7adf4471ec191b362be0 ------------------------------------------------- Alexei pointed out that we can use BPF_REG_0 which already contains imm from move_blob2blob computation. Note that we now compare the second insn's imm, but this should not matter, since both will be zeroed out for the error case for the insn populated earlier. Suggested-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NKumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NSong Liu <songliubraving@fb.com> Link: https://lore.kernel.org/bpf/20211122235733.634914-4-memxor@gmail.com (cherry picked from commit d995816b) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Kumar Kartikeya Dwivedi 提交于
mainline inclusion from mainline-5.17-rc1 commit 0270090d category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0270090d396a8e7e7f42adae13fdfa48ffb85144 ------------------------------------------------- Instead, jump directly to success case stores in case ret >= 0, else do the default 0 value store and jump over the success case. This is better in terms of readability. Readjust the code for kfunc relocation as well to follow a similar pattern, also leads to easier to follow code now. Suggested-by: NAlexei Starovoitov <ast@kernel.org> Signed-off-by: NKumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NSong Liu <songliubraving@fb.com> Link: https://lore.kernel.org/bpf/20211122235733.634914-3-memxor@gmail.com (cherry picked from commit 0270090d) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Kumar Kartikeya Dwivedi 提交于
mainline inclusion from mainline-5.17-rc1 commit d4efb170 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d4efb170861827290f7f571020001a60d001faaf ------------------------------------------------- Andrii mentioned in [0] that switching to ARG_CONST_SIZE_OR_ZERO lets user avoid having to prove that string size at runtime is not zero and helps with not having to supress clang optimizations. [0]: https://lore.kernel.org/bpf/CAEf4BzZa_vhXB3c8atNcTS6=krQvC25H7K7c3WWZhM=27ro=Wg@mail.gmail.comSuggested-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NKumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Acked-by: NSong Liu <songliubraving@fb.com> Link: https://lore.kernel.org/bpf/20211122235733.634914-2-memxor@gmail.com (cherry picked from commit d4efb170) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Hengqi Chen 提交于
mainline inclusion from mainline-5.17-rc1 commit 341ac5ff category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=341ac5ffc4bd859103899c876902caf07cc97ea4 ------------------------------------------------- Support static initialization of BPF_MAP_TYPE_PROG_ARRAY with a syntax similar to map-in-map initialization ([0]): SEC("socket") int tailcall_1(void *ctx) { return 0; } struct { __uint(type, BPF_MAP_TYPE_PROG_ARRAY); __uint(max_entries, 2); __uint(key_size, sizeof(__u32)); __array(values, int (void *)); } prog_array_init SEC(".maps") = { .values = { [1] = (void *)&tailcall_1, }, }; Here's the relevant part of libbpf debug log showing what's going on with prog-array initialization: libbpf: sec '.relsocket': collecting relocation for section(3) 'socket' libbpf: sec '.relsocket': relo #0: insn #2 against 'prog_array_init' libbpf: prog 'entry': found map 0 (prog_array_init, sec 4, off 0) for insn #0 libbpf: .maps relo #0: for 3 value 0 rel->r_offset 32 name 53 ('tailcall_1') libbpf: .maps relo #0: map 'prog_array_init' slot [1] points to prog 'tailcall_1' libbpf: map 'prog_array_init': created successfully, fd=5 libbpf: map 'prog_array_init': slot [1] set to prog 'tailcall_1' fd=6 [0] Closes: https://github.com/libbpf/libbpf/issues/354Signed-off-by: NHengqi Chen <hengqi.chen@gmail.com> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211128141633.502339-2-hengqi.chen@gmail.com (cherry picked from commit 341ac5ff) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit 8f6f41f3 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8f6f41f39348f25db843f2fcb2f1c166b4bfa2d7 ------------------------------------------------- Similar to previous patch, just copy over necessary struct into local stack variable before checking its fields. Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20211124002325.1737739-14-andrii@kernel.org (cherry picked from commit 8f6f41f3) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit 57428298 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=57428298b5acf2ba2dd98359c532774f6eaeecb3 ------------------------------------------------- Buf can be not zero-terminated leading to strstr() to access data beyond the intended buf[] array. Fix by forcing zero termination. Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20211124002325.1737739-12-andrii@kernel.org (cherry picked from commit 57428298) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit e2e0d90c category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e2e0d90c550a2588ebed7aa2753adaac0f633989 ------------------------------------------------- Copy over iphdr into a local variable before accessing its fields. Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20211124002325.1737739-11-andrii@kernel.org (cherry picked from commit e2e0d90c) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit 6c4dedb7 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6c4dedb7550aafd094f7d803668fd039545f4e57 ------------------------------------------------- Perfbuf doesn't guarantee 8-byte alignment of the data like BPF ringbuf does, so struct get_stack_trace_t can arrive not properly aligned for subsequent u64 accesses. Easiest fix is to just copy data locally. Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20211124002325.1737739-10-andrii@kernel.org (cherry picked from commit 6c4dedb7) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit 3bd0233f category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3bd0233f388e061c44d36a1ac614a3bb4a851b7e ------------------------------------------------- Prevent sanitizer from complaining about passing NULL into memcpy(), even if it happens with zero size. Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20211124002325.1737739-9-andrii@kernel.org (cherry picked from commit 3bd0233f) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit 59383537 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=593835377f24ca1bb98008ec1dc3baefe491ad6e ------------------------------------------------- add_dst_sec() can invalidate bpf_linker's section index making dst_symtab pointer pointing into unallocated memory. Reinitialize dst_symtab pointer on each iteration to make sure it's always valid. Fixes: faf6ed32 ("libbpf: Add BPF static linker APIs") Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20211124002325.1737739-7-andrii@kernel.org (cherry picked from commit 59383537) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit 8cb12556 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8cb125566c40b7141d8842c534f0ea5820ee3d5c ------------------------------------------------- glob_syms array wasn't freed on bpf_link__free(). Fix that. Fixes: a4634922 ("libbpf: Add linker extern resolution support for functions and global variables") Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20211124002325.1737739-6-andrii@kernel.org (cherry picked from commit 8cb12556) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit 2a6a9bf2 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2a6a9bf26170b4e156c18706cd230934ebd2f95f ------------------------------------------------- Sanitizer complains about qsort(), bsearch(), and memcpy() being called with NULL pointer. This can only happen when the associated number of elements is zero, so no harm should be done. But still prevent this from happening to keep sanitizer runs clean from extra noise. Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20211124002325.1737739-5-andrii@kernel.org (cherry picked from commit 2a6a9bf2) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit 401891a9 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=401891a9debaf0a684502f2aaecf53448cee9414 ------------------------------------------------- Perform a memory copy before we do the sanity checks of btf_ext_hdr. This prevents misaligned memory access if raw btf_ext data is not 4-byte aligned ([0]). While at it, also add missing const qualifier. [0] Closes: https://github.com/libbpf/libbpf/issues/391 Fixes: 2993e051 ("tools/bpf: add support to read .BTF.ext sections") Reported-by: NEvgeny Vereshchagin <evvers@ya.ru> Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20211124002325.1737739-3-andrii@kernel.org (cherry picked from commit 401891a9) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-
由 Andrii Nakryiko 提交于
mainline inclusion from mainline-5.17-rc1 commit 16e0c35c category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=16e0c35c6f7a2e90d52f3035ecf942af21417b7b ------------------------------------------------- Load global data maps lazily, if kernel is too old to support global data. Make sure that programs are still correct by detecting if any of the to-be-loaded programs have relocation against any of such maps. This allows to solve the issue ([0]) with bpf_printk() and Clang generating unnecessary and unreferenced .rodata.strX.Y sections, but it also goes further along the CO-RE lines, allowing to have a BPF object in which some code can work on very old kernels and relies only on BPF maps explicitly, while other BPF programs might enjoy global variable support. If such programs are correctly set to not load at runtime on old kernels, bpf_object will load and function correctly now. [0] https://lore.kernel.org/bpf/CAK-59YFPU3qO+_pXWOH+c1LSA=8WA1yabJZfREjOEXNHAqgXNg@mail.gmail.com/ Fixes: aed65917 ("libbpf: Support multiple .rodata.* and .data.* BPF maps") Signed-off-by: NAndrii Nakryiko <andrii@kernel.org> Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net> Acked-by: NSong Liu <songliubraving@fb.com> Link: https://lore.kernel.org/bpf/20211123200105.387855-1-andrii@kernel.org (cherry picked from commit 16e0c35c) Signed-off-by: NWang Yufen <wangyufen@huawei.com>
-