Skip to contentSkip to conversation

CVE-2022-50331: wwan_hwsim: fix possible memory leak in wwan_hwsim_dev_new()

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Sep 15, 2025

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

wwan_hwsim: fix possible memory leak in wwan_hwsim_dev_new()

Inject fault while probing module, if device_register() fails, but the refcount of kobject is not decreased to 0, the name allocated in dev_set_name() is leaked. Fix this by calling put_device(), so that name can be freed in callback function kobject_cleanup().

unreferenced object 0xffff88810152ad20 (size 8):
comm "modprobe", pid 252, jiffies 4294849206 (age 22.713s) hex dump (first 8 bytes):

    68 77 73 69 6d 30 00 ff                          hwsim0..
  backtrace:
    [<000000009c3504ed>] __kmalloc_node_track_caller+0x44/0x1b0
    [<00000000c0228a5e>] kvasprintf+0xb5/0x140
    [<00000000cff8c21f>] kvasprintf_const+0x55/0x180
    [<0000000055a1e073>] kobject_set_name_vargs+0x56/0x150
    [<000000000a80b139>] dev_set_name+0xab/0xe0

The Linux kernel CVE team has assigned CVE-2022-50331 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 5.14 with commit f36a111a74e71edbba27d4c0cf3d7bbccc172108 and fixed in 5.15.76 with commit 50c31fa952309536c6e4461ff815ddccc8dff9d5
	Issue introduced in 5.14 with commit f36a111a74e71edbba27d4c0cf3d7bbccc172108 and fixed in 6.0.6 with commit d87973314aba6de80a49f4271dd9be4ddc08e729
	Issue introduced in 5.14 with commit f36a111a74e71edbba27d4c0cf3d7bbccc172108 and fixed in 6.1 with commit 258ad2fe5ede773625adfda88b173f4123e59f45

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2022-50331

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
drivers/net/wwan/wwan_hwsim.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/50c31fa952309536c6e4461ff815ddccc8dff9d5
	https://git.kernel.org/stable/c/d87973314aba6de80a49f4271dd9be4ddc08e729
	https://git.kernel.org/stable/c/258ad2fe5ede773625adfda88b173f4123e59f45