{"id":"CVE-2021-47391","published":"2024-05-21T15:03:49Z","modified":"2026-08-05T08:47:36Z","title":"RDMA/cma: Ensure rdma_addr_cancel() happens before issuing more requests","vendor":"Linux","product":"Linux","tier":"tail","description":{"text":"In the Linux kernel, the following vulnerability has been resolved:\n\nRDMA/cma: Ensure rdma_addr_cancel() happens before issuing more requests\n\nThe FSM can run in a circle allowing rdma_resolve_ip() to be called twice\non the same id_priv. While this cannot happen without going through the\nwork, it violates the invariant that the same address resolution\nbackground request cannot be active twice.\n\n       CPU 1                                  CPU 2\n\nrdma_resolve_addr():\n  RDMA_CM_IDLE -> RDMA_CM_ADDR_QUERY\n  rdma_resolve_ip(addr_handler)  #1\n\n\t\t\t process_one_req(): for #1\n                          addr_handler():\n                            RDMA_CM_ADDR_QUERY -> RDMA_CM_ADDR_BOUND\n                            mutex_unlock(&id_priv->handler_mutex);\n                            [.. handler still running ..]\n\nrdma_resolve_addr():\n  RDMA_CM_ADDR_BOUND -> RDMA_CM_ADDR_QUERY\n  rdma_resolve_ip(addr_handler)\n    !! two requests are now on the req_list\n\nrdma_destroy_id():\n destroy_id_handler_unlock():\n  _destroy_id():\n   cma_cancel_operation():\n    rdma_addr_cancel()\n\n                          // process_one_req() self removes it\n\t\t          spin_lock_bh(&lock);\n                           cancel_delayed_work(&req->work);\n\t                   if (!list_empty(&req->list)) == true\n\n      ! rdma_addr_cancel() returns after process_on_req #1 is done\n\n   kfree(id_priv)\n\n\t\t\t process_one_req(): for #2\n                          addr_handler():\n\t                    mutex_lock(&id_priv->handler_mutex);\n                            !! Use after free on id_priv\n\nrdma_addr_cancel() expects there to be one req on the list and only\ncancels the first one. The self-removal behavior of the work only happens\nafter the handler has returned. This yields a situations where the\nreq_list can have two reqs for the same \"handle\" but rdma_addr_cancel()\nonly cancels the first one.\n\nThe second req remains active beyond rdma_destroy_id() and will\nuse-after-free id_priv once it inevitably triggers.\n\nFix this by remembering if the id_priv has called rdma_resolve_ip() and\nalways cancel before calling it again. This ensures the req_list never\ngets more than one item in it and doesn't cost anything in the normal flow\nthat never uses this strange error path.","provenance":"source","from":"CVE.org"},"cvss":{"score":7.8,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00317,"percentile":0.17044,"provenance":"source"},"cwes":[],"references":[{"url":"https://git.kernel.org/stable/c/9a085fa9b7d644a234465091e038c1911e1a4f2a","tags":[]},{"url":"https://git.kernel.org/stable/c/03d884671572af8bcfbc9e63944c1021efce7589","tags":[]},{"url":"https://git.kernel.org/stable/c/305d568b72f17f674155a2a8275f865f207b3808","tags":[]}],"priority":{"score":8.9,"factors":[{"name":"EPSS percentile","points":3.41},{"name":"CVSS severity","points":5.46}]},"vendorSlug":"linux","affectedVersions":[{"vendor":"Linux","product":"Linux","versions":[">= e51060f08a61965c4dd91516d82fe90617152590, < 9a085fa9b7d644a234465091e038c1911e1a4f2a",">= e51060f08a61965c4dd91516d82fe90617152590, < 03d884671572af8bcfbc9e63944c1021efce7589",">= e51060f08a61965c4dd91516d82fe90617152590, < 305d568b72f17f674155a2a8275f865f207b3808"]},{"vendor":"Linux","product":"Linux","versions":["2.6.18"]}],"ssvc":{"exploitation":"none","automatable":"no","technicalImpact":"partial","timestamp":"2024-05-21T17:33:43.729564Z","from":"CISA ADP","provenance":"source"},"euvd":{"id":"EUVD-2021-34396","exploited":false,"provenance":"source"}}