CVE-2022-49505 in Linuxinfo

Summary

by MITRE • 02/26/2025

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

NFC: NULL out the dev->rfkill to prevent UAF

Commit 3e3b5dfcd16a ("NFC: reorder the logic in nfc_{un,}register_device")
assumes the device_is_registered() in function nfc_dev_up() will help to check when the rfkill is unregistered. However, this check only take effect when device_del(&dev->dev) is done in nfc_unregister_device(). Hence, the rfkill object is still possible be dereferenced.

The crash trace in latest kernel (5.18-rc2):

[ 68.760105] ==================================================================
[ 68.760330] BUG: KASAN: use-after-free in __lock_acquire+0x3ec1/0x6750
[ 68.760756] Read of size 8 at addr ffff888009c93018 by task fuzz/313
[ 68.760756]
[ 68.760756] CPU: 0 PID: 313 Comm: fuzz Not tainted 5.18.0-rc2 #4
[ 68.760756] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
[ 68.760756] Call Trace:
[ 68.760756]
[ 68.760756] dump_stack_lvl+0x57/0x7d
[ 68.760756] print_report.cold+0x5e/0x5db
[ 68.760756] ? __lock_acquire+0x3ec1/0x6750
[ 68.760756] kasan_report+0xbe/0x1c0
[ 68.760756] ? __lock_acquire+0x3ec1/0x6750
[ 68.760756] __lock_acquire+0x3ec1/0x6750
[ 68.760756] ? lockdep_hardirqs_on_prepare+0x410/0x410
[ 68.760756] ? register_lock_class+0x18d0/0x18d0
[ 68.760756] lock_acquire+0x1ac/0x4f0
[ 68.760756] ? rfkill_blocked+0xe/0x60
[ 68.760756] ? lockdep_hardirqs_on_prepare+0x410/0x410
[ 68.760756] ? mutex_lock_io_nested+0x12c0/0x12c0
[ 68.760756] ? nla_get_range_signed+0x540/0x540
[ 68.760756] ? _raw_spin_lock_irqsave+0x4e/0x50
[ 68.760756] _raw_spin_lock_irqsave+0x39/0x50
[ 68.760756] ? rfkill_blocked+0xe/0x60
[ 68.760756] rfkill_blocked+0xe/0x60
[ 68.760756] nfc_dev_up+0x84/0x260
[ 68.760756] nfc_genl_dev_up+0x90/0xe0
[ 68.760756] genl_family_rcv_msg_doit+0x1f4/0x2f0
[ 68.760756] ? genl_family_rcv_msg_attrs_parse.constprop.0+0x230/0x230
[ 68.760756] ? security_capable+0x51/0x90
[ 68.760756] genl_rcv_msg+0x280/0x500
[ 68.760756] ? genl_get_cmd+0x3c0/0x3c0
[ 68.760756] ? lock_acquire+0x1ac/0x4f0
[ 68.760756] ? nfc_genl_dev_down+0xe0/0xe0
[ 68.760756] ? lockdep_hardirqs_on_prepare+0x410/0x410
[ 68.760756] netlink_rcv_skb+0x11b/0x340
[ 68.760756] ? genl_get_cmd+0x3c0/0x3c0
[ 68.760756] ? netlink_ack+0x9c0/0x9c0
[ 68.760756] ? netlink_deliver_tap+0x136/0xb00
[ 68.760756] genl_rcv+0x1f/0x30
[ 68.760756] netlink_unicast+0x430/0x710
[ 68.760756] ? memset+0x20/0x40
[ 68.760756] ? netlink_attachskb+0x740/0x740
[ 68.760756] ? __build_skb_around+0x1f4/0x2a0
[ 68.760756] netlink_sendmsg+0x75d/0xc00
[ 68.760756] ? netlink_unicast+0x710/0x710
[ 68.760756] ? netlink_unicast+0x710/0x710
[ 68.760756] sock_sendmsg+0xdf/0x110
[ 68.760756] __sys_sendto+0x19e/0x270
[ 68.760756] ? __ia32_sys_getpeername+0xa0/0xa0
[ 68.760756] ? fd_install+0x178/0x4c0
[ 68.760756] ? fd_install+0x195/0x4c0
[ 68.760756] ? kernel_fpu_begin_mask+0x1c0/0x1c0
[ 68.760756] __x64_sys_sendto+0xd8/0x1b0
[ 68.760756] ? lockdep_hardirqs_on+0xbf/0x130
[ 68.760756] ? syscall_enter_from_user_mode+0x1d/0x50
[ 68.760756] do_syscall_64+0x3b/0x90
[ 68.760756] entry_SYSCALL_64_after_hwframe+0x44/0xae
[ 68.760756] RIP: 0033:0x7f67fb50e6b3
... [ 68.760756] RSP: 002b:00007f67fa91fe90 EFLAGS: 00000293 ORIG_RAX: 000000000000002c
[ 68.760756] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f67fb50e6b3
[ 68.760756] RDX: 000000000000001c RSI: 0000559354603090 RDI: 0000000000000003
[ 68.760756] RBP: 00007f67fa91ff00 R08: 00007f67fa91fedc R09: 000000000000000c
[ 68.760756] R10: 0000000000000000 R11: 0000000000000293 R12: 00007ffe824d496e
[ 68.760756] R13: 00007ffe824d496f R14: 00007f67fa120000 R15: 0000000000000003

