{"id":"CVE-2022-50459","state":"PUBLISHED","title":"scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nscsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()\n\nFix a NULL pointer crash that occurs when we are freeing the socket at the\nsame time we access it via sysfs.\n\nThe problem is that:\n\n 1. iscsi_sw_tcp_conn_get_param() and iscsi_sw_tcp_host_get_param() take\n    the frwd_lock and do sock_hold() then drop the frwd_lock. sock_hold()\n    does a get on the \"struct sock\".\n\n 2. iscsi_sw_tcp_release_conn() does sockfd_put() which does the last put\n    on the \"struct socket\" and that does __sock_release() which sets the\n    sock->ops to NULL.\n\n 3. iscsi_sw_tcp_conn_get_param() and iscsi_sw_tcp_host_get_param() then\n    call kernel_getpeername() which accesses the NULL sock->ops.\n\nAbove we do a get on the \"struct sock\", but we needed a get on the \"struct\nsocket\". Originally, we just held the frwd_lock the entire time but in\ncommit bcf3a2953d36 (\"scsi: iscsi: iscsi_tcp: Avoid holding spinlock while\ncalling getpeername()\") we switched to refcount based because the network\nlayer changed and started taking a mutex in that path, so we could no\nlonger hold the frwd_lock.\n\nInstead of trying to maintain multiple refcounts, this just has us use a\nmutex for accessing the socket in the interface code paths.","publishedAt":"2025-10-01T11:45:31.740Z","updatedAt":"2026-08-05T08:58:52.235Z","severity":{"score":7.8,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"Linux"},"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"bcf3a2953d36bbfb9bd44ccb3db0897d935cc485","status":"affected","lessThan":"884a788f065578bb640382279a83d1df433b13e6","versionType":"git"},{"version":"bcf3a2953d36bbfb9bd44ccb3db0897d935cc485","status":"affected","lessThan":"a26b0658751bb0a3b28386fca715333b104d32a2","versionType":"git"},{"version":"bcf3a2953d36bbfb9bd44ccb3db0897d935cc485","status":"affected","lessThan":"897dbbc57d71e8a34ec1af8e573a142de457da38","versionType":"git"},{"version":"bcf3a2953d36bbfb9bd44ccb3db0897d935cc485","status":"affected","lessThan":"0a0b861fce2657ba08ec356a74346b37ca4b2008","versionType":"git"},{"version":"bcf3a2953d36bbfb9bd44ccb3db0897d935cc485","status":"affected","lessThan":"57569c37f0add1b6489e1a1563c71519daf732cf","versionType":"git"},{"version":"7d29e950766327f658cb92722b9445ac3b3ae023","status":"affected","versionType":"git"},{"version":"5.8.14","status":"affected","lessThan":"5.9","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/scsi/iscsi_tcp.c","drivers/scsi/iscsi_tcp.h"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.9","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.9","versionType":"semver"},{"version":"5.10.150","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.75","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"5.19.17","status":"unaffected","lessThanOrEqual":"5.19.*","versionType":"semver"},{"version":"6.0.3","status":"unaffected","lessThanOrEqual":"6.0.*","versionType":"semver"},{"version":"6.1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/scsi/iscsi_tcp.c","drivers/scsi/iscsi_tcp.h"]}],"references":["https://git.kernel.org/stable/c/884a788f065578bb640382279a83d1df433b13e6","https://git.kernel.org/stable/c/a26b0658751bb0a3b28386fca715333b104d32a2","https://git.kernel.org/stable/c/897dbbc57d71e8a34ec1af8e573a142de457da38","https://git.kernel.org/stable/c/0a0b861fce2657ba08ec356a74346b37ca4b2008","https://git.kernel.org/stable/c/57569c37f0add1b6489e1a1563c71519daf732cf"],"weaknesses":[],"ingestedAt":"2026-10-29T20:05:26.763Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2022/50xxx/CVE-2022-50459.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2022-50459","state":"PUBLISHED","datePublished":"2025-10-01T11:45:31.740Z","dateUpdated":"2026-08-05T08:58:52.235Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2025-10-01T11:38:45.640Z"},"containers":{"cna":{"title":"scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nscsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()\n\nFix a NULL pointer crash that occurs when we are freeing the socket at the\nsame time we access it via sysfs.\n\nThe problem is that:\n\n 1. iscsi_sw_tcp_conn_get_param() and iscsi_sw_tcp_host_get_param() take\n    the frwd_lock and do sock_hold() then drop the frwd_lock. sock_hold()\n    does a get on the \"struct sock\".\n\n 2. iscsi_sw_tcp_release_conn() does sockfd_put() which does the last put\n    on the \"struct socket\" and that does __sock_release() which sets the\n    sock->ops to NULL.\n\n 3. iscsi_sw_tcp_conn_get_param() and iscsi_sw_tcp_host_get_param() then\n    call kernel_getpeername() which accesses the NULL sock->ops.\n\nAbove we do a get on the \"struct sock\", but we needed a get on the \"struct\nsocket\". Originally, we just held the frwd_lock the entire time but in\ncommit bcf3a2953d36 (\"scsi: iscsi: iscsi_tcp: Avoid holding spinlock while\ncalling getpeername()\") we switched to refcount based because the network\nlayer changed and started taking a mutex in that path, so we could no\nlonger hold the frwd_lock.\n\nInstead of trying to maintain multiple refcounts, this just has us use a\nmutex for accessing the socket in the interface code paths."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"bcf3a2953d36bbfb9bd44ccb3db0897d935cc485","status":"affected","lessThan":"884a788f065578bb640382279a83d1df433b13e6","versionType":"git"},{"version":"bcf3a2953d36bbfb9bd44ccb3db0897d935cc485","status":"affected","lessThan":"a26b0658751bb0a3b28386fca715333b104d32a2","versionType":"git"},{"version":"bcf3a2953d36bbfb9bd44ccb3db0897d935cc485","status":"affected","lessThan":"897dbbc57d71e8a34ec1af8e573a142de457da38","versionType":"git"},{"version":"bcf3a2953d36bbfb9bd44ccb3db0897d935cc485","status":"affected","lessThan":"0a0b861fce2657ba08ec356a74346b37ca4b2008","versionType":"git"},{"version":"bcf3a2953d36bbfb9bd44ccb3db0897d935cc485","status":"affected","lessThan":"57569c37f0add1b6489e1a1563c71519daf732cf","versionType":"git"},{"version":"7d29e950766327f658cb92722b9445ac3b3ae023","status":"affected","versionType":"git"},{"version":"5.8.14","status":"affected","lessThan":"5.9","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/scsi/iscsi_tcp.c","drivers/scsi/iscsi_tcp.h"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.9","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.9","versionType":"semver"},{"version":"5.10.150","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.75","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"5.19.17","status":"unaffected","lessThanOrEqual":"5.19.*","versionType":"semver"},{"version":"6.0.3","status":"unaffected","lessThanOrEqual":"6.0.*","versionType":"semver"},{"version":"6.1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/scsi/iscsi_tcp.c","drivers/scsi/iscsi_tcp.h"]}],"references":[{"url":"https://git.kernel.org/stable/c/884a788f065578bb640382279a83d1df433b13e6"},{"url":"https://git.kernel.org/stable/c/a26b0658751bb0a3b28386fca715333b104d32a2"},{"url":"https://git.kernel.org/stable/c/897dbbc57d71e8a34ec1af8e573a142de457da38"},{"url":"https://git.kernel.org/stable/c/0a0b861fce2657ba08ec356a74346b37ca4b2008"},{"url":"https://git.kernel.org/stable/c/57569c37f0add1b6489e1a1563c71519daf732cf"}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","baseScore":7.8,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:L - The vulnerable path is reached by reading world-readable iscsi_connection/iscsi_host sysfs attributes (address/port/local_port/ipaddress) that call iscsi_sw_tcp_conn_get_param()/iscsi_sw_tcp_host_get_param(), a local sysfs/syscall path rather than remote packet processing.\nAC:L - An attacker who can spam the sysfs reads controls one side of the race and can align it with connection stop/logout/cleanup_work teardown; when the attacker also manages the session they control both sides, so success does not depend on attacker-uncontrollable memory layout.\nPR:L - The crashing/UAF read path uses S_IRUGO sysfs attributes with no capable() check, so on hosts that already have iscsi_tcp sessions an unprivileged local user (e.g. cat of the attr) can trigger the bug without CAP_SYS_ADMIN.\nUI:N - Exploitation requires only the attacker’s own sysfs reads raced with connection teardown; no separate victim action such as mounting a filesystem is required.\nS:U - Impact remains within the host kernel’s iSCSI/socket authority and does not cross a VM, IOMMU, or other security boundary.\nC:H - The bug holds only a struct sock ref while sockfd_put may free the struct socket, yielding a UAF of the socket object whose reused contents can be sprayed to obtain an arbitrary kernel read primitive.\nI:H - Use-after-free of struct socket allows a sprayed sock->ops function-pointer table, so kernel_getpeername()/getsockname() can be turned into control-flow hijacking / arbitrary write rather than only a crash.\nA:H - The documented concurrent free versus getpeername path NULL-dereferences sock->ops (and UAF crashes under KASAN), causing a kernel oops/panic and full availability loss."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T08:58:52.235Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.9","versionEndExcluding":"5.10.150"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.9","versionEndExcluding":"5.15.75"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.9","versionEndExcluding":"5.19.17"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.9","versionEndExcluding":"6.0.3"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.9","versionEndExcluding":"6.1"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.8.14"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}