1. 06 Mar, 2024 4 commits
    • Daniel Borkmann's avatar
      xdp, bonding: Fix feature flags when there are no slave devs anymore · f267f262
      Daniel Borkmann authored
      Commit 9b0ed890 ("bonding: do not report NETDEV_XDP_ACT_XSK_ZEROCOPY")
      changed the driver from reporting everything as supported before a device
      was bonded into having the driver report that no XDP feature is supported
      until a real device is bonded as it seems to be more truthful given
      eventually real underlying devices decide what XDP features are supported.
      
      The change however did not take into account when all slave devices get
      removed from the bond device. In this case after 9b0ed890, the driver
      keeps reporting a feature mask of 0x77, that is, NETDEV_XDP_ACT_MASK &
      ~NETDEV_XDP_ACT_XSK_ZEROCOPY whereas it should have reported a feature
      mask of 0.
      
      Fix it by resetting XDP feature flags in the same way as if no XDP program
      is attached to the bond device. This was uncovered by the XDP bond selftest
      which let BPF CI fail. After adjusting the starting masks on the latter
      to 0 instead of NETDEV_XDP_ACT_MASK the test passes again together with
      this fix.
      
      Fixes: 9b0ed890 ("bonding: do not report NETDEV_XDP_ACT_XSK_ZEROCOPY")
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Cc: Magnus Karlsson <magnus.karlsson@intel.com>
      Cc: Prashant Batra <prbatra.mail@gmail.com>
      Cc: Toke Høiland-Jørgensen <toke@redhat.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Reviewed-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Message-ID: <20240305090829.17131-1-daniel@iogearbox.net>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      f267f262
    • Alexei Starovoitov's avatar
      Merge branch 'check-bpf_func_state-callback_depth-when-pruning-states' · 399eca1b
      Alexei Starovoitov authored
      Eduard Zingerman says:
      
      ====================
      check bpf_func_state->callback_depth when pruning states
      
      This patch-set fixes bug in states pruning logic hit in mailing list
      discussion [0]. The details of the fix are in patch #1.
      
      The main idea for the fix belongs to Yonghong Song,
      mine contribution is merely in review and test cases.
      
      There are some changes in verification performance:
      
      File                       Program        Insns    (DIFF)  States  (DIFF)
      -------------------------  -------------  ---------------  --------------
      pyperf600_bpf_loop.bpf.o   on_event          +15 (+0.42%)     +0 (+0.00%)
      strobemeta_bpf_loop.bpf.o  on_event        +857 (+37.95%)   +60 (+38.96%)
      xdp_synproxy_kern.bpf.o    syncookie_tc   +2892 (+30.39%)  +109 (+36.33%)
      xdp_synproxy_kern.bpf.o    syncookie_xdp  +2892 (+30.01%)  +109 (+36.09%)
      
      (when tested on a subset of selftests identified by
       selftests/bpf/veristat.cfg and Cilium bpf object files from [4])
      
      Changelog:
      v2 [2] -> v3:
      - fixes for verifier.c commit message as suggested by Yonghong;
      - patch-set re-rerouted to 'bpf' tree as suggested in [2];
      - patch for test_tcp_custom_syncookie is sent separately to 'bpf-next' [3].
      - veristat results updated using 'bpf' tree as baseline and clang 16.
      
      v1 [1] -> v2:
      - patch #2 commit message updated to better reflect verifier behavior
        with regards to checkpoints tree (suggested by Yonghong);
      - veristat results added (suggested by Andrii).
      
      [0] https://lore.kernel.org/bpf/9b251840-7cb8-4d17-bd23-1fc8071d8eef@linux.dev/
      [1] https://lore.kernel.org/bpf/20240212143832.28838-1-eddyz87@gmail.com/
      [2] https://lore.kernel.org/bpf/20240216150334.31937-1-eddyz87@gmail.com/
      [3] https://lore.kernel.org/bpf/20240222150300.14909-1-eddyz87@gmail.com/
      [4] https://github.com/anakryiko/cilium
      ====================
      
      Link: https://lore.kernel.org/r/20240222154121.6991-1-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      399eca1b
    • Eduard Zingerman's avatar
      selftests/bpf: test case for callback_depth states pruning logic · 5c2bc5e2
      Eduard Zingerman authored
      The test case was minimized from mailing list discussion [0].
      It is equivalent to the following C program:
      
          struct iter_limit_bug_ctx { __u64 a; __u64 b; __u64 c; };
      
          static __naked void iter_limit_bug_cb(void)
          {
          	switch (bpf_get_prandom_u32()) {
          	case 1:  ctx->a = 42; break;
          	case 2:  ctx->b = 42; break;
          	default: ctx->c = 42; break;
          	}
          }
      
          int iter_limit_bug(struct __sk_buff *skb)
          {
          	struct iter_limit_bug_ctx ctx = { 7, 7, 7 };
      
          	bpf_loop(2, iter_limit_bug_cb, &ctx, 0);
          	if (ctx.a == 42 && ctx.b == 42 && ctx.c == 7)
          	  asm volatile("r1 /= 0;":::"r1");
          	return 0;
          }
      
      The main idea is that each loop iteration changes one of the state
      variables in a non-deterministic manner. Hence it is premature to
      prune the states that have two iterations left comparing them to
      states with one iteration left.
      E.g. {{7,7,7}, callback_depth=0} can reach state {42,42,7},
      while {{7,7,7}, callback_depth=1} can't.
      
      [0] https://lore.kernel.org/bpf/9b251840-7cb8-4d17-bd23-1fc8071d8eef@linux.dev/Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
      Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/r/20240222154121.6991-3-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      5c2bc5e2
    • Eduard Zingerman's avatar
      bpf: check bpf_func_state->callback_depth when pruning states · e9a8e5a5
      Eduard Zingerman authored
      When comparing current and cached states verifier should consider
      bpf_func_state->callback_depth. Current state cannot be pruned against
      cached state, when current states has more iterations left compared to
      cached state. Current state has more iterations left when it's
      callback_depth is smaller.
      
      Below is an example illustrating this bug, minimized from mailing list
      discussion [0] (assume that BPF_F_TEST_STATE_FREQ is set).
      The example is not a safe program: if loop_cb point (1) is followed by
      loop_cb point (2), then division by zero is possible at point (4).
      
          struct ctx {
          	__u64 a;
          	__u64 b;
          	__u64 c;
          };
      
          static void loop_cb(int i, struct ctx *ctx)
          {
          	/* assume that generated code is "fallthrough-first":
          	 * if ... == 1 goto
          	 * if ... == 2 goto
          	 * <default>
          	 */
          	switch (bpf_get_prandom_u32()) {
          	case 1:  /* 1 */ ctx->a = 42; return 0; break;
          	case 2:  /* 2 */ ctx->b = 42; return 0; break;
          	default: /* 3 */ ctx->c = 42; return 0; break;
          	}
          }
      
          SEC("tc")
          __failure
          __flag(BPF_F_TEST_STATE_FREQ)
          int test(struct __sk_buff *skb)
          {
          	struct ctx ctx = { 7, 7, 7 };
      
          	bpf_loop(2, loop_cb, &ctx, 0);              /* 0 */
          	/* assume generated checks are in-order: .a first */
          	if (ctx.a == 42 && ctx.b == 42 && ctx.c == 7)
          		asm volatile("r0 /= 0;":::"r0");    /* 4 */
          	return 0;
          }
      
      Prior to this commit verifier built the following checkpoint tree for
      this example:
      
       .------------------------------------- Checkpoint / State name
       |    .-------------------------------- Code point number
       |    |   .---------------------------- Stack state {ctx.a,ctx.b,ctx.c}
       |    |   |        .------------------- Callback depth in frame #0
       v    v   v        v
         - (0) {7P,7P,7},depth=0
           - (3) {7P,7P,7},depth=1
             - (0) {7P,7P,42},depth=1
               - (3) {7P,7,42},depth=2
                 - (0) {7P,7,42},depth=2      loop terminates because of depth limit
                   - (4) {7P,7,42},depth=0    predicted false, ctx.a marked precise
                   - (6) exit
      (a)      - (2) {7P,7,42},depth=2
                 - (0) {7P,42,42},depth=2     loop terminates because of depth limit
                   - (4) {7P,42,42},depth=0   predicted false, ctx.a marked precise
                   - (6) exit
      (b)      - (1) {7P,7P,42},depth=2
                 - (0) {42P,7P,42},depth=2    loop terminates because of depth limit
                   - (4) {42P,7P,42},depth=0  predicted false, ctx.{a,b} marked precise
                   - (6) exit
           - (2) {7P,7,7},depth=1             considered safe, pruned using checkpoint (a)
      (c)  - (1) {7P,7P,7},depth=1            considered safe, pruned using checkpoint (b)
      
      Here checkpoint (b) has callback_depth of 2, meaning that it would
      never reach state {42,42,7}.
      While checkpoint (c) has callback_depth of 1, and thus
      could yet explore the state {42,42,7} if not pruned prematurely.
      This commit makes forbids such premature pruning,
      allowing verifier to explore states sub-tree starting at (c):
      
      (c)  - (1) {7,7,7P},depth=1
             - (0) {42P,7,7P},depth=1
               ...
               - (2) {42,7,7},depth=2
                 - (0) {42,42,7},depth=2      loop terminates because of depth limit
                   - (4) {42,42,7},depth=0    predicted true, ctx.{a,b,c} marked precise
                     - (5) division by zero
      
      [0] https://lore.kernel.org/bpf/9b251840-7cb8-4d17-bd23-1fc8071d8eef@linux.dev/
      
      Fixes: bb124da6 ("bpf: keep track of max number of bpf_loop callback iterations")
      Suggested-by: default avatarYonghong Song <yonghong.song@linux.dev>
      Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
      Link: https://lore.kernel.org/r/20240222154121.6991-2-eddyz87@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      e9a8e5a5
  2. 05 Mar, 2024 4 commits
    • Eric Dumazet's avatar
      net/ipv6: avoid possible UAF in ip6_route_mpath_notify() · 685f7d53
      Eric Dumazet authored
      syzbot found another use-after-free in ip6_route_mpath_notify() [1]
      
      Commit f7225172 ("net/ipv6: prevent use after free in
      ip6_route_mpath_notify") was not able to fix the root cause.
      
      We need to defer the fib6_info_release() calls after
      ip6_route_mpath_notify(), in the cleanup phase.
      
      [1]
      BUG: KASAN: slab-use-after-free in rt6_fill_node+0x1460/0x1ac0
      Read of size 4 at addr ffff88809a07fc64 by task syz-executor.2/23037
      
      CPU: 0 PID: 23037 Comm: syz-executor.2 Not tainted 6.8.0-rc4-syzkaller-01035-gea7f3cfa #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
      Call Trace:
       <TASK>
        __dump_stack lib/dump_stack.c:88 [inline]
        dump_stack_lvl+0x1e7/0x2e0 lib/dump_stack.c:106
        print_address_description mm/kasan/report.c:377 [inline]
        print_report+0x167/0x540 mm/kasan/report.c:488
        kasan_report+0x142/0x180 mm/kasan/report.c:601
       rt6_fill_node+0x1460/0x1ac0
        inet6_rt_notify+0x13b/0x290 net/ipv6/route.c:6184
        ip6_route_mpath_notify net/ipv6/route.c:5198 [inline]
        ip6_route_multipath_add net/ipv6/route.c:5404 [inline]
        inet6_rtm_newroute+0x1d0f/0x2300 net/ipv6/route.c:5517
        rtnetlink_rcv_msg+0x885/0x1040 net/core/rtnetlink.c:6597
        netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543
        netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline]
        netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367
        netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908
        sock_sendmsg_nosec net/socket.c:730 [inline]
        __sock_sendmsg+0x221/0x270 net/socket.c:745
        ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584
        ___sys_sendmsg net/socket.c:2638 [inline]
        __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667
       do_syscall_64+0xf9/0x240
       entry_SYSCALL_64_after_hwframe+0x6f/0x77
      RIP: 0033:0x7f73dd87dda9
      Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007f73de6550c8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007f73dd9ac050 RCX: 00007f73dd87dda9
      RDX: 0000000000000000 RSI: 0000000020000140 RDI: 0000000000000005
      RBP: 00007f73dd8ca47a R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      R13: 000000000000006e R14: 00007f73dd9ac050 R15: 00007ffdbdeb7858
       </TASK>
      
      Allocated by task 23037:
        kasan_save_stack mm/kasan/common.c:47 [inline]
        kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
        poison_kmalloc_redzone mm/kasan/common.c:372 [inline]
        __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:389
        kasan_kmalloc include/linux/kasan.h:211 [inline]
        __do_kmalloc_node mm/slub.c:3981 [inline]
        __kmalloc+0x22e/0x490 mm/slub.c:3994
        kmalloc include/linux/slab.h:594 [inline]
        kzalloc include/linux/slab.h:711 [inline]
        fib6_info_alloc+0x2e/0xf0 net/ipv6/ip6_fib.c:155
        ip6_route_info_create+0x445/0x12b0 net/ipv6/route.c:3758
        ip6_route_multipath_add net/ipv6/route.c:5298 [inline]
        inet6_rtm_newroute+0x744/0x2300 net/ipv6/route.c:5517
        rtnetlink_rcv_msg+0x885/0x1040 net/core/rtnetlink.c:6597
        netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543
        netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline]
        netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367
        netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908
        sock_sendmsg_nosec net/socket.c:730 [inline]
        __sock_sendmsg+0x221/0x270 net/socket.c:745
        ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584
        ___sys_sendmsg net/socket.c:2638 [inline]
        __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667
       do_syscall_64+0xf9/0x240
       entry_SYSCALL_64_after_hwframe+0x6f/0x77
      
      Freed by task 16:
        kasan_save_stack mm/kasan/common.c:47 [inline]
        kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
        kasan_save_free_info+0x4e/0x60 mm/kasan/generic.c:640
        poison_slab_object+0xa6/0xe0 mm/kasan/common.c:241
        __kasan_slab_free+0x34/0x70 mm/kasan/common.c:257
        kasan_slab_free include/linux/kasan.h:184 [inline]
        slab_free_hook mm/slub.c:2121 [inline]
        slab_free mm/slub.c:4299 [inline]
        kfree+0x14a/0x380 mm/slub.c:4409
        rcu_do_batch kernel/rcu/tree.c:2190 [inline]
        rcu_core+0xd76/0x1810 kernel/rcu/tree.c:2465
        __do_softirq+0x2bb/0x942 kernel/softirq.c:553
      
      Last potentially related work creation:
        kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47
        __kasan_record_aux_stack+0xae/0x100 mm/kasan/generic.c:586
        __call_rcu_common kernel/rcu/tree.c:2715 [inline]
        call_rcu+0x167/0xa80 kernel/rcu/tree.c:2829
        fib6_info_release include/net/ip6_fib.h:341 [inline]
        ip6_route_multipath_add net/ipv6/route.c:5344 [inline]
        inet6_rtm_newroute+0x114d/0x2300 net/ipv6/route.c:5517
        rtnetlink_rcv_msg+0x885/0x1040 net/core/rtnetlink.c:6597
        netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543
        netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline]
        netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367
        netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908
        sock_sendmsg_nosec net/socket.c:730 [inline]
        __sock_sendmsg+0x221/0x270 net/socket.c:745
        ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584
        ___sys_sendmsg net/socket.c:2638 [inline]
        __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667
       do_syscall_64+0xf9/0x240
       entry_SYSCALL_64_after_hwframe+0x6f/0x77
      
      The buggy address belongs to the object at ffff88809a07fc00
       which belongs to the cache kmalloc-512 of size 512
      The buggy address is located 100 bytes inside of
       freed 512-byte region [ffff88809a07fc00, ffff88809a07fe00)
      
      The buggy address belongs to the physical page:
      page:ffffea0002681f00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x9a07c
      head:ffffea0002681f00 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0
      flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
      page_type: 0xffffffff()
      raw: 00fff00000000840 ffff888014c41c80 dead000000000122 0000000000000000
      raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      page_owner tracks the page as allocated
      page last allocated via order 2, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 23028, tgid 23027 (syz-executor.4), ts 2340253595219, free_ts 2339107097036
        set_page_owner include/linux/page_owner.h:31 [inline]
        post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1533
        prep_new_page mm/page_alloc.c:1540 [inline]
        get_page_from_freelist+0x33ea/0x3580 mm/page_alloc.c:3311
        __alloc_pages+0x255/0x680 mm/page_alloc.c:4567
        __alloc_pages_node include/linux/gfp.h:238 [inline]
        alloc_pages_node include/linux/gfp.h:261 [inline]
        alloc_slab_page+0x5f/0x160 mm/slub.c:2190
        allocate_slab mm/slub.c:2354 [inline]
        new_slab+0x84/0x2f0 mm/slub.c:2407
        ___slab_alloc+0xd17/0x13e0 mm/slub.c:3540
        __slab_alloc mm/slub.c:3625 [inline]
        __slab_alloc_node mm/slub.c:3678 [inline]
        slab_alloc_node mm/slub.c:3850 [inline]
        __do_kmalloc_node mm/slub.c:3980 [inline]
        __kmalloc+0x2e0/0x490 mm/slub.c:3994
        kmalloc include/linux/slab.h:594 [inline]
        kzalloc include/linux/slab.h:711 [inline]
        new_dir fs/proc/proc_sysctl.c:956 [inline]
        get_subdir fs/proc/proc_sysctl.c:1000 [inline]
        sysctl_mkdir_p fs/proc/proc_sysctl.c:1295 [inline]
        __register_sysctl_table+0xb30/0x1440 fs/proc/proc_sysctl.c:1376
        neigh_sysctl_register+0x416/0x500 net/core/neighbour.c:3859
        devinet_sysctl_register+0xaf/0x1f0 net/ipv4/devinet.c:2644
        inetdev_init+0x296/0x4d0 net/ipv4/devinet.c:286
        inetdev_event+0x338/0x15c0 net/ipv4/devinet.c:1555
        notifier_call_chain+0x18f/0x3b0 kernel/notifier.c:93
        call_netdevice_notifiers_extack net/core/dev.c:1987 [inline]
        call_netdevice_notifiers net/core/dev.c:2001 [inline]
        register_netdevice+0x15b2/0x1a20 net/core/dev.c:10340
        br_dev_newlink+0x27/0x100 net/bridge/br_netlink.c:1563
        rtnl_newlink_create net/core/rtnetlink.c:3497 [inline]
        __rtnl_newlink net/core/rtnetlink.c:3717 [inline]
        rtnl_newlink+0x158f/0x20a0 net/core/rtnetlink.c:3730
      page last free pid 11583 tgid 11583 stack trace:
        reset_page_owner include/linux/page_owner.h:24 [inline]
        free_pages_prepare mm/page_alloc.c:1140 [inline]
        free_unref_page_prepare+0x968/0xa90 mm/page_alloc.c:2346
        free_unref_page+0x37/0x3f0 mm/page_alloc.c:2486
        kasan_depopulate_vmalloc_pte+0x74/0x90 mm/kasan/shadow.c:415
        apply_to_pte_range mm/memory.c:2619 [inline]
        apply_to_pmd_range mm/memory.c:2663 [inline]
        apply_to_pud_range mm/memory.c:2699 [inline]
        apply_to_p4d_range mm/memory.c:2735 [inline]
        __apply_to_page_range+0x8ec/0xe40 mm/memory.c:2769
        kasan_release_vmalloc+0x9a/0xb0 mm/kasan/shadow.c:532
        __purge_vmap_area_lazy+0x163f/0x1a10 mm/vmalloc.c:1770
        drain_vmap_area_work+0x40/0xd0 mm/vmalloc.c:1804
        process_one_work kernel/workqueue.c:2633 [inline]
        process_scheduled_works+0x913/0x1420 kernel/workqueue.c:2706
        worker_thread+0xa5f/0x1000 kernel/workqueue.c:2787
        kthread+0x2ef/0x390 kernel/kthread.c:388
        ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
        ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242
      
      Memory state around the buggy address:
       ffff88809a07fb00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff88809a07fb80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      >ffff88809a07fc00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                             ^
       ffff88809a07fc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff88809a07fd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      
      Fixes: 3b1137fe ("net: ipv6: Change notifications for multipath add to RTA_MULTIPATH")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/20240303144801.702646-1-edumazet@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      685f7d53
    • Jakub Kicinski's avatar
      Merge tag 'mlx5-fixes-2024-03-01' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux · 4daa8731
      Jakub Kicinski authored
      Saeed Mahameed says:
      
      ====================
      mlx5 fixes 2024-03-01
      
      This series provides bug fixes to mlx5 driver.
      Please pull and let me know if there is any problem.
      
      * tag 'mlx5-fixes-2024-03-01' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux:
        net/mlx5e: Switch to using _bh variant of of spinlock API in port timestamping NAPI poll context
        net/mlx5e: Use a memory barrier to enforce PTP WQ xmit submission tracking occurs after populating the metadata_map
        net/mlx5e: Fix MACsec state loss upon state update in offload path
        net/mlx5e: Change the warning when ignore_flow_level is not supported
        net/mlx5: Check capability for fw_reset
        net/mlx5: Fix fw reporter diagnose output
        net/mlx5: E-switch, Change flow rule destination checking
        Revert "net/mlx5e: Check the number of elements before walk TC rhashtable"
        Revert "net/mlx5: Block entering switchdev mode with ns inconsistency"
      ====================
      
      Link: https://lore.kernel.org/r/20240302070318.62997-1-saeed@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4daa8731
    • Jakub Kicinski's avatar
      Merge branch '10GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue · 47fe2fc1
      Jakub Kicinski authored
      Tony Nguyen says:
      
      ====================
      Intel Wired LAN Driver Updates 2024-03-01 (ixgbe, i40e, ice)
      
      This series contains updates to ixgbe, i40e, and ice drivers.
      
      Maciej corrects disable flow for ixgbe, i40e, and ice drivers which could
      cause non-functional interface with AF_XDP.
      
      Michal restores host configuration when changing MSI-X count for VFs on
      ice driver.
      
      * '10GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue:
        ice: reconfig host after changing MSI-X on VF
        ice: reorder disabling IRQ and NAPI in ice_qp_dis
        i40e: disable NAPI right after disabling irqs when handling xsk_pool
        ixgbe: {dis, en}able irqs in ixgbe_txrx_ring_{dis, en}able
      ====================
      
      Link: https://lore.kernel.org/r/20240301192549.2993798-1-anthony.l.nguyen@intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      47fe2fc1
    • Horatiu Vultur's avatar
      net: sparx5: Fix use after free inside sparx5_del_mact_entry · 89d72d41
      Horatiu Vultur authored
      Based on the static analyzis of the code it looks like when an entry
      from the MAC table was removed, the entry was still used after being
      freed. More precise the vid of the mac_entry was used after calling
      devm_kfree on the mac_entry.
      The fix consists in first using the vid of the mac_entry to delete the
      entry from the HW and after that to free it.
      
      Fixes: b37a1bae ("net: sparx5: add mactable support")
      Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20240301080608.3053468-1-horatiu.vultur@microchip.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      89d72d41
  3. 04 Mar, 2024 6 commits
    • David S. Miller's avatar
      Merge branch 'mptcp-test-fixes' · 948abb59
      David S. Miller authored
      Matthieu Baerts says:
      
      ====================
      selftests: mptcp: fixes for diag.sh
      
      Here are two patches fixing issues in MPTCP diag.sh kselftest:
      
      - Patch 1 makes sure the exit code is '1' in case of error, and not the
        test ID, not to return an exit code that would be wrongly interpreted
        by the ksefltests framework, e.g. '4' means 'skip'.
      
      - Patch 2 avoids waiting for unnecessary conditions, which can cause
        timeouts in some very slow environments.
      ====================
      Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
      948abb59
    • Matthieu Baerts (NGI0)'s avatar
      selftests: mptcp: diag: avoid extra waiting · f05d2283
      Matthieu Baerts (NGI0) authored
      When creating a lot of listener sockets, it is enough to wait only for
      the last one, like we are doing before in diag.sh for other subtests.
      
      If we do a check for each listener sockets, each time listing all
      available sockets, it can take a very long time in very slow
      environments, at the point we can reach some timeout.
      
      When using the debug kconfig, the waiting time switches from more than
      8 sec to 0.1 sec on my side. In slow/busy environments, and with a poll
      timeout set to 30 ms, the waiting time could go up to ~100 sec because
      the listener socket would timeout and stop, while the script would still
      be checking one by one if all sockets are ready. The result is that
      after having waited for everything to be ready, all sockets have been
      stopped due to a timeout, and it is too late for the script to check how
      many there were.
      
      While at it, also removed ss options we don't need: we only need the
      filtering options, to count how many listener sockets have been created.
      We don't need to ask ss to display internal TCP information, and the
      memory if the output is dropped by the 'wc -l' command anyway.
      
      Fixes: b4b51d36 ("selftests: mptcp: explicitly trigger the listener diag code-path")
      Reported-by: default avatarJakub Kicinski <kuba@kernel.org>
      Closes: https://lore.kernel.org/r/20240301063754.2ecefecf@kernel.orgSigned-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f05d2283
    • Geliang Tang's avatar
      selftests: mptcp: diag: return KSFT_FAIL not test_cnt · 45bcc034
      Geliang Tang authored
      The test counter 'test_cnt' should not be returned in diag.sh, e.g. what
      if only the 4th test fail? Will do 'exit 4' which is 'exit ${KSFT_SKIP}',
      the whole test will be marked as skipped instead of 'failed'!
      
      So we should do ret=${KSFT_FAIL} instead.
      
      Fixes: df62f2ec ("selftests/mptcp: add diag interface tests")
      Cc: stable@vger.kernel.org
      Fixes: 42fb6cdd ("selftests: mptcp: more stable diag tests")
      Signed-off-by: default avatarGeliang Tang <tanggeliang@kylinos.cn>
      Reviewed-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
      Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      45bcc034
    • Jakub Kicinski's avatar
      page_pool: fix netlink dump stop/resume · 429679dc
      Jakub Kicinski authored
      If message fills up we need to stop writing. 'break' will
      only get us out of the iteration over pools of a single
      netdev, we need to also stop walking netdevs.
      
      This results in either infinite dump, or missing pools,
      depending on whether message full happens on the last
      netdev (infinite dump) or non-last (missing pools).
      
      Fixes: 950ab53b ("net: page_pool: implement GET in the netlink API")
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      429679dc
    • Eric Dumazet's avatar
      geneve: make sure to pull inner header in geneve_rx() · 1ca1ba46
      Eric Dumazet authored
      syzbot triggered a bug in geneve_rx() [1]
      
      Issue is similar to the one I fixed in commit 8d975c15
      ("ip6_tunnel: make sure to pull inner header in __ip6_tnl_rcv()")
      
      We have to save skb->network_header in a temporary variable
      in order to be able to recompute the network_header pointer
      after a pskb_inet_may_pull() call.
      
      pskb_inet_may_pull() makes sure the needed headers are in skb->head.
      
      [1]
      BUG: KMSAN: uninit-value in IP_ECN_decapsulate include/net/inet_ecn.h:302 [inline]
       BUG: KMSAN: uninit-value in geneve_rx drivers/net/geneve.c:279 [inline]
       BUG: KMSAN: uninit-value in geneve_udp_encap_recv+0x36f9/0x3c10 drivers/net/geneve.c:391
        IP_ECN_decapsulate include/net/inet_ecn.h:302 [inline]
        geneve_rx drivers/net/geneve.c:279 [inline]
        geneve_udp_encap_recv+0x36f9/0x3c10 drivers/net/geneve.c:391
        udp_queue_rcv_one_skb+0x1d39/0x1f20 net/ipv4/udp.c:2108
        udp_queue_rcv_skb+0x6ae/0x6e0 net/ipv4/udp.c:2186
        udp_unicast_rcv_skb+0x184/0x4b0 net/ipv4/udp.c:2346
        __udp4_lib_rcv+0x1c6b/0x3010 net/ipv4/udp.c:2422
        udp_rcv+0x7d/0xa0 net/ipv4/udp.c:2604
        ip_protocol_deliver_rcu+0x264/0x1300 net/ipv4/ip_input.c:205
        ip_local_deliver_finish+0x2b8/0x440 net/ipv4/ip_input.c:233
        NF_HOOK include/linux/netfilter.h:314 [inline]
        ip_local_deliver+0x21f/0x490 net/ipv4/ip_input.c:254
        dst_input include/net/dst.h:461 [inline]
        ip_rcv_finish net/ipv4/ip_input.c:449 [inline]
        NF_HOOK include/linux/netfilter.h:314 [inline]
        ip_rcv+0x46f/0x760 net/ipv4/ip_input.c:569
        __netif_receive_skb_one_core net/core/dev.c:5534 [inline]
        __netif_receive_skb+0x1a6/0x5a0 net/core/dev.c:5648
        process_backlog+0x480/0x8b0 net/core/dev.c:5976
        __napi_poll+0xe3/0x980 net/core/dev.c:6576
        napi_poll net/core/dev.c:6645 [inline]
        net_rx_action+0x8b8/0x1870 net/core/dev.c:6778
        __do_softirq+0x1b7/0x7c5 kernel/softirq.c:553
        do_softirq+0x9a/0xf0 kernel/softirq.c:454
        __local_bh_enable_ip+0x9b/0xa0 kernel/softirq.c:381
        local_bh_enable include/linux/bottom_half.h:33 [inline]
        rcu_read_unlock_bh include/linux/rcupdate.h:820 [inline]
        __dev_queue_xmit+0x2768/0x51c0 net/core/dev.c:4378
        dev_queue_xmit include/linux/netdevice.h:3171 [inline]
        packet_xmit+0x9c/0x6b0 net/packet/af_packet.c:276
        packet_snd net/packet/af_packet.c:3081 [inline]
        packet_sendmsg+0x8aef/0x9f10 net/packet/af_packet.c:3113
        sock_sendmsg_nosec net/socket.c:730 [inline]
        __sock_sendmsg net/socket.c:745 [inline]
        __sys_sendto+0x735/0xa10 net/socket.c:2191
        __do_sys_sendto net/socket.c:2203 [inline]
        __se_sys_sendto net/socket.c:2199 [inline]
        __x64_sys_sendto+0x125/0x1c0 net/socket.c:2199
        do_syscall_x64 arch/x86/entry/common.c:52 [inline]
        do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      Uninit was created at:
        slab_post_alloc_hook mm/slub.c:3819 [inline]
        slab_alloc_node mm/slub.c:3860 [inline]
        kmem_cache_alloc_node+0x5cb/0xbc0 mm/slub.c:3903
        kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:560
        __alloc_skb+0x352/0x790 net/core/skbuff.c:651
        alloc_skb include/linux/skbuff.h:1296 [inline]
        alloc_skb_with_frags+0xc8/0xbd0 net/core/skbuff.c:6394
        sock_alloc_send_pskb+0xa80/0xbf0 net/core/sock.c:2783
        packet_alloc_skb net/packet/af_packet.c:2930 [inline]
        packet_snd net/packet/af_packet.c:3024 [inline]
        packet_sendmsg+0x70c2/0x9f10 net/packet/af_packet.c:3113
        sock_sendmsg_nosec net/socket.c:730 [inline]
        __sock_sendmsg net/socket.c:745 [inline]
        __sys_sendto+0x735/0xa10 net/socket.c:2191
        __do_sys_sendto net/socket.c:2203 [inline]
        __se_sys_sendto net/socket.c:2199 [inline]
        __x64_sys_sendto+0x125/0x1c0 net/socket.c:2199
        do_syscall_x64 arch/x86/entry/common.c:52 [inline]
        do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      Fixes: 2d07dc79 ("geneve: add initial netdev driver for GENEVE tunnels")
      Reported-and-tested-by: syzbot+6a1423ff3f97159aae64@syzkaller.appspotmail.com
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1ca1ba46
    • Steven Rostedt (Google)'s avatar
      tracing/net_sched: Fix tracepoints that save qdisc_dev() as a string · 51270d57
      Steven Rostedt (Google) authored
      I'm updating __assign_str() and will be removing the second parameter. To
      make sure that it does not break anything, I make sure that it matches the
      __string() field, as that is where the string is actually going to be
      saved in. To make sure there's nothing that breaks, I added a WARN_ON() to
      make sure that what was used in __string() is the same that is used in
      __assign_str().
      
      In doing this change, an error was triggered as __assign_str() now expects
      the string passed in to be a char * value. I instead had the following
      warning:
      
      include/trace/events/qdisc.h: In function ‘trace_event_raw_event_qdisc_reset’:
      include/trace/events/qdisc.h:91:35: error: passing argument 1 of 'strcmp' from incompatible pointer type [-Werror=incompatible-pointer-types]
         91 |                 __assign_str(dev, qdisc_dev(q));
      
      That's because the qdisc_enqueue() and qdisc_reset() pass in qdisc_dev(q)
      to __assign_str() and to __string(). But that function returns a pointer
      to struct net_device and not a string.
      
      It appears that these events are just saving the pointer as a string and
      then reading it as a string as well.
      
      Use qdisc_dev(q)->name to save the device instead.
      
      Fixes: a34dac0b ("net_sched: add tracepoints for qdisc_reset() and qdisc_destroy()")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Reviewed-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      51270d57
  4. 02 Mar, 2024 9 commits
  5. 01 Mar, 2024 8 commits
  6. 29 Feb, 2024 9 commits