From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A0361A3161 for ; Wed, 26 Feb 2025 01:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535060; cv=none; b=gHRpWBaWLcsM1tzePDNSCAnbkI9qXxz9vpzw0qjgrfFstJS1fUfi9+hWOXd/sdq32V0gugJSnU5VjHoxTodMLGqlp0qTAC+7MIJv4YKStfS5JDQFg3bDQDh7IlEdZbYZjKUvq6Kd5gR7L+W+rv24AF3rl5FgWvYeJ+fOaXnNivo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535060; c=relaxed/simple; bh=Bqy95XF6zg8OJ8rQspHucWKpH27t5BMyxBpw8i0owRc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FiJcvzAnV2BbGf/8A8+3vK/GRIn6be4O4c3MPImylbgsRi98SZiMKD5yScx99T7fpEsr7worUqVsDRz3or91GK05VEBnYVCUwhwh0kNlAzReSwWpKG7ZIC54o7m1b5Ve7+1l1knTiwuWbORD7XKoAdyJAGDkFLLhe1t+p24yXBU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Bi7hnaCX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Bi7hnaCX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E27A7C4CEDD; Wed, 26 Feb 2025 01:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740535060; bh=Bqy95XF6zg8OJ8rQspHucWKpH27t5BMyxBpw8i0owRc=; h=From:To:Cc:Subject:Date:Reply-to:From; b=Bi7hnaCXzzcZQguIcXBMUS60gil2iMcTvxWAtOEobOnZvIv1eX3LFyDaMO/xTHGT9 JaydtT8+EXpFnqJSww/hKiZMaTn08C6FKqJIuAsxM1lwPj6GoRQ27jpOsS55bwG9RB DvhMSHwxSN5v74QeqMRHPHI45bawGSuSG1Lfgs9o= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49052: mm: fix unexpected zeroed page mapping with zram swap Date: Wed, 26 Feb 2025 02:54:17 +0100 Message-ID: <2025022651-CVE-2022-49052-4ea2@gregkh> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=4731; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=Bqy95XF6zg8OJ8rQspHucWKpH27t5BMyxBpw8i0owRc=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7SgymbW3c735TS/sHV9uFOcnvzFpnl25duWqvldhap u5rW7nedsSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEXk9gmO/pHZpg7Sw0pfWD s3xTwPEFe3Pi3RgWdLfcVZ20R/poYrpI2PzJ++7cf/4sCwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: mm: fix unexpected zeroed page mapping with zram swap Two processes under CLONE_VM cloning, user process can be corrupted by seeing zeroed page unexpectedly. CPU A CPU B do_swap_page do_swap_page SWP_SYNCHRONOUS_IO path SWP_SYNCHRONOUS_IO path swap_readpage valid data swap_slot_free_notify delete zram entry swap_readpage zeroed(invalid) data pte_lock map the *zero data* to userspace pte_unlock pte_lock if (!pte_same) goto out_nomap; pte_unlock return and next refault will read zeroed data The swap_slot_free_notify is bogus for CLONE_VM case since it doesn't increase the refcount of swap slot at copy_mm so it couldn't catch up whether it's safe or not to discard data from backing device. In the case, only the lock it could rely on to synchronize swap slot freeing is page table lock. Thus, this patch gets rid of the swap_slot_free_notify function. With this patch, CPU A will see correct data. CPU A CPU B do_swap_page do_swap_page SWP_SYNCHRONOUS_IO path SWP_SYNCHRONOUS_IO path swap_readpage original data pte_lock map the original data swap_free swap_range_free bd_disk->fops->swap_slot_free_notify swap_readpage read zeroed data pte_unlock pte_lock if (!pte_same) goto out_nomap; pte_unlock return on next refault will see mapped data by CPU B The concern of the patch would increase memory consumption since it could keep wasted memory with compressed form in zram as well as uncompressed form in address space. However, most of cases of zram uses no readahead and do_swap_page is followed by swap_free so it will free the compressed form from in zram quickly. The Linux kernel CVE team has assigned CVE-2022-49052 to this issue. Affected and fixed versions =========================== Issue introduced in 4.15 with commit 0bcac06f27d7528591c27ac2b093ccd71c5d0168 and fixed in 4.19.242 with commit f86d55cf616199404c05f5b0c5c41b17351baa02 Issue introduced in 4.15 with commit 0bcac06f27d7528591c27ac2b093ccd71c5d0168 and fixed in 5.4.193 with commit f098f8b9820fe3f2e41aefc4329dfe8a3859d1c1 Issue introduced in 4.15 with commit 0bcac06f27d7528591c27ac2b093ccd71c5d0168 and fixed in 5.10.112 with commit 20ed94f8181a25212e7404e44958e234f407624b Issue introduced in 4.15 with commit 0bcac06f27d7528591c27ac2b093ccd71c5d0168 and fixed in 5.15.35 with commit 12ba1d38115a101c45d8e0ca3aa1181fd148e57f Issue introduced in 4.15 with commit 0bcac06f27d7528591c27ac2b093ccd71c5d0168 and fixed in 5.17.4 with commit afac4b88699a06c8b9369f9d759a1ec3c254b788 Issue introduced in 4.15 with commit 0bcac06f27d7528591c27ac2b093ccd71c5d0168 and fixed in 5.18 with commit e914d8f00391520ecc4495dd0ca0124538ab7119 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-49052 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: mm/page_io.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/f86d55cf616199404c05f5b0c5c41b17351baa02 https://git.kernel.org/stable/c/f098f8b9820fe3f2e41aefc4329dfe8a3859d1c1 https://git.kernel.org/stable/c/20ed94f8181a25212e7404e44958e234f407624b https://git.kernel.org/stable/c/12ba1d38115a101c45d8e0ca3aa1181fd148e57f https://git.kernel.org/stable/c/afac4b88699a06c8b9369f9d759a1ec3c254b788 https://git.kernel.org/stable/c/e914d8f00391520ecc4495dd0ca0124538ab7119