cve-2022-49789
Vulnerability from cvelistv5
Published
2025-05-01 14:09
Modified
2025-05-04 08:45
Severity ?
Summary
scsi: zfcp: Fix double free of FSF request when qdio send fails
Impacted products
LinuxLinux
LinuxLinux
Show details on NVD website


{
  "containers": {
    "cna": {
      "affected": [
        {
          "defaultStatus": "unaffected",
          "product": "Linux",
          "programFiles": [
            "drivers/s390/scsi/zfcp_fsf.c"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "lessThan": "1bf8ed585501bb2dd0b5f67c824eab45adfbdccd",
              "status": "affected",
              "version": "e60a6d69f1f84c2ef1cc63aefaadfe7ae9f12934",
              "versionType": "git"
            },
            {
              "lessThan": "d2c7d8f58e9cde8ac8d1f75e9d66c2a813ffe0ab",
              "status": "affected",
              "version": "e60a6d69f1f84c2ef1cc63aefaadfe7ae9f12934",
              "versionType": "git"
            },
            {
              "lessThan": "11edbdee4399401f533adda9bffe94567aa08b96",
              "status": "affected",
              "version": "e60a6d69f1f84c2ef1cc63aefaadfe7ae9f12934",
              "versionType": "git"
            },
            {
              "lessThan": "90a49a6b015fa439cd62e45121390284c125a91f",
              "status": "affected",
              "version": "e60a6d69f1f84c2ef1cc63aefaadfe7ae9f12934",
              "versionType": "git"
            },
            {
              "lessThan": "0954256e970ecf371b03a6c9af2cf91b9c4085ff",
              "status": "affected",
              "version": "e60a6d69f1f84c2ef1cc63aefaadfe7ae9f12934",
              "versionType": "git"
            }
          ]
        },
        {
          "defaultStatus": "affected",
          "product": "Linux",
          "programFiles": [
            "drivers/s390/scsi/zfcp_fsf.c"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "vendor": "Linux",
          "versions": [
            {
              "status": "affected",
              "version": "2.6.34"
            },
            {
              "lessThan": "2.6.34",
              "status": "unaffected",
              "version": "0",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "5.4.*",
              "status": "unaffected",
              "version": "5.4.225",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "5.10.*",
              "status": "unaffected",
              "version": "5.10.156",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "5.15.*",
              "status": "unaffected",
              "version": "5.15.80",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "6.0.*",
              "status": "unaffected",
              "version": "6.0.10",
              "versionType": "semver"
            },
            {
              "lessThanOrEqual": "*",
              "status": "unaffected",
              "version": "6.1",
              "versionType": "original_commit_for_fix"
            }
          ]
        }
      ],
      "cpeApplicability": [
        {
          "nodes": [
            {
              "cpeMatch": [
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.4.225",
                  "versionStartIncluding": "2.6.34",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.10.156",
                  "versionStartIncluding": "2.6.34",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "5.15.80",
                  "versionStartIncluding": "2.6.34",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "6.0.10",
                  "versionStartIncluding": "2.6.34",
                  "vulnerable": true
                },
                {
                  "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*",
                  "versionEndExcluding": "6.1",
                  "versionStartIncluding": "2.6.34",
                  "vulnerable": true
                }
              ],
              "negate": false,
              "operator": "OR"
            }
          ]
        }
      ],
      "descriptions": [
        {
          "lang": "en",
          "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nscsi: zfcp: Fix double free of FSF request when qdio send fails\n\nWe used to use the wrong type of integer in \u0027zfcp_fsf_req_send()\u0027 to cache\nthe FSF request ID when sending a new FSF request. This is used in case the\nsending fails and we need to remove the request from our internal hash\ntable again (so we don\u0027t keep an invalid reference and use it when we free\nthe request again).\n\nIn \u0027zfcp_fsf_req_send()\u0027 we used to cache the ID as \u0027int\u0027 (signed and 32\nbit wide), but the rest of the zfcp code (and the firmware specification)\nhandles the ID as \u0027unsigned long\u0027/\u0027u64\u0027 (unsigned and 64 bit wide [s390x\nELF ABI]).  For one this has the obvious problem that when the ID grows\npast 32 bit (this can happen reasonably fast) it is truncated to 32 bit\nwhen storing it in the cache variable and so doesn\u0027t match the original ID\nanymore.  The second less obvious problem is that even when the original ID\nhas not yet grown past 32 bit, as soon as the 32nd bit is set in the\noriginal ID (0x80000000 = 2\u0027147\u0027483\u0027648) we will have a mismatch when we\ncast it back to \u0027unsigned long\u0027. As the cached variable is of a signed\ntype, the compiler will choose a sign-extending instruction to load the 32\nbit variable into a 64 bit register (e.g.: \u0027lgf %r11,188(%r15)\u0027). So once\nwe pass the cached variable into \u0027zfcp_reqlist_find_rm()\u0027 to remove the\nrequest again all the leading zeros will be flipped to ones to extend the\nsign and won\u0027t match the original ID anymore (this has been observed in\npractice).\n\nIf we can\u0027t successfully remove the request from the hash table again after\n\u0027zfcp_qdio_send()\u0027 fails (this happens regularly when zfcp cannot notify\nthe adapter about new work because the adapter is already gone during\ne.g. a ChpID toggle) we will end up with a double free.  We unconditionally\nfree the request in the calling function when \u0027zfcp_fsf_req_send()\u0027 fails,\nbut because the request is still in the hash table we end up with a stale\nmemory reference, and once the zfcp adapter is either reset during recovery\nor shutdown we end up freeing the same memory twice.\n\nThe resulting stack traces vary depending on the kernel and have no direct\ncorrelation to the place where the bug occurs. Here are three examples that\nhave been seen in practice:\n\n  list_del corruption. next-\u003eprev should be 00000001b9d13800, but was 00000000dead4ead. (next=00000001bd131a00)\n  ------------[ cut here ]------------\n  kernel BUG at lib/list_debug.c:62!\n  monitor event: 0040 ilc:2 [#1] PREEMPT SMP\n  Modules linked in: ...\n  CPU: 9 PID: 1617 Comm: zfcperp0.0.1740 Kdump: loaded\n  Hardware name: ...\n  Krnl PSW : 0704d00180000000 00000003cbeea1f8 (__list_del_entry_valid+0x98/0x140)\n             R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:1 PM:0 RI:0 EA:3\n  Krnl GPRS: 00000000916d12f1 0000000080000000 000000000000006d 00000003cb665cd6\n             0000000000000001 0000000000000000 0000000000000000 00000000d28d21e8\n             00000000d3844000 00000380099efd28 00000001bd131a00 00000001b9d13800\n             00000000d3290100 0000000000000000 00000003cbeea1f4 00000380099efc70\n  Krnl Code: 00000003cbeea1e8: c020004f68a7        larl    %r2,00000003cc8d7336\n             00000003cbeea1ee: c0e50027fd65        brasl   %r14,00000003cc3e9cb8\n            #00000003cbeea1f4: af000000            mc      0,0\n            \u003e00000003cbeea1f8: c02000920440        larl    %r2,00000003cd12aa78\n             00000003cbeea1fe: c0e500289c25        brasl   %r14,00000003cc3fda48\n             00000003cbeea204: b9040043            lgr     %r4,%r3\n             00000003cbeea208: b9040051            lgr     %r5,%r1\n             00000003cbeea20c: b9040032            lgr     %r3,%r2\n  Call Trace:\n   [\u003c00000003cbeea1f8\u003e] __list_del_entry_valid+0x98/0x140\n  ([\u003c00000003cbeea1f4\u003e] __list_del_entry_valid+0x94/0x140)\n   [\u003c000003ff7ff502fe\u003e] zfcp_fsf_req_dismiss_all+0xde/0x150 [zfcp]\n   [\u003c000003ff7ff49cd0\u003e] zfcp_erp_strategy_do_action+0x160/0x280 [zfcp]\n---truncated---"
        }
      ],
      "providerMetadata": {
        "dateUpdated": "2025-05-04T08:45:24.202Z",
        "orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
        "shortName": "Linux"
      },
      "references": [
        {
          "url": "https://git.kernel.org/stable/c/1bf8ed585501bb2dd0b5f67c824eab45adfbdccd"
        },
        {
          "url": "https://git.kernel.org/stable/c/d2c7d8f58e9cde8ac8d1f75e9d66c2a813ffe0ab"
        },
        {
          "url": "https://git.kernel.org/stable/c/11edbdee4399401f533adda9bffe94567aa08b96"
        },
        {
          "url": "https://git.kernel.org/stable/c/90a49a6b015fa439cd62e45121390284c125a91f"
        },
        {
          "url": "https://git.kernel.org/stable/c/0954256e970ecf371b03a6c9af2cf91b9c4085ff"
        }
      ],
      "title": "scsi: zfcp: Fix double free of FSF request when qdio send fails",
      "x_generator": {
        "engine": "bippy-1.2.0"
      }
    }
  },
  "cveMetadata": {
    "assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
    "assignerShortName": "Linux",
    "cveId": "CVE-2022-49789",
    "datePublished": "2025-05-01T14:09:21.481Z",
    "dateReserved": "2025-05-01T14:05:17.224Z",
    "dateUpdated": "2025-05-04T08:45:24.202Z",
    "state": "PUBLISHED"
  },
  "dataType": "CVE_RECORD",
  "dataVersion": "5.1",
  "meta": {
    "nvd": "{\"cve\":{\"id\":\"CVE-2022-49789\",\"sourceIdentifier\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"published\":\"2025-05-01T15:16:02.143\",\"lastModified\":\"2025-05-02T13:53:20.943\",\"vulnStatus\":\"Awaiting Analysis\",\"cveTags\":[],\"descriptions\":[{\"lang\":\"en\",\"value\":\"In the Linux kernel, the following vulnerability has been resolved:\\n\\nscsi: zfcp: Fix double free of FSF request when qdio send fails\\n\\nWe used to use the wrong type of integer in \u0027zfcp_fsf_req_send()\u0027 to cache\\nthe FSF request ID when sending a new FSF request. This is used in case the\\nsending fails and we need to remove the request from our internal hash\\ntable again (so we don\u0027t keep an invalid reference and use it when we free\\nthe request again).\\n\\nIn \u0027zfcp_fsf_req_send()\u0027 we used to cache the ID as \u0027int\u0027 (signed and 32\\nbit wide), but the rest of the zfcp code (and the firmware specification)\\nhandles the ID as \u0027unsigned long\u0027/\u0027u64\u0027 (unsigned and 64 bit wide [s390x\\nELF ABI]).  For one this has the obvious problem that when the ID grows\\npast 32 bit (this can happen reasonably fast) it is truncated to 32 bit\\nwhen storing it in the cache variable and so doesn\u0027t match the original ID\\nanymore.  The second less obvious problem is that even when the original ID\\nhas not yet grown past 32 bit, as soon as the 32nd bit is set in the\\noriginal ID (0x80000000 = 2\u0027147\u0027483\u0027648) we will have a mismatch when we\\ncast it back to \u0027unsigned long\u0027. As the cached variable is of a signed\\ntype, the compiler will choose a sign-extending instruction to load the 32\\nbit variable into a 64 bit register (e.g.: \u0027lgf %r11,188(%r15)\u0027). So once\\nwe pass the cached variable into \u0027zfcp_reqlist_find_rm()\u0027 to remove the\\nrequest again all the leading zeros will be flipped to ones to extend the\\nsign and won\u0027t match the original ID anymore (this has been observed in\\npractice).\\n\\nIf we can\u0027t successfully remove the request from the hash table again after\\n\u0027zfcp_qdio_send()\u0027 fails (this happens regularly when zfcp cannot notify\\nthe adapter about new work because the adapter is already gone during\\ne.g. a ChpID toggle) we will end up with a double free.  We unconditionally\\nfree the request in the calling function when \u0027zfcp_fsf_req_send()\u0027 fails,\\nbut because the request is still in the hash table we end up with a stale\\nmemory reference, and once the zfcp adapter is either reset during recovery\\nor shutdown we end up freeing the same memory twice.\\n\\nThe resulting stack traces vary depending on the kernel and have no direct\\ncorrelation to the place where the bug occurs. Here are three examples that\\nhave been seen in practice:\\n\\n  list_del corruption. next-\u003eprev should be 00000001b9d13800, but was 00000000dead4ead. (next=00000001bd131a00)\\n  ------------[ cut here ]------------\\n  kernel BUG at lib/list_debug.c:62!\\n  monitor event: 0040 ilc:2 [#1] PREEMPT SMP\\n  Modules linked in: ...\\n  CPU: 9 PID: 1617 Comm: zfcperp0.0.1740 Kdump: loaded\\n  Hardware name: ...\\n  Krnl PSW : 0704d00180000000 00000003cbeea1f8 (__list_del_entry_valid+0x98/0x140)\\n             R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:1 PM:0 RI:0 EA:3\\n  Krnl GPRS: 00000000916d12f1 0000000080000000 000000000000006d 00000003cb665cd6\\n             0000000000000001 0000000000000000 0000000000000000 00000000d28d21e8\\n             00000000d3844000 00000380099efd28 00000001bd131a00 00000001b9d13800\\n             00000000d3290100 0000000000000000 00000003cbeea1f4 00000380099efc70\\n  Krnl Code: 00000003cbeea1e8: c020004f68a7        larl    %r2,00000003cc8d7336\\n             00000003cbeea1ee: c0e50027fd65        brasl   %r14,00000003cc3e9cb8\\n            #00000003cbeea1f4: af000000            mc      0,0\\n            \u003e00000003cbeea1f8: c02000920440        larl    %r2,00000003cd12aa78\\n             00000003cbeea1fe: c0e500289c25        brasl   %r14,00000003cc3fda48\\n             00000003cbeea204: b9040043            lgr     %r4,%r3\\n             00000003cbeea208: b9040051            lgr     %r5,%r1\\n             00000003cbeea20c: b9040032            lgr     %r3,%r2\\n  Call Trace:\\n   [\u003c00000003cbeea1f8\u003e] __list_del_entry_valid+0x98/0x140\\n  ([\u003c00000003cbeea1f4\u003e] __list_del_entry_valid+0x94/0x140)\\n   [\u003c000003ff7ff502fe\u003e] zfcp_fsf_req_dismiss_all+0xde/0x150 [zfcp]\\n   [\u003c000003ff7ff49cd0\u003e] zfcp_erp_strategy_do_action+0x160/0x280 [zfcp]\\n---truncated---\"},{\"lang\":\"es\",\"value\":\"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: scsi: zfcp: Arregla doble liberaci\u00f3n de solicitud FSF cuando falla el env\u00edo de qdio Sol\u00edamos usar el tipo incorrecto de entero en \u0027zfcp_fsf_req_send()\u0027 para almacenar en cach\u00e9 el ID de solicitud FSF al enviar una nueva solicitud FSF. Esto se usa en caso de que el env\u00edo falle y necesitemos eliminar la solicitud de nuestra tabla hash interna nuevamente (para no mantener una referencia no v\u00e1lida y usarla cuando liberemos la solicitud nuevamente). En \u0027zfcp_fsf_req_send()\u0027 sol\u00edamos almacenar en cach\u00e9 el ID como \u0027int\u0027 (con signo y 32 bits de ancho), pero el resto del c\u00f3digo zfcp (y la especificaci\u00f3n del firmware) maneja el ID como \u0027unsigned long\u0027/\u0027u64\u0027 (sin signo y 64 bits de ancho [s390x ELF ABI]). Por un lado, esto presenta el problema obvio de que, cuando el ID supera los 32 bits (esto puede ocurrir con relativa rapidez), se trunca a 32 bits al almacenarlo en la variable de cach\u00e9, por lo que ya no coincide con el ID original. El segundo problema, menos obvio, es que, incluso cuando el ID original a\u00fan no supera los 32 bits, en cuanto se establece el bit 32 en el ID original (0x80000000 = 2\u0027147\u0027483\u0027648), se produce una discrepancia al convertirlo a \u0027unsigned long\u0027. Como la variable en cach\u00e9 es de tipo con signo, el compilador utilizar\u00e1 una instrucci\u00f3n de extensi\u00f3n de signo para cargar la variable de 32 bits en un registro de 64 bits (p. ej., \u0027lgf %r11,188(%r15)\u0027). Entonces, una vez que pasamos la variable en cach\u00e9 a \u0027zfcp_reqlist_find_rm()\u0027 para eliminar la solicitud de nuevo, todos los ceros iniciales se invertir\u00e1n a unos para extender el signo y ya no coincidir\u00e1n con el ID original (esto se ha observado en la pr\u00e1ctica). Si no podemos eliminar correctamente la solicitud de la tabla hash de nuevo despu\u00e9s de que \u0027zfcp_qdio_send()\u0027 falle (esto sucede regularmente cuando zfcp no puede notificar al adaptador sobre el nuevo trabajo porque el adaptador ya se ha ido durante, por ejemplo, una conmutaci\u00f3n de ChpID), terminaremos con una doble liberaci\u00f3n. Liberamos incondicionalmente la solicitud en la funci\u00f3n de llamada cuando \u0027zfcp_fsf_req_send()\u0027 falla, pero debido a que la solicitud a\u00fan est\u00e1 en la tabla hash, terminamos con una referencia de memoria obsoleta, y una vez que el adaptador zfcp se reinicia durante la recuperaci\u00f3n o el apagado, terminamos liberando la misma memoria dos veces. Los seguimientos de pila resultantes var\u00edan seg\u00fan el kernel y no tienen correlaci\u00f3n directa con el lugar donde ocurre el error. A continuaci\u00f3n se muestran tres ejemplos que se han visto en la pr\u00e1ctica: corrupci\u00f3n de list_del. next-\u0026gt;prev deber\u00eda ser 00000001b9d13800, pero era 00000000dead4ead. (next=00000001bd131a00) ------------[ cortar aqu\u00ed ]------------ \u00a1ERROR del kernel en lib/list_debug.c:62! evento de monitor: 0040 ilc:2 [#1] PREEMPT M\u00f3dulos SMP vinculados: ... CPU: 9 PID: 1617 Comm: zfcperp0.0.1740 Kdump: cargado Nombre del hardware: ... Krnl PSW: 0704d00180000000 00000003cbeea1f8 (__list_del_entry_valid+0x98/0x140) R:0 T:1 IO:1 EX:1 Clave:0 M:1 W:0 P:0 AS:3 CC:1 PM:0 RI:0 EA:3 Krnl GPRS: 00000000916d12f1 0000000080000000 00000000000006d 00000003cb665cd6 0000000000000001 0000000000000000 0000000000000000 00000000d28d21e8 00000000d3844000 00000380099efd28 00000001bd131a00 00000001b9d13800 00000000d3290100 0000000000000000 00000003cbeea1f4 00000380099efc70 C\u00f3digo Krnl: 00000003cbeea1e8: c020004f68a7 larl %r2,00000003cc8d7336 00000003cbeea1ee: c0e50027fd65 brasl %r14,00000003cc3e9cb8 #00000003cbeea1f4: af000000 mc 0,0 \u0026gt;00000003cbeea1f8: c02000920440 larl %r2,00000003cd12aa78 00000003cbeea1fe: c0e500289c25 brasl %r14,00000003cc3fda48 00000003cbeea204: b9040043 lgr %r4,%r3 00000003cbeea208: b9040051 lgr %r5,%r1 00000003cbeea20c: b9040032 lgr %r3,%r2 Rastreo de llamadas: [\u0026lt;00000003cbeea1f8\u0026gt;] __list_del_entry_valid+0x98/0x140 ([\u0026lt;00000003cbeea1f4\u0026gt;] __list_del_entry_valid+0x94/0x140) [\u0026lt;000003ff7ff502fe\u0026gt;] zfcp_fsf_req_dismiss_all+0xde/0x150 [zfcp] [\u0026lt;000003ff7ff49cd0\u0026gt;] zfcp_erp_strategy_do_action+0x160/0x280 [zfcp] ---truncado---\"}],\"metrics\":{},\"references\":[{\"url\":\"https://git.kernel.org/stable/c/0954256e970ecf371b03a6c9af2cf91b9c4085ff\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/11edbdee4399401f533adda9bffe94567aa08b96\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/1bf8ed585501bb2dd0b5f67c824eab45adfbdccd\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/90a49a6b015fa439cd62e45121390284c125a91f\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/d2c7d8f58e9cde8ac8d1f75e9d66c2a813ffe0ab\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"}]}}"
  }
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading...

Loading...

Loading...
  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.