Bug 2300713 (CVE-2024-42096) - CVE-2024-42096 kernel: x86: stop playing stack games in profile_pc()
Summary: CVE-2024-42096 kernel: x86: stop playing stack games in profile_pc()
Keywords:
Status: NEW
Alias: CVE-2024-42096
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Product Security DevOps Team
QA Contact:
URL:
Whiteboard:
Depends On: 2301752
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-07-29 18:21 UTC by OSIDB Bzimport
Modified: 2024-10-21 09:47 UTC (History)
4 users (show)

Fixed In Version: kernel 4.19.317, kernel 5.4.279, kernel 5.10.221, kernel 5.15.162, kernel 6.1.97, kernel 6.6.37, kernel 6.9.8, kernel 6.10
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2024:6650 0 None None None 2024-09-12 14:28:42 UTC
Red Hat Product Errata RHBA-2024:7043 0 None None None 2024-09-24 09:43:30 UTC
Red Hat Product Errata RHBA-2024:7198 0 None None None 2024-09-26 09:50:58 UTC
Red Hat Product Errata RHBA-2024:7236 0 None None None 2024-09-26 14:38:02 UTC
Red Hat Product Errata RHBA-2024:7637 0 None None None 2024-10-03 14:46:19 UTC
Red Hat Product Errata RHBA-2024:8227 0 None None None 2024-10-17 06:46:17 UTC
Red Hat Product Errata RHSA-2024:6567 0 None None None 2024-09-11 01:01:15 UTC
Red Hat Product Errata RHSA-2024:7000 0 None None None 2024-09-24 02:35:21 UTC
Red Hat Product Errata RHSA-2024:7001 0 None None None 2024-09-24 00:39:53 UTC

Description OSIDB Bzimport 2024-07-29 18:21:30 UTC
In the Linux kernel, the following vulnerability has been resolved:

x86: stop playing stack games in profile_pc()

The 'profile_pc()' function is used for timer-based profiling, which
isn't really all that relevant any more to begin with, but it also ends
up making assumptions based on the stack layout that aren't necessarily
valid.

Basically, the code tries to account the time spent in spinlocks to the
caller rather than the spinlock, and while I support that as a concept,
it's not worth the code complexity or the KASAN warnings when no serious
profiling is done using timers anyway these days.

And the code really does depend on stack layout that is only true in the
simplest of cases.  We've lost the comment at some point (I think when
the 32-bit and 64-bit code was unified), but it used to say:

	Assume the lock function has either no stack frame or a copy
	of eflags from PUSHF.

which explains why it just blindly loads a word or two straight off the
stack pointer and then takes a minimal look at the values to just check
if they might be eflags or the return pc:

	Eflags always has bits 22 and up cleared unlike kernel addresses

but that basic stack layout assumption assumes that there isn't any lock
debugging etc going on that would complicate the code and cause a stack
frame.

It causes KASAN unhappiness reported for years by syzkaller [1] and
others [2].

With no real practical reason for this any more, just remove the code.

Just for historical interest, here's some background commits relating to
this code from 2006:

  0cb91a229364 ("i386: Account spinlocks to the caller during profiling for !FP kernels")
  31679f38d886 ("Simplify profile_pc on x86-64")

and a code unification from 2009:

  ef4512882dbe ("x86: time_32/64.c unify profile_pc")

but the basics of this thing actually goes back to before the git tree.

Comment 1 Mauro Matteo Cascella 2024-07-30 17:49:18 UTC
Upstream advisory:
https://lore.kernel.org/linux-cve-announce/2024072911-CVE-2024-42096-67f3@gregkh/T

Comment 2 Mauro Matteo Cascella 2024-07-30 17:49:39 UTC
Created kernel tracking bugs for this issue:

Affects: fedora-all [bug 2301752]

Comment 132 errata-xmlrpc 2024-09-11 01:01:13 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 9

Via RHSA-2024:6567 https://access.redhat.com/errata/RHSA-2024:6567

Comment 133 errata-xmlrpc 2024-09-24 00:39:52 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2024:7001 https://access.redhat.com/errata/RHSA-2024:7001

Comment 134 errata-xmlrpc 2024-09-24 02:35:20 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2024:7000 https://access.redhat.com/errata/RHSA-2024:7000


Note You need to log in before you can comment on or make changes to this bug.