{
   "containers": {
      "cna": {
         "providerMetadata": {
            "orgId": "f4215fc3-5b6b-47ff-a258-f7189bd81038"
         },
         "descriptions": [
            {
               "lang": "en",
               "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nusb: f_fs: Fix use-after-free for epfile\n\nConsider a case where ffs_func_eps_disable is called from\nffs_func_disable as part of composition switch and at the\nsame time ffs_epfile_release get called from userspace.\nffs_epfile_release will free up the read buffer and call\nffs_data_closed which in turn destroys ffs->epfiles and\nmark it as NULL. While this was happening the driver has\nalready initialized the local epfile in ffs_func_eps_disable\nwhich is now freed and waiting to acquire the spinlock. Once\nspinlock is acquired the driver proceeds with the stale value\nof epfile and tries to free the already freed read buffer\ncausing use-after-free.\n\nFollowing is the illustration of the race:\n\n      CPU1                                  CPU2\n\n   ffs_func_eps_disable\n   epfiles (local copy)\n\t\t\t\t\tffs_epfile_release\n\t\t\t\t\tffs_data_closed\n\t\t\t\t\tif (last file closed)\n\t\t\t\t\tffs_data_reset\n\t\t\t\t\tffs_data_clear\n\t\t\t\t\tffs_epfiles_destroy\nspin_lock\ndereference epfiles\n\nFix this races by taking epfiles local copy & assigning it under\nspinlock and if epfiles(local) is null then update it in ffs->epfiles\nthen finally destroy it.\nExtending the scope further from the race, protecting the ep related\nstructures, and concurrent accesses."
            }
         ],
         "affected": [
            {
               "product": "Linux",
               "vendor": "Linux",
               "defaultStatus": "unaffected",
               "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
               "programFiles": [
                  "drivers/usb/gadget/function/f_fs.c"
               ],
               "versions": [
                  {
                     "version": "a9e6f83c2df1",
                     "lessThan": "32048f4be071",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "a9e6f83c2df1",
                     "lessThan": "cfe5f6fd335d",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "a9e6f83c2df1",
                     "lessThan": "c9fc422c9a43",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "a9e6f83c2df1",
                     "lessThan": "0042178a69eb",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "a9e6f83c2df1",
                     "lessThan": "72a8aee863af",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "a9e6f83c2df1",
                     "lessThan": "3e078b187536",
                     "status": "affected",
                     "versionType": "git"
                  },
                  {
                     "version": "a9e6f83c2df1",
                     "lessThan": "ebe2b1add105",
                     "status": "affected",
                     "versionType": "git"
                  }
               ]
            },
            {
               "product": "Linux",
               "vendor": "Linux",
               "defaultStatus": "affected",
               "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
               "programFiles": [
                  "drivers/usb/gadget/function/f_fs.c"
               ],
               "versions": [
                  {
                     "version": "4.9",
                     "status": "affected"
                  },
                  {
                     "version": "0",
                     "lessThan": "4.9",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "4.14.267",
                     "lessThanOrEqual": "4.14.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "4.19.230",
                     "lessThanOrEqual": "4.19.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "5.4.180",
                     "lessThanOrEqual": "5.4.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "5.10.101",
                     "lessThanOrEqual": "5.10.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "5.15.24",
                     "lessThanOrEqual": "5.15.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "5.16.10",
                     "lessThanOrEqual": "5.16.*",
                     "status": "unaffected",
                     "versionType": "custom"
                  },
                  {
                     "version": "5.17",
                     "lessThanOrEqual": "*",
                     "status": "unaffected",
                     "versionType": "original_commit_for_fix"
                  }
               ]
            }
         ],
         "references": [
            {
               "url": "https://git.kernel.org/stable/c/32048f4be071f9a6966744243f1786f45bb22dc2"
            },
            {
               "url": "https://git.kernel.org/stable/c/cfe5f6fd335d882bcc829a1c8a7d462a455c626e"
            },
            {
               "url": "https://git.kernel.org/stable/c/c9fc422c9a43e3d58d246334a71f3390401781dc"
            },
            {
               "url": "https://git.kernel.org/stable/c/0042178a69eb77a979e36a50dcce9794a3140ef8"
            },
            {
               "url": "https://git.kernel.org/stable/c/72a8aee863af099d4434314c4536d6c9a61dcf3c"
            },
            {
               "url": "https://git.kernel.org/stable/c/3e078b18753669615301d946297bafd69294ad2c"
            },
            {
               "url": "https://git.kernel.org/stable/c/ebe2b1add1055b903e2acd86b290a85297edc0b3"
            }
         ],
         "title": "usb: f_fs: Fix use-after-free for epfile",
         "x_generator": {
            "engine": "bippy-c9c4e1df01b2"
         }
      }
   },
   "cveMetadata": {
      "assignerOrgId": "f4215fc3-5b6b-47ff-a258-f7189bd81038",
      "cveID": "CVE-2022-48822",
      "requesterUserId": "gregkh@kernel.org",
      "serial": "1",
      "state": "PUBLISHED"
   },
   "dataType": "CVE_RECORD",
   "dataVersion": "5.0"
}
