)]}'
{
  "commit": "5aa79ea169d0d1a67a8163db34df13385ce01cd4",
  "tree": "506e07b39914b18d14965d0e1968359fe8f3d63f",
  "parents": [
    "911e929f07d35d4ec1727256c6b8b5ddeaf74a86",
    "21a41535cf1730fb2dceed58d6fbd53f6d297f8a"
  ],
  "author": {
    "name": "Willem de Bruijn",
    "email": "willemb@google.com",
    "time": "Mon Nov 30 10:16:25 2026 -0500"
  },
  "committer": {
    "name": "Willem de Bruijn",
    "email": "willemb@google.com",
    "time": "Mon Nov 30 10:16:27 2026 -0500"
  },
  "message": "Merge branch \u0027net-mlx5e-fix-null-pointer-dereference-in-arfs_create_groups\u0027\n\nJin Qi says:\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\nnet/mlx5e: fix NULL pointer dereference in arfs_create_groups()\n\nThe following patch fixes a NULL pointer dereference in the mlx5e aRFS\ncode, which oopses the kernel during NIC bring-up.\n\nThe bug was introduced by commit 3c6d5189246f (\"net/mlx5e: fix a\ndouble-free in arfs_create_groups\", in v6.8) and is still present in\nv7.4-rc2.\n\n1. What happens\n\narfs_create_groups() creates up to two flow groups in ft-\u003eg[], and\nincrements ft-\u003enum_groups for each group that was created successfully.\nIf creating the second group fails, the error path frees ft-\u003eg and sets\nit to NULL, but leaves ft-\u003enum_groups at 1.\n\nThe only caller, arfs_create_table(), calls mlx5e_destroy_flow_table() on\nthe error path, which calls mlx5e_destroy_groups():\n\n\tfor (i \u003d ft-\u003enum_groups - 1; i \u003e\u003d 0; i--) {\n\t\tif (!IS_ERR_OR_NULL(ft-\u003eg[i]))\n\t\t\tmlx5_destroy_flow_group(ft-\u003eg[i]);\n\t\tft-\u003eg[i] \u003d NULL;\n\t}\n\nft-\u003eg is NULL at this point, so ft-\u003eg[0] is a NULL pointer dereference.\nNote that only a failure of the *second* group triggers this; if the\nfirst group fails, num_groups is still 0 and the loop body never runs.\n\nThe same error path also leaks the flow group that was created\nsuccessfully before the failure, since ft-\u003eg is freed without the group\nbeing destroyed.\n\n2. How this was introduced\n\nCommit 3c6d5189246f fixed a double free of ft-\u003eg between\narfs_create_groups() and its caller. Before that commit, the group\nfailure path did not touch ft-\u003eg at all:\n\n\terr:\n\t\terr \u003d PTR_ERR(ft-\u003eg[ft-\u003enum_groups]);\n\t\tft-\u003eg[ft-\u003enum_groups] \u003d NULL;\n\tout:\n\t\tkvfree(in);\n\t\treturn err;\n\nso the caller destroyed the flow groups that had been created and then\nfreed the array. That commit fixed the double free in the allocation\nfailure path by freeing ft-\u003eg here as well, and in doing so changed the\ngroup failure path too:\n\n\terr_clean_group:\n\t\terr \u003d PTR_ERR(ft-\u003eg[ft-\u003enum_groups]);\n\t\tft-\u003eg[ft-\u003enum_groups] \u003d NULL;\n\terr_free_in:\n\t\tkvfree(in);\n\terr_free_g:\n\t\tkfree(ft-\u003eg);\n\t\tft-\u003eg \u003d NULL;\n\t\treturn err;\n\nThe reset of ft-\u003enum_groups that would have prevented this was\nsuggested during review, but deferred (\"it is a better idea to leave it\nto a refector patch one day\"), and that patch never landed.\n\n3. The oops\n\nUnable to handle kernel NULL pointer dereference at virtual address 0000000000000000\nOops [#1]\nepc : mlx5e_destroy_groups+0x38/0x6c\n ra : mlx5e_destroy_flow_table+0x10/0x30\nstatus: 0000000200000120 badaddr: 0000000000000000 cause: 000000000000000d\n[\u003cffffffff80843604\u003e] mlx5e_arfs_create_tables+0x44c/0x5d8\n[\u003cffffffff80815bd6\u003e] mlx5e_create_flow_steering+0x42/0x6bc\n[\u003cffffffff808043e4\u003e] mlx5e_init_nic_rx+0x84/0x14c\n[\u003cffffffff80808a4c\u003e] mlx5e_attach_netdev+0xb8/0x2e8\n[\u003cffffffff8080f36e\u003e] mlx5e_probe+0x48e/0x81c\nCode: 89b3 40f9 e052 098e 7a7d a011 84be 3783 0109 97a6 (6398) 853a\nKernel panic - not syncing: Attempted to kill init! exitcode\u003d0x0000000b\n\nThe register dump shows a5 \u003d 0, i.e. ft-\u003eg was read as NULL. Offset 16\nof struct mlx5e_flow_table is ft-\u003eg, and the faulting instruction loads\nfrom the address in a5, so the faulting access is the ft-\u003eg[0] read.\n\nNote that the bug itself is not architecture specific. It is a plain\nerror path in C, and it is reachable on any architecture; the register\ndump above is only from the machine on which it was hit.\n\n4. How this was hit\n\nThis was found while testing a virtual mlx5 device whose firmware\nanswers host mailbox commands. The device took longer than the\nfirmware\u0027s own timeout to answer one CREATE_FLOW_GROUP command, so the\nfirmware reported the command as failed even though the device had\ncompleted it. The host then took its error path, and the bug above\nturned a command failure into a kernel panic.\n\nThat is only the trigger though, not the cause: the host oopses on any\nerror returned by CREATE_FLOW_GROUP, no matter where the error comes\nfrom (a device that rejects the command, a resource shortage, a command\ntimeout, ...). A firmware that returns an error for the second\nCREATE_FLOW_GROUP is enough to reproduce it.\n\nA minimal reproduction is therefore: enable aRFS, and make the second\nCREATE_FLOW_GROUP of one of the aRFS flow tables fail. The kernel\nthen calls mlx5e_destroy_flow_table() with ft-\u003enum_groups \u003d\u003d 1 and\nft-\u003eg \u003d\u003d NULL, and dereferences the NULL array.\n\n5. The fix\n\nThe patch leaves the free of ft-\u003eg to the caller:\nmlx5e_destroy_flow_table() frees ft-\u003eg exactly once, and also destroys\nthe flow groups that were created. This fixes the NULL pointer\ndereference and the leak, while keeping the double free fixed.\n\nFor the three error paths of arfs_create_groups():\n\n  ft-\u003eg     num_groups  what the caller does\n  --------  ----------  ----------------------------------------\n  NULL      0           kfree(NULL), no group to destroy\n  non-NULL  0           kfree(ft-\u003eg), no group to destroy\n  non-NULL  1           destroy the created group, then kfree(ft-\u003eg)\n\nft-\u003eg is therefore freed exactly once in all three cases, so the double\nfree that 3c6d5189246f fixed stays fixed.\n\n6. Scope\n\nThe patch was reviewed against v7.4-rc2 and applies cleanly. The crash\nitself was reproduced on a virtual mlx5 device; the patched kernel was\nnot booted, so this patch is not marked as tested.\n\nv1: https://lore.kernel.org/netdev/20261114144325.816-1-jinvas@126.com/\n\n\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\nLink: https://patch.msgid.link/20261124091455.1714-1-jinvas@126.com\nSigned-off-by: Willem de Bruijn \u003cwillemb@google.com\u003e\n",
  "tree_diff": []
}
