)]}'
{
  "commit": "7903980261cb4e87fdbb8b523a06d98fc0571783",
  "tree": "c3ee182379f064f2965597d1e41b79cecbd30759",
  "parents": [
    "98a283a1f3d66342eea6d766a836eaf23694e0a0"
  ],
  "author": {
    "name": "Alexandre Cassen",
    "email": "acassen@corp.free.fr",
    "time": "Mon Nov 23 23:13:08 2026 +0100"
  },
  "committer": {
    "name": "Paolo Abeni",
    "email": "pabeni@redhat.com",
    "time": "Tue Dec 01 12:58:00 2026 +0100"
  },
  "message": "net/mlx5: HWS, fix action STE double free on rule update\n\nAn HWS rule keeps the chunk of its action STEs in rule-\u003eaction_ste. An\nupdate saves it in rule-\u003eold_action_ste and frees it once the new match\nSTE is written. When the new actions need no action STEs, the rule still\npoints to that chunk. Its next update or its deletion free it again.\n\nTwo rules can then end up with the same action STEs. A packet of one can\nget the header rewrite or the meter of the other. The second free can\nalso dereference an action STE table that the cleanup work has freed.\nNeither was observed.\n\nThe buddy allocator counts the same segment as free twice. After a few\nupdates of several rules, it finds no segment where it counts one:\n\n  ICM Buddy: failed finding free mem for order 0\n  WARNING: drivers/net/ethernet/mellanox/mlx5/core/steering/hws/buddy.c:93 at mlx5hws_buddy_alloc_mem+0x11a/0x140 [mlx5_core], CPU#34: tc/449154\n  Call Trace:\n   \u003cTASK\u003e\n   hws_pool_buddy_db_get_chunk+0x25/0x50 [mlx5_core]\n   mlx5hws_pool_chunk_alloc+0x30/0x80 [mlx5_core]\n   mlx5hws_action_ste_chunk_alloc+0x85/0x480 [mlx5_core]\n   hws_rule_create_hws+0x860/0x9c0 [mlx5_core]\n   mlx5hws_rule_action_update+0x81/0x140 [mlx5_core]\n   mlx5hws_bwc_rule_action_update+0x10d/0x200 [mlx5_core]\n   mlx5_cmd_hws_update_fte+0xb0/0x140 [mlx5_core]\n   del_hw_fte+0x1b2/0x390 [mlx5_core]\n   mlx5_del_flow_rules+0x10f/0x270 [mlx5_core]\n   __mlx5_eswitch_del_rule+0x5c/0x1b0 [mlx5_core]\n   mlx5_eswitch_del_offloaded_rule+0x10/0x20 [mlx5_core]\n   mlx5e_tc_rule_unoffload+0x4b/0x100 [mlx5_core]\n   mlx5e_tc_unoffload_fdb_rules+0x35/0x80 [mlx5_core]\n   mlx5e_tc_del_fdb_flow+0x2ca/0x310 [mlx5_core]\n   mlx5e_tc_del_flow+0x63/0x610 [mlx5_core]\n   mlx5e_flow_put+0x3a/0x80 [mlx5_core]\n   mlx5e_delete_flower+0x29b/0x460 [mlx5_core]\n   mlx5e_setup_tc_cls_flower+0x7d/0x90 [mlx5_core]\n   mlx5e_setup_tc_block_cb+0x58/0x90 [mlx5_core]\n   tc_setup_cb_destroy+0xcc/0x1b0\n   fl_hw_destroy_filter+0xa1/0xe0 [cls_flower]\n   fl_change+0x1bf1/0x20a9 [cls_flower]\n   tc_new_tfilter+0x432/0xea0\n   rtnetlink_rcv_msg+0x384/0x460\n   netlink_rcv_skb+0x61/0x120\n   rtnetlink_rcv+0x15/0x30\n   netlink_unicast+0x2a1/0x3d0\n   netlink_sendmsg+0x237/0x490\n   ____sys_sendmsg+0x32d/0x350\n   ___sys_sendmsg+0xaf/0x110\n   __sys_sendmsg+0x93/0x100\n   __x64_sys_sendmsg+0x1d/0x30\n   x64_sys_call+0x821/0x23d0\n   do_syscall_64+0xbd/0x570\n   \u003c/TASK\u003e\n\nThe pool then holds more free elements than its size at close:\n\n  mlx5_core 0000:31:00.0: mlx5hws_pool_destroy:386:(pid 448599): Attempting to destroy non-empty pool\n\nForget the chunk in rule-\u003eaction_ste once it is saved, as the update\nflow did with the action STE index before the commit below.\n\nTriggered during an endurance test of a 5G UPF code, on flower rules\nthat lose their police action in place. The reproduction below gives\nthe trace above on a ConnectX-7 with firmware 28.48.1000. It only\nuses tc and devlink, with no kernel change. DEV is the uplink\nrepresentor and PCI its devlink handle:\n\n  r() { for i in $(seq 128); do echo \"filter $1 dev $DEV ingress prio 1 handle $i protocol ip flower skip_sw dst_ip 10.0.0.$i $2\"; done | tc -b -; }\n  BIG\u003d\"action pedit ex munge ip ttl set 63 pipe action csum ip pipe action police rate 1mbit burst 32k conform-exceed drop/pipe action drop\"\n  devlink dev param set $PCI name flow_steering_mode value hmfs cmode runtime\n  devlink dev eswitch set $PCI mode switchdev\n  tc qdisc add dev $DEV ingress\n  r add \"$BIG\"\n  for n in 1 2 3; do r replace \"action drop\"; r replace \"$BIG\"; done\n  tc filter del dev $DEV ingress prio 1\n  devlink dev eswitch set $PCI mode legacy\n\nWith this fix, the reproduction runs clean on the same ConnectX-7.\nIt was not tested against kernel selftests.\n\nNot addressed here and not triggered: after a successful update,\nhws_rule_destroy_failed_hws() can free rule-\u003eold_action_ste again. A\nfailed update can leak it now also when it needs no action STEs.\n\nFixes: 3fc44ca44d7c (\"net/mlx5: HWS, update flow - support through bigger action RTC\")\nSigned-off-by: Alexandre Cassen \u003cacassen@corp.free.fr\u003e\nReviewed-by: Yevgeny Kliteynik \u003ckliteyn@nvidia.com\u003e\nLink: https://patch.msgid.link/20261123221310.4045513-1-acassen@corp.free.fr\nSigned-off-by: Paolo Abeni \u003cpabeni@redhat.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "0d4cb2b2393b9a30cd4702128a07ea27eb81cdc9",
      "old_mode": 33188,
      "old_path": "drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.c",
      "new_id": "cc94d3149d76afae5c0726c0ee6ae15def22e811",
      "new_mode": 33188,
      "new_path": "drivers/net/ethernet/mellanox/mlx5/core/steering/hws/rule.c"
    }
  ]
}
