1. 28 Mar, 2024 6 commits
    • Paolo Abeni's avatar
      Merge tag 'nf-24-03-28' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf · 005e528c
      Paolo Abeni authored
      Pablo Neira Ayuso says:
      
      ====================
      Netfilter fixes for net
      
      The following patchset contains Netfilter fixes for net:
      
      Patch #1 reject destroy chain command to delete device hooks in netdev
               family, hence, only delchain commands are allowed.
      
      Patch #2 reject table flag update interference with netdev basechain
      	 hook updates, this can leave hooks in inconsistent
      	 registration/unregistration state.
      
      Patch #3 do not unregister netdev basechain hooks if table is dormant.
      	 Otherwise, splat with double unregistration is possible.
      
      Patch #4 fixes Kconfig to allow to restore IP_NF_ARPTABLES,
      	 from Kuniyuki Iwashima.
      
      There are a more fixes still in progress on my side that need more work.
      
      * tag 'nf-24-03-28' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf:
        netfilter: arptables: Select NETFILTER_FAMILY_ARP when building arp_tables.c
        netfilter: nf_tables: skip netdev hook unregistration if table is dormant
        netfilter: nf_tables: reject table flag and netdev basechain updates
        netfilter: nf_tables: reject destroy command to remove basechain hooks
      ====================
      
      Link: https://lore.kernel.org/r/20240328031855.2063-1-pablo@netfilter.orgSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      005e528c
    • Paolo Abeni's avatar
      Merge tag 'for-net' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf · 7e6f4b2a
      Paolo Abeni authored
      Alexei Starovoitov says:
      
      ====================
      pull-request: bpf 2024-03-27
      
      The following pull-request contains BPF updates for your *net* tree.
      
      We've added 4 non-merge commits during the last 1 day(s) which contain
      a total of 5 files changed, 26 insertions(+), 3 deletions(-).
      
      The main changes are:
      
      1) Fix bloom filter value size validation and protect the verifier
         against such mistakes, from Andrei.
      
      2) Fix build due to CONFIG_KEXEC_CORE/CRASH_DUMP split, from Hari.
      
      3) Update bpf_lsm maintainers entry, from Matt.
      
      * tag 'for-net' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf:
        bpf: update BPF LSM designated reviewer list
        bpf: Protect against int overflow for stack access size
        bpf: Check bloom filter map value size
        bpf: fix warning for crash_kexec
      ====================
      
      Link: https://lore.kernel.org/r/20240328012938.24249-1-alexei.starovoitov@gmail.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      7e6f4b2a
    • Kuniyuki Iwashima's avatar
      netfilter: arptables: Select NETFILTER_FAMILY_ARP when building arp_tables.c · 15fba562
      Kuniyuki Iwashima authored
      syzkaller started to report a warning below [0] after consuming the
      commit 4654467d ("netfilter: arptables: allow xtables-nft only
      builds").
      
      The change accidentally removed the dependency on NETFILTER_FAMILY_ARP
      from IP_NF_ARPTABLES.
      
      If NF_TABLES_ARP is not enabled on Kconfig, NETFILTER_FAMILY_ARP will
      be removed and some code necessary for arptables will not be compiled.
      
        $ grep -E "(NETFILTER_FAMILY_ARP|IP_NF_ARPTABLES|NF_TABLES_ARP)" .config
        CONFIG_NETFILTER_FAMILY_ARP=y
        # CONFIG_NF_TABLES_ARP is not set
        CONFIG_IP_NF_ARPTABLES=y
      
        $ make olddefconfig
      
        $ grep -E "(NETFILTER_FAMILY_ARP|IP_NF_ARPTABLES|NF_TABLES_ARP)" .config
        # CONFIG_NF_TABLES_ARP is not set
        CONFIG_IP_NF_ARPTABLES=y
      
      So, when nf_register_net_hooks() is called for arptables, it will
      trigger the splat below.
      
      Now IP_NF_ARPTABLES is only enabled by IP_NF_ARPFILTER, so let's
      restore the dependency on NETFILTER_FAMILY_ARP in IP_NF_ARPFILTER.
      
      [0]:
      WARNING: CPU: 0 PID: 242 at net/netfilter/core.c:316 nf_hook_entry_head+0x1e1/0x2c0 net/netfilter/core.c:316
      Modules linked in:
      CPU: 0 PID: 242 Comm: syz-executor.0 Not tainted 6.8.0-12821-g537c2e91 #10
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
      RIP: 0010:nf_hook_entry_head+0x1e1/0x2c0 net/netfilter/core.c:316
      Code: 83 fd 04 0f 87 bc 00 00 00 e8 5b 84 83 fd 4d 8d ac ec a8 0b 00 00 e8 4e 84 83 fd 4c 89 e8 5b 5d 41 5c 41 5d c3 e8 3f 84 83 fd <0f> 0b e8 38 84 83 fd 45 31 ed 5b 5d 4c 89 e8 41 5c 41 5d c3 e8 26
      RSP: 0018:ffffc90000b8f6e8 EFLAGS: 00010293
      RAX: 0000000000000000 RBX: 0000000000000003 RCX: ffffffff83c42164
      RDX: ffff888106851180 RSI: ffffffff83c42321 RDI: 0000000000000005
      RBP: 0000000000000000 R08: 0000000000000005 R09: 000000000000000a
      R10: 0000000000000003 R11: ffff8881055c2f00 R12: ffff888112b78000
      R13: 0000000000000000 R14: ffff8881055c2f00 R15: ffff8881055c2f00
      FS:  00007f377bd78800(0000) GS:ffff88811b000000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000496068 CR3: 000000011298b003 CR4: 0000000000770ef0
      PKRU: 55555554
      Call Trace:
       <TASK>
       __nf_register_net_hook+0xcd/0x7a0 net/netfilter/core.c:428
       nf_register_net_hook+0x116/0x170 net/netfilter/core.c:578
       nf_register_net_hooks+0x5d/0xc0 net/netfilter/core.c:594
       arpt_register_table+0x250/0x420 net/ipv4/netfilter/arp_tables.c:1553
       arptable_filter_table_init+0x41/0x60 net/ipv4/netfilter/arptable_filter.c:39
       xt_find_table_lock+0x2e9/0x4b0 net/netfilter/x_tables.c:1260
       xt_request_find_table_lock+0x2b/0xe0 net/netfilter/x_tables.c:1285
       get_info+0x169/0x5c0 net/ipv4/netfilter/arp_tables.c:808
       do_arpt_get_ctl+0x3f9/0x830 net/ipv4/netfilter/arp_tables.c:1444
       nf_getsockopt+0x76/0xd0 net/netfilter/nf_sockopt.c:116
       ip_getsockopt+0x17d/0x1c0 net/ipv4/ip_sockglue.c:1777
       tcp_getsockopt+0x99/0x100 net/ipv4/tcp.c:4373
       do_sock_getsockopt+0x279/0x360 net/socket.c:2373
       __sys_getsockopt+0x115/0x1e0 net/socket.c:2402
       __do_sys_getsockopt net/socket.c:2412 [inline]
       __se_sys_getsockopt net/socket.c:2409 [inline]
       __x64_sys_getsockopt+0xbd/0x150 net/socket.c:2409
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0x4f/0x110 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x46/0x4e
      RIP: 0033:0x7f377beca6fe
      Code: 1f 44 00 00 48 8b 15 01 97 0a 00 f7 d8 64 89 02 b8 ff ff ff ff eb b8 0f 1f 44 00 00 f3 0f 1e fa 49 89 ca b8 37 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 0a c3 66 0f 1f 84 00 00 00 00 00 48 8b 15 c9
      RSP: 002b:00000000005df728 EFLAGS: 00000246 ORIG_RAX: 0000000000000037
      RAX: ffffffffffffffda RBX: 00000000004966e0 RCX: 00007f377beca6fe
      RDX: 0000000000000060 RSI: 0000000000000000 RDI: 0000000000000003
      RBP: 000000000042938a R08: 00000000005df73c R09: 00000000005df800
      R10: 00000000004966e8 R11: 0000000000000246 R12: 0000000000000003
      R13: 0000000000496068 R14: 0000000000000003 R15: 00000000004bc9d8
       </TASK>
      
      Fixes: 4654467d ("netfilter: arptables: allow xtables-nft only builds")
      Reported-by: default avatarsyzkaller <syzkaller@googlegroups.com>
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      15fba562
    • Pablo Neira Ayuso's avatar
      netfilter: nf_tables: skip netdev hook unregistration if table is dormant · 216e7bf7
      Pablo Neira Ayuso authored
      Skip hook unregistration when adding or deleting devices from an
      existing netdev basechain. Otherwise, commit/abort path try to
      unregister hooks which not enabled.
      
      Fixes: b9703ed4 ("netfilter: nf_tables: support for adding new devices to an existing netdev chain")
      Fixes: 7d937b10 ("netfilter: nf_tables: support for deleting devices in an existing netdev chain")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      216e7bf7
    • Pablo Neira Ayuso's avatar
      netfilter: nf_tables: reject table flag and netdev basechain updates · 1e1fb6f0
      Pablo Neira Ayuso authored
      netdev basechain updates are stored in the transaction object hook list.
      When setting on the table dormant flag, it iterates over the existing
      hooks in the basechain. Thus, skipping the hooks that are being
      added/deleted in this transaction, which leaves hook registration in
      inconsistent state.
      
      Reject table flag updates in combination with netdev basechain updates
      in the same batch:
      
      - Update table flags and add/delete basechain: Check from basechain update
        path if there are pending flag updates for this table.
      - add/delete basechain and update table flags: Iterate over the transaction
        list to search for basechain updates from the table update path.
      
      In both cases, the batch is rejected. Based on suggestion from Florian Westphal.
      
      Fixes: b9703ed4 ("netfilter: nf_tables: support for adding new devices to an existing netdev chain")
      Fixes: 7d937b10 ("netfilter: nf_tables: support for deleting devices in an existing netdev chain")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      1e1fb6f0
    • Pablo Neira Ayuso's avatar
      netfilter: nf_tables: reject destroy command to remove basechain hooks · b32ca27f
      Pablo Neira Ayuso authored
      Report EOPNOTSUPP if NFT_MSG_DESTROYCHAIN is used to delete hooks in an
      existing netdev basechain, thus, only NFT_MSG_DELCHAIN is allowed.
      
      Fixes: 7d937b10 ("netfilter: nf_tables: support for deleting devices in an existing netdev chain")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      b32ca27f
  2. 27 Mar, 2024 15 commits
  3. 26 Mar, 2024 15 commits
  4. 25 Mar, 2024 4 commits
    • Pu Lehui's avatar
      riscv, bpf: Fix kfunc parameters incompatibility between bpf and riscv abi · 443574b0
      Pu Lehui authored
      We encountered a failing case when running selftest in no_alu32 mode:
      
      The failure case is `kfunc_call/kfunc_call_test4` and its source code is
      like bellow:
      ```
      long bpf_kfunc_call_test4(signed char a, short b, int c, long d) __ksym;
      int kfunc_call_test4(struct __sk_buff *skb)
      {
      	...
      	tmp = bpf_kfunc_call_test4(-3, -30, -200, -1000);
      	...
      }
      ```
      
      And its corresponding asm code is:
      ```
      0: r1 = -3
      1: r2 = -30
      2: r3 = 0xffffff38 # opcode: 18 03 00 00 38 ff ff ff 00 00 00 00 00 00 00 00
      4: r4 = -1000
      5: call bpf_kfunc_call_test4
      ```
      
      insn 2 is parsed to ld_imm64 insn to emit 0x00000000ffffff38 imm, and
      converted to int type and then send to bpf_kfunc_call_test4. But since
      it is zero-extended in the bpf calling convention, riscv jit will
      directly treat it as an unsigned 32-bit int value, and then fails with
      the message "actual 4294966063 != expected -1234".
      
      The reason is the incompatibility between bpf and riscv abi, that is,
      bpf will do zero-extension on uint, but riscv64 requires sign-extension
      on int or uint. We can solve this problem by sign extending the 32-bit
      parameters in kfunc.
      
      The issue is related to [0], and thanks to Yonghong and Alexei.
      
      Link: https://github.com/llvm/llvm-project/pull/84874 [0]
      Fixes: d40c3847 ("riscv, bpf: Add kfunc support for RV64")
      Signed-off-by: default avatarPu Lehui <pulehui@huawei.com>
      Tested-by: default avatarPuranjay Mohan <puranjay12@gmail.com>
      Reviewed-by: default avatarPuranjay Mohan <puranjay12@gmail.com>
      Link: https://lore.kernel.org/r/20240324103306.2202954-1-pulehui@huaweicloud.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      443574b0
    • Kurt Kanzenbach's avatar
      igc: Remove stale comment about Tx timestamping · 47ce2956
      Kurt Kanzenbach authored
      The initial igc Tx timestamping implementation used only one register for
      retrieving Tx timestamps. Commit 3ed247e7 ("igc: Add support for
      multiple in-flight TX timestamps") added support for utilizing all four of
      them e.g., for multiple domain support. Remove the stale comment/FIXME.
      
      Fixes: 3ed247e7 ("igc: Add support for multiple in-flight TX timestamps")
      Signed-off-by: Kurt Kanzenbach's avatarKurt Kanzenbach <kurt@linutronix.de>
      Acked-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
      Reviewed-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
      Tested-by: default avatarNaama Meir <naamax.meir@linux.intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      47ce2956
    • Przemek Kitszel's avatar
      ixgbe: avoid sleeping allocation in ixgbe_ipsec_vf_add_sa() · aec806fb
      Przemek Kitszel authored
      Change kzalloc() flags used in ixgbe_ipsec_vf_add_sa() to GFP_ATOMIC, to
      avoid sleeping in IRQ context.
      
      Dan Carpenter, with the help of Smatch, has found following issue:
      The patch eda0333a: "ixgbe: add VF IPsec management" from Aug 13,
      2018 (linux-next), leads to the following Smatch static checker
      warning: drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c:917 ixgbe_ipsec_vf_add_sa()
      	warn: sleeping in IRQ context
      
      The call tree that Smatch is worried about is:
      ixgbe_msix_other() <- IRQ handler
      -> ixgbe_msg_task()
         -> ixgbe_rcv_msg_from_vf()
            -> ixgbe_ipsec_vf_add_sa()
      
      Fixes: eda0333a ("ixgbe: add VF IPsec management")
      Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Link: https://lore.kernel.org/intel-wired-lan/db31a0b0-4d9f-4e6b-aed8-88266eb5665c@moroto.mountainReviewed-by: default avatarMichal Kubiak <michal.kubiak@intel.com>
      Signed-off-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
      Reviewed-by: default avatarShannon Nelson <shannon.nelson@amd.com>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      aec806fb
    • Jesse Brandeburg's avatar
      ice: fix memory corruption bug with suspend and rebuild · 1cb7fdb1
      Jesse Brandeburg authored
      The ice driver would previously panic after suspend. This is caused
      from the driver *only* calling the ice_vsi_free_q_vectors() function by
      itself, when it is suspending. Since commit b3e7b3a6 ("ice: prevent
      NULL pointer deref during reload") the driver has zeroed out
      num_q_vectors, and only restored it in ice_vsi_cfg_def().
      
      This further causes the ice_rebuild() function to allocate a zero length
      buffer, after which num_q_vectors is updated, and then the new value of
      num_q_vectors is used to index into the zero length buffer, which
      corrupts memory.
      
      The fix entails making sure all the code referencing num_q_vectors only
      does so after it has been reset via ice_vsi_cfg_def().
      
      I didn't perform a full bisect, but I was able to test against 6.1.77
      kernel and that ice driver works fine for suspend/resume with no panic,
      so sometime since then, this problem was introduced.
      
      Also clean up an un-needed init of a local variable in the function
      being modified.
      
      PANIC from 6.8.0-rc1:
      
      [1026674.915596] PM: suspend exit
      [1026675.664697] ice 0000:17:00.1: PTP reset successful
      [1026675.664707] ice 0000:17:00.1: 2755 msecs passed between update to cached PHC time
      [1026675.667660] ice 0000:b1:00.0: PTP reset successful
      [1026675.675944] ice 0000:b1:00.0: 2832 msecs passed between update to cached PHC time
      [1026677.137733] ixgbe 0000:31:00.0 ens787: NIC Link is Up 1 Gbps, Flow Control: None
      [1026677.190201] BUG: kernel NULL pointer dereference, address: 0000000000000010
      [1026677.192753] ice 0000:17:00.0: PTP reset successful
      [1026677.192764] ice 0000:17:00.0: 4548 msecs passed between update to cached PHC time
      [1026677.197928] #PF: supervisor read access in kernel mode
      [1026677.197933] #PF: error_code(0x0000) - not-present page
      [1026677.197937] PGD 1557a7067 P4D 0
      [1026677.212133] ice 0000:b1:00.1: PTP reset successful
      [1026677.212143] ice 0000:b1:00.1: 4344 msecs passed between update to cached PHC time
      [1026677.212575]
      [1026677.243142] Oops: 0000 [#1] PREEMPT SMP NOPTI
      [1026677.247918] CPU: 23 PID: 42790 Comm: kworker/23:0 Kdump: loaded Tainted: G        W          6.8.0-rc1+ #1
      [1026677.257989] Hardware name: Intel Corporation M50CYP2SBSTD/M50CYP2SBSTD, BIOS SE5C620.86B.01.01.0005.2202160810 02/16/2022
      [1026677.269367] Workqueue: ice ice_service_task [ice]
      [1026677.274592] RIP: 0010:ice_vsi_rebuild_set_coalesce+0x130/0x1e0 [ice]
      [1026677.281421] Code: 0f 84 3a ff ff ff 41 0f b7 74 ec 02 66 89 b0 22 02 00 00 81 e6 ff 1f 00 00 e8 ec fd ff ff e9 35 ff ff ff 48 8b 43 30 49 63 ed <41> 0f b7 34 24 41 83 c5 01 48 8b 3c e8 66 89 b7 aa 02 00 00 81 e6
      [1026677.300877] RSP: 0018:ff3be62a6399bcc0 EFLAGS: 00010202
      [1026677.306556] RAX: ff28691e28980828 RBX: ff28691e41099828 RCX: 0000000000188000
      [1026677.314148] RDX: 0000000000000000 RSI: 0000000000000010 RDI: ff28691e41099828
      [1026677.321730] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
      [1026677.329311] R10: 0000000000000007 R11: ffffffffffffffc0 R12: 0000000000000010
      [1026677.336896] R13: 0000000000000000 R14: 0000000000000000 R15: ff28691e0eaa81a0
      [1026677.344472] FS:  0000000000000000(0000) GS:ff28693cbffc0000(0000) knlGS:0000000000000000
      [1026677.353000] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [1026677.359195] CR2: 0000000000000010 CR3: 0000000128df4001 CR4: 0000000000771ef0
      [1026677.366779] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [1026677.374369] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [1026677.381952] PKRU: 55555554
      [1026677.385116] Call Trace:
      [1026677.388023]  <TASK>
      [1026677.390589]  ? __die+0x20/0x70
      [1026677.394105]  ? page_fault_oops+0x82/0x160
      [1026677.398576]  ? do_user_addr_fault+0x65/0x6a0
      [1026677.403307]  ? exc_page_fault+0x6a/0x150
      [1026677.407694]  ? asm_exc_page_fault+0x22/0x30
      [1026677.412349]  ? ice_vsi_rebuild_set_coalesce+0x130/0x1e0 [ice]
      [1026677.418614]  ice_vsi_rebuild+0x34b/0x3c0 [ice]
      [1026677.423583]  ice_vsi_rebuild_by_type+0x76/0x180 [ice]
      [1026677.429147]  ice_rebuild+0x18b/0x520 [ice]
      [1026677.433746]  ? delay_tsc+0x8f/0xc0
      [1026677.437630]  ice_do_reset+0xa3/0x190 [ice]
      [1026677.442231]  ice_service_task+0x26/0x440 [ice]
      [1026677.447180]  process_one_work+0x174/0x340
      [1026677.451669]  worker_thread+0x27e/0x390
      [1026677.455890]  ? __pfx_worker_thread+0x10/0x10
      [1026677.460627]  kthread+0xee/0x120
      [1026677.464235]  ? __pfx_kthread+0x10/0x10
      [1026677.468445]  ret_from_fork+0x2d/0x50
      [1026677.472476]  ? __pfx_kthread+0x10/0x10
      [1026677.476671]  ret_from_fork_asm+0x1b/0x30
      [1026677.481050]  </TASK>
      
      Fixes: b3e7b3a6 ("ice: prevent NULL pointer deref during reload")
      Reported-by: default avatarRobert Elliott <elliott@hpe.com>
      Signed-off-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Reviewed-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      1cb7fdb1