Bug 2236982 (CVE-2023-4732)

Summary: CVE-2023-4732 kernel: Race between task migrating pages and another task calling exit_mmap to release those same pages getting invalid opcode BUG in include/linux/swapops.h
Product: [Other] Security Response Reporter: Rohit Keshri <rkeshri>
Component: vulnerabilityAssignee: Product Security <prodsec-ir-bot>
Status: NEW --- QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: acaringi, allarkin, bhu, bugzilla_throwaway, chwhite, dbohanno, debarbos, dfreiber, dvlasenk, ezulian, hkrzesin, jarod, jburrell, jdenham, jfaracco, jforbes, jlelli, joe.lawrence, jshortt, jstancek, jwyatt, kcarcia, ldoskova, lgoncalv, lzampier, nmurray, ptalbert, rogbas, rrobaina, rvrbovsk, rysulliv, scweaver, tglozar, tyberry, vkumar, walters, wcosta, williams, wmealing, ycote
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Kernel 5.14-rc1 Doc Type: If docs needed, set a value
Doc Text:
A flaw was found in pfn_swap_entry_to_page in memory management subsystem in the Linux Kernel. In this flaw, an attacker with a local user privilege may cause a denial of service problem due to a BUG statement referencing pmd_t x.
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2231554, 2237947    
Bug Blocks: 2236219    

Description Rohit Keshri 2023-09-02 14:35:45 UTC
A flaw was found in the Linux Kernel's memory management subsytem. In this flaw, A task is exiting and releasing 2MB page in a vma (vm_area_struct) and hits the BUG statement in pfn_swap_entry_to_page() referencing pmd_t x.

    208 static inline struct page *pfn_swap_entry_to_page(swp_entry_t entry)
    209 {
   <omit>
    216         BUG_ON(is_migration_entry(entry) && !PageLocked(p));   <-----  

It finds the entry is of type SWP_MIGRATION_READ and the page is not locked, Another task is calling migrate_pages() on the same addresses and has just completed with the above pmd_t x and is moving to  pmd_t x+1 in try_to_unmap_one().

Comment 1 bugzilla_throwaway 2023-09-04 07:32:40 UTC
Could you please link the fix, if there is one?

Comment 2 Rohit Keshri 2023-09-04 19:41:52 UTC
In reply to comment #1:
> Could you please link the fix, if there is one?

Thank you for reaching to us, the investigation is still in progress, but it seems the issue was seen by the commit 578ede398633 ("userfaultfd: wp: drop _PAGE_UFFD_WP properly when fork"). 

Also it seems that the exploitation is not easy, and will need a special user privilege.

Comment 9 errata-xmlrpc 2023-11-14 15:15:58 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2023:6901 https://access.redhat.com/errata/RHSA-2023:6901

Comment 10 errata-xmlrpc 2023-11-14 15:21:20 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2023:7077 https://access.redhat.com/errata/RHSA-2023:7077

Comment 11 errata-xmlrpc 2023-11-28 15:35:45 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.8 Extended Update Support

Via RHSA-2023:7539 https://access.redhat.com/errata/RHSA-2023:7539

Comment 14 errata-xmlrpc 2024-01-24 16:45:00 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.6 Extended Update Support

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