CyberSecBulletin
CVE-2022-49700NVD status: Analyzed

Linux: Use After Free

CVE-2022-49700 is a high-severity use after free vulnerability in Linux, with a CVSS 3.1 base score of 7.8 out of 10. It can be exploited with local access to the system by an attacker with a low-privileged account, without any action from a user. The record lists versions 308c6d0e1f200fd26c71270c6e6bfcf0fc6ff082, d6a597450e686d4c6388bd3cdcb17224b4dae7f0, e2b2f0e2e34d71ae6c2a1114fd3c525930e84bc7 as the first without the flaw, so updating Linux to one of those releases or later removes the exposure. There is no confirmed exploitation so far. EPSS estimates a 0.29% chance of exploitation within 30 days, which is low compared with other CVEs.

Next patch cycle

High severity with no evidence of exploitation so far.

What to do

  1. Update Linux to 308c6d0e1f200fd26c71270c6e6bfcf0fc6ff082 or d6a597450e686d4c6388bd3cdcb17224b4dae7f0 or e2b2f0e2e34d71ae6c2a1114fd3c525930e84bc7 or e7e3e90d671078455a3a08189f89d85b3da2de9e, whichever matches your release line, or a later version.
  2. Update Linux Kernel to 4.9.323 or 4.14.288 or 4.19.252 or 5.4.205, whichever matches your release line, or a later version.

Affected products and versions

VendorProductAffected versionsFixed in
LinuxLinux03e404af26dc2ea0d278d7a342de0aab394793ce up to, but not including, 308c6d0e1f200fd26c71270c6e6bfcf0fc6ff082; 03e404af26dc2ea0d278d7a342de0aab394793ce up to, but not including, d6a597450e686d4c6388bd3cdcb17224b4dae7f0; 03e404af26dc2ea0d278d7a342de0aab394793ce up to, but not including, e2b2f0e2e34d71ae6c2a1114fd3c525930e84bc7; 03e404af26dc2ea0d278d7a342de0aab394793ce up to, but not including, e7e3e90d671078455a3a08189f89d85b3da2de9e; 03e404af26dc2ea0d278d7a342de0aab394793ce up to, but not including, 6c32496964da0dc230cea763a0e934b2e02dabd5; 03e404af26dc2ea0d278d7a342de0aab394793ce up to, but not including, 0515cc9b6b24877f59b222ade704bfaa42caa2a6; 03e404af26dc2ea0d278d7a342de0aab394793ce up to, but not including, 197e257da473c725dfe47759c3ee02f2398d8ea5; 03e404af26dc2ea0d278d7a342de0aab394793ce up to, but not including, eeaa345e128515135ccb864c04482180c08e3259; and 1 more ranges308c6d0e1f200fd26c71270c6e6bfcf0fc6ff082, d6a597450e686d4c6388bd3cdcb17224b4dae7f0, e2b2f0e2e34d71ae6c2a1114fd3c525930e84bc7, e7e3e90d671078455a3a08189f89d85b3da2de9e, 6c32496964da0dc230cea763a0e934b2e02dabd5, 0515cc9b6b24877f59b222ade704bfaa42caa2a6
LinuxLinux Kernel3.1 up to, but not including, 4.9.323; 4.10 up to, but not including, 4.14.288; 4.15 up to, but not including, 4.19.252; 4.20 up to, but not including, 5.4.205; 5.5 up to, but not including, 5.10.130; 5.11 up to, but not including, 5.15.54; 5.16 up to, but not including, 5.18.8; 5.194.9.323, 4.14.288, 4.19.252, 5.4.205, 5.10.130, 5.15.54

Version data comes from the organisation that assigned the CVE. Confirm against the vendor advisory before deciding you are unaffected.

How the severity score breaks down

Attack vector
LocalThe attacker needs local access or must trick a user into running something.
Attack complexity
LowNo special conditions are needed; the attack works reliably.
Privileges required
LowA basic user account is enough.
User interaction
NoneNo action by a victim is required.
Scope
UnchangedImpact stays within the vulnerable component.
Confidentiality
HighAll data handled by the component can be read.
Integrity
HighData or code can be modified at will.
Availability
HighThe component can be taken down completely.

Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H. Scored by CISA (ADP).

Official description

In the Linux kernel, the following vulnerability has been resolved: mm/slub: add missing TID updates on slab deactivation The fastpath in slab_alloc_node() assumes that c->slab is stable as long as the TID stays the same. However, two places in __slab_alloc() currently don't update the TID when deactivating the CPU slab. If multiple operations race the right way, this could lead to an object getting lost; or, in an even more unlikely situation, it could even lead to an object being freed onto the wrong slab's freelist, messing up the `inuse` counter and eventually causing a page to be freed to the page allocator while it still contains slab objects. (I haven't actually tested these cases though, this is just based on looking at the code. Writing testcases for this stuff seems like it'd be a pain...) The race leading to state inconsistency is (all operations on the same CPU and kmem_cache): - task A: begin do_slab_free(): - read TID - read pcpu freelist (==NULL) - check `slab == c->slab` (true) - [PREEMPT A->B] - task B: begin slab_alloc_node(): - fastpath fails (`c->freelist` is NULL) - enter __slab_alloc() - slub_get_cpu_ptr() (disables preemption) - enter ___slab_alloc() - take local_lock_irqsave() - read c->freelist as NULL - get_freelist() returns NULL - write `c->slab = NULL` - drop local_unlock_irqrestore() - goto new_slab - slub_percpu_partial() is NULL - get_partial() returns NULL - slub_put_cpu_ptr() (enables preemption) - [PREEMPT B->A] - task A: finish do_slab_free(): - this_cpu_cmpxchg_double() succeeds() - [CORRUPT STATE: c->slab==NULL, c->freelist!=NULL] From there, the object on c->freelist will get lost if task B is allowed to continue from here: It will proceed to the retry_load_slab label, set c->slab, then jump to load_freelist, which clobbers c->freelist. But if we instead continue as follows, we get worse corruption: - task A: run __slab_free() on object from other struct slab: - CPU_PARTIAL_FREE case (slab was on no list, is now on pcpu partial) - task A: run slab_alloc_node() with NUMA node constraint: - fastpath fails (c->slab is NULL) - call __slab_alloc() - slub_get_cpu_ptr() (disables preemption) - enter ___slab_alloc() - c->slab is NULL: goto new_slab - slub_percpu_partial() is non-NULL - set c->slab to slub_percpu_partial(c) - [CORRUPT STATE: c->slab points to slab-1, c->freelist has objects from slab-2] - goto redo - node_match() fails - goto deactivate_slab - existing c->freelist is passed into deactivate_slab() - inuse count of slab-1 is decremented to account for object from slab-2 At this point, the inuse count of slab-1 is 1 lower than it should be. This means that if we free all allocated objects in slab-1 except for one, SLUB will think that slab-1 is completely unused, and may free its page, leading to use-after-free.

Source: the CVE record as published by its numbering authority, via NVD and CVE.org.

The underlying weakness: Use After Free

The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory belongs to the code that operates on the new pointer.

How developers prevent this class of flaw

  • Choose a language that provides automatic memory management.
  • When freeing pointers, be sure to set them to NULL once they are freed. However, the utilization of multiple or complex data structures may lower the usefulness of this strategy.

More Use After Free vulnerabilities (CWE-416)

Timeline

  1. CVE record published.
  2. CISA published its SSVC assessment (exploitation: none, automatable: no, technical impact: total).
  3. Record last changed materially (score, affected products, status or references).

References

Recent Use After Free vulnerabilities

Spotted an error? Tell us.