{
   "containers": {
      "cna": {
         "providerMetadata": {
            "orgId": "f4215fc3-5b6b-47ff-a258-f7189bd81038"
         },
         "descriptions": [
            {
               "lang": "en",
               "value": "nfc: llcp_core: Hold a ref to llcp_local->dev when holding a ref to llcp_local\n\nllcp_sock_sendmsg() calls nfc_llcp_send_ui_frame() which in turn calls\nnfc_alloc_send_skb(), which accesses the nfc_dev from the llcp_sock for\ngetting the headroom and tailroom needed for skb allocation.\n\nParallelly the nfc_dev can be freed, as the refcount is decreased via\nnfc_free_device(), leading to a UAF reported by Syzkaller, which can\nbe summarized as follows:\n\n(1) llcp_sock_sendmsg() -> nfc_llcp_send_ui_frame()\n\t-> nfc_alloc_send_skb() -> Dereference *nfc_dev\n(2) virtual_ncidev_close() -> nci_free_device() -> nfc_free_device()\n\t-> put_device() -> nfc_release() -> Free *nfc_dev\n\nWhen a reference to llcp_local is acquired, we do not acquire the same\nfor the nfc_dev. This leads to freeing even when the llcp_local is in\nuse, and this is the case with the UAF described above too.\n\nThus, when we acquire a reference to llcp_local, we should acquire a\nreference to nfc_dev, and release the references appropriately later.\n\nReferences for llcp_local is initialized in nfc_llcp_register_device()\n(which is called by nfc_register_device()). Thus, we should acquire a\nreference to nfc_dev there.\n\nnfc_unregister_device() calls nfc_llcp_unregister_device() which in\nturn calls nfc_llcp_local_put(). Thus, the reference to nfc_dev is\nappropriately released later."
            }
         ],
         "affected": [
            {
               "product": "Linux",
               "vendor": "Linux",
               "defaultStatus": "unaffected",
               "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
               "versions": [
                  {
                     "version": "c7aa12252f51",
                     "lessThan": "83724831dab1",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "c7aa12252f51",
                     "lessThan": "df02150025a3",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "c7aa12252f51",
                     "lessThan": "65c6ef02ff26",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "c7aa12252f51",
                     "lessThan": "6adeb15cb6ad",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "c7aa12252f51",
                     "lessThan": "802af3c88ad1",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "c7aa12252f51",
                     "lessThan": "a4b0a9b80a96",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "c7aa12252f51",
                     "lessThan": "fb195df90544",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "c7aa12252f51",
                     "lessThan": "c95f919567d6",
                     "status": "affected",
                     "versionType": "git"
                  }
               ]
            },
            {
               "product": "Linux",
               "vendor": "Linux",
               "defaultStatus": "affected",
               "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
               "versions": [
                  {
                     "version": "3.6",
                     "status": "affected"
                  },
                  {
                     "version": "0",
                     "lessThan": "3.6",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "4.14.336",
                     "lessThanOrEqual": "4.14.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "4.19.305",
                     "lessThanOrEqual": "4.19.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "5.4.267",
                     "lessThanOrEqual": "5.4.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "5.10.208",
                     "lessThanOrEqual": "5.10.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "5.15.147",
                     "lessThanOrEqual": "5.15.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "6.1.72",
                     "lessThanOrEqual": "6.1.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "6.6.11",
                     "lessThanOrEqual": "6.6.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "6.7",
                     "lessThanOrEqual": "*",
                     "status": "unaffected",
                     "versionType": "original_commit_for_fix"
                  }
               ]
            }
         ],
         "references": [
            {
               "url": "https://git.kernel.org/stable/c/83724831dab1"
            },
            {
               "url": "https://git.kernel.org/stable/c/df02150025a3"
            },
            {
               "url": "https://git.kernel.org/stable/c/65c6ef02ff26"
            },
            {
               "url": "https://git.kernel.org/stable/c/6adeb15cb6ad"
            },
            {
               "url": "https://git.kernel.org/stable/c/802af3c88ad1"
            },
            {
               "url": "https://git.kernel.org/stable/c/a4b0a9b80a96"
            },
            {
               "url": "https://git.kernel.org/stable/c/fb195df90544"
            },
            {
               "url": "https://git.kernel.org/stable/c/c95f919567d6"
            }
         ],
         "title": "nfc: llcp_core: Hold a ref to llcp_local->dev when holding a ref to llcp_local",
         "x_generator": {
            "engine": "bippy-c4875b56942e"
         }
      }
   },
   "cveMetadata": {
      "assignerOrgId": "f4215fc3-5b6b-47ff-a258-f7189bd81038",
      "cveID": "CVE-2023-1851",
      "requesterUserId": "gregkh@linuxfoundation.org",
      "serial": "1",
      "state": "PUBLISHED"
   },
   "dataType": "CVE_RECORD",
   "dataVersion": "5.0"
}
