tree:
https://git.kernel.org/pub/scm/linux/kernel/git/toke/linux.git
bpf-freplace-multi-attach-alt-04
head: 4b32f3fa732bbc5ab739fc9a0b9864c66a6183fd
commit: 22ff8de2b0635ae278b2698fcf7c1581cb776567 [4/8] bpf: support attaching freplace
programs to multiple attach points
config: nios2-randconfig-m031-20200920 (attached as .config)
compiler: nios2-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 22ff8de2b0635ae278b2698fcf7c1581cb776567
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nios2
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
In file included from kernel/bpf/syscall.c:4:
include/linux/bpf.h:680:15: error: unknown type name 'bpf_trampoline'
680 | static inline bpf_trampoline *bpf_trampoline_get(u64 key, void *addr,
| ^~~~~~~~~~~~~~
kernel/bpf/syscall.c: In function 'bpf_tracing_prog_attach':
> kernel/bpf/syscall.c:2696:6: error: assignment to 'struct
bpf_trampoline *' from incompatible pointer type 'int *'
[-Werror=incompatible-pointer-types]
2696 | tr = bpf_trampoline_get(key, (void
*)addr, &fmodel);
| ^
cc1: some warnings being treated as errors
#
https://git.kernel.org/pub/scm/linux/kernel/git/toke/linux.git/commit/?id...
git remote add toke
https://git.kernel.org/pub/scm/linux/kernel/git/toke/linux.git
git fetch --no-tags toke bpf-freplace-multi-attach-alt-04
git checkout 22ff8de2b0635ae278b2698fcf7c1581cb776567
vim +2696 kernel/bpf/syscall.c
2593
2594 static int bpf_tracing_prog_attach(struct bpf_prog *prog,
2595 int tgt_prog_fd,
2596 u32 btf_id)
2597 {
2598 struct bpf_link_primer link_primer;
2599 struct bpf_prog *tgt_prog = NULL;
2600 struct bpf_tracing_link *link;
2601 struct btf_func_model fmodel;
2602 bool restore_link = false;
2603 long addr;
2604 u64 key;
2605 int err;
2606
2607 switch (prog->type) {
2608 case BPF_PROG_TYPE_TRACING:
2609 if (prog->expected_attach_type != BPF_TRACE_FENTRY &&
2610 prog->expected_attach_type != BPF_TRACE_FEXIT &&
2611 prog->expected_attach_type != BPF_MODIFY_RETURN) {
2612 err = -EINVAL;
2613 goto out_put_prog;
2614 }
2615 break;
2616 case BPF_PROG_TYPE_EXT:
2617 if (prog->expected_attach_type != 0) {
2618 err = -EINVAL;
2619 goto out_put_prog;
2620 }
2621 break;
2622 case BPF_PROG_TYPE_LSM:
2623 if (prog->expected_attach_type != BPF_LSM_MAC) {
2624 err = -EINVAL;
2625 goto out_put_prog;
2626 }
2627 break;
2628 default:
2629 err = -EINVAL;
2630 goto out_put_prog;
2631 }
2632 if (tgt_prog_fd) {
2633 /* For now we only allow new targets for BPF_PROG_TYPE_EXT */
2634 if (prog->type != BPF_PROG_TYPE_EXT || !btf_id) {
2635 err = -EINVAL;
2636 goto out_put_prog;
2637 }
2638
2639 tgt_prog = bpf_prog_get(tgt_prog_fd);
2640 if (IS_ERR(tgt_prog)) {
2641 err = PTR_ERR(tgt_prog);
2642 goto out_put_prog;
2643 }
2644
2645 key = ((u64)tgt_prog->aux->id) << 32 | btf_id;
2646 } else if (btf_id) {
2647 err = -EINVAL;
2648 goto out_put_prog;
2649 }
2650
2651 link = xchg(&prog->aux->tgt_link, NULL);
2652 if (link && tgt_prog) {
2653 if (link->trampoline->key != key) {
2654 /* supplying a tgt_prog is always destructive of the
2655 * target ref from the extension prog, which means that
2656 * mixing old and new API is not supported.
2657 */
2658 bpf_tracing_link_free(link);
2659 link = NULL;
2660 } else {
2661 /* re-using link that already has ref on tgt_prog, don't
2662 * take another
2663 */
2664 bpf_prog_put(tgt_prog);
2665 tgt_prog = NULL;
2666 }
2667 } else if (link) {
2668 /* called without a target fd, so restore link on failure for
2669 * compatibility
2670 */
2671 restore_link = true;
2672 }
2673
2674 if (!link) {
2675 struct bpf_trampoline *tr;
2676
2677 if (!tgt_prog) {
2678 err = -ENOENT;
2679 goto out_put_prog;
2680 }
2681
2682 err = bpf_check_attach_target(NULL, prog, tgt_prog, btf_id,
2683 &fmodel, &addr, NULL, NULL);
2684 if (err) {
2685 bpf_prog_put(tgt_prog);
2686 goto out_put_prog;
2687 }
2688
2689 link = bpf_tracing_link_create(prog, tgt_prog);
2690 if (IS_ERR(link)) {
2691 bpf_prog_put(tgt_prog);
2692 err = PTR_ERR(link);
2693 goto out_put_prog;
2694 }
2695
2696 tr = bpf_trampoline_get(key, (void *)addr, &fmodel);
2697 if (IS_ERR(tr)) {
2698 err = PTR_ERR(tr);
2699 goto out_put_link;
2700 }
2701 link->trampoline = tr;
2702 }
2703
2704 err = bpf_link_prime(&link->link, &link_primer);
2705 if (err)
2706 goto out_put_link;
2707
2708 err = bpf_trampoline_link_prog(prog, link->trampoline);
2709 if (err) {
2710 bpf_trampoline_put(link->trampoline);
2711 link->trampoline = NULL;
2712 bpf_link_cleanup(&link_primer);
2713 goto out_put_prog;
2714 }
2715
2716 return bpf_link_settle(&link_primer);
2717 out_put_link:
2718 if (restore_link)
2719 WARN_ON_ONCE(cmpxchg(&prog->aux->tgt_link, NULL, link) != NULL);
2720 else
2721 bpf_tracing_link_free(link);
2722 out_put_prog:
2723 bpf_prog_put(prog);
2724 return err;
2725 }
2726
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org