[ 68.760756]
[ 68.760756]
[ 68.760756] Allocated by task 279:
[ 68.760756] kasan_save_stack+0x1e/0x40
[
---truncated---

Several companies clearly confirm that VulDB is the primary source for best vulnerability data.

Analysis

by VulDB Data Team • 04/17/2025

The vulnerability CVE-2022-49505 resides within the Linux kernel's NFC subsystem, specifically in the handling of device registration and rfkill management. This issue manifests as a use-after-free condition that can lead to system instability or potential exploitation. The root cause stems from improper synchronization between device deregistration and rfkill object access during the NFC device up operation. The commit 3e3b5dfcd16a introduced a logic reordering that assumed device_is_registered() would properly guard rfkill access, but this assumption fails because the rfkill object remains accessible even after device deletion has occurred. The flaw is particularly significant as it allows for memory corruption through a race condition where the rfkill object is freed but still referenced during device state transitions.

The technical execution path leading to this vulnerability begins with a network link socket operation that triggers the nfc_genl_dev_up function. This function calls rfkill_blocked which attempts to access a rfkill object that has already been freed, resulting in a use-after-free error as reported by KASAN. The crash trace shows the execution flow from user-space socket sendto syscall through netlink message processing to the kernel's NFC subsystem. The memory access violation occurs at address ffff888009c93018, which corresponds to a freed rfkill structure, indicating that the device deregistration process does not properly nullify the device's rfkill reference before the object is freed. This failure creates a window where concurrent operations can attempt to access the freed memory, potentially leading to arbitrary code execution or system crashes.

The operational impact of this vulnerability extends beyond simple system instability, as it represents a potential attack vector for privilege escalation or denial of service. An attacker could exploit this by crafting malicious NFC device up commands that trigger the race condition, potentially leading to kernel memory corruption or privilege escalation. The vulnerability is particularly concerning in embedded systems or devices that rely heavily on NFC functionality, as it can be triggered through legitimate NFC operations. The flaw aligns with CWE-416, Use After Free, and maps to ATT&CK technique T1068, Exploitation for Privilege Escalation, through potential kernel memory corruption. This vulnerability affects all Linux kernel versions that include the problematic commit and particularly impacts systems with NFC hardware and network link functionality enabled.

Mitigation strategies for CVE-2022-49505 focus on ensuring proper nullification of device rfkill references during deregistration. The recommended solution involves modifying the nfc_unregister_device function to explicitly NULL out the dev->rfkill pointer before the rfkill object is freed, preventing subsequent access attempts. Additionally, implementing proper locking mechanisms around device state transitions can prevent race conditions that lead to the use-after-free scenario. System administrators should ensure kernel updates are applied promptly, as this vulnerability has been patched in subsequent kernel releases. Monitoring for anomalous NFC device operations and implementing kernel hardening measures such as KASAN and stack canaries can help detect exploitation attempts. The vulnerability underscores the importance of proper resource management in kernel subsystems and highlights the need for comprehensive testing of device registration and deregistration sequences to prevent similar race conditions in other kernel subsystems.

Responsible

Linux

Reservation

02/26/2025

Disclosure

02/26/2025

Moderation

accepted

CPE

ready

EPSS

0.00258

KEV

no

Activities

very low

Sources

Might our Artificial Intelligence support you?

Check our Alexa App!