stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Fan Yang <Fan_Yang@sjtu.edu.cn>,
	Dan Williams <dan.j.williams@intel.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 5.6 31/43] mm: Fix mremap not considering huge pmd devmap
Date: Fri,  5 Jun 2020 16:15:01 +0200	[thread overview]
Message-ID: <20200605140154.154168800@linuxfoundation.org> (raw)
In-Reply-To: <20200605140152.493743366@linuxfoundation.org>

From: Fan Yang <Fan_Yang@sjtu.edu.cn>

commit 5bfea2d9b17f1034a68147a8b03b9789af5700f9 upstream.

The original code in mm/mremap.c checks huge pmd by:

		if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd)) {

However, a DAX mapped nvdimm is mapped as huge page (by default) but it
is not transparent huge page (_PAGE_PSE | PAGE_DEVMAP).  This commit
changes the condition to include the case.

This addresses CVE-2020-10757.

Fixes: 5c7fb56e5e3f ("mm, dax: dax-pmd vs thp-pmd vs hugetlbfs-pmd")
Cc: <stable@vger.kernel.org>
Reported-by: Fan Yang <Fan_Yang@sjtu.edu.cn>
Signed-off-by: Fan Yang <Fan_Yang@sjtu.edu.cn>
Tested-by: Fan Yang <Fan_Yang@sjtu.edu.cn>
Tested-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/include/asm/pgtable.h |    1 +
 mm/mremap.c                    |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -256,6 +256,7 @@ static inline int pmd_large(pmd_t pte)
 }
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
+/* NOTE: when predicate huge page, consider also pmd_devmap, or use pmd_large */
 static inline int pmd_trans_huge(pmd_t pmd)
 {
 	return (pmd_val(pmd) & (_PAGE_PSE|_PAGE_DEVMAP)) == _PAGE_PSE;
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -266,7 +266,7 @@ unsigned long move_page_tables(struct vm
 		new_pmd = alloc_new_pmd(vma->vm_mm, vma, new_addr);
 		if (!new_pmd)
 			break;
-		if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd)) {
+		if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd) || pmd_devmap(*old_pmd)) {
 			if (extent == HPAGE_PMD_SIZE) {
 				bool moved;
 				/* See comment in move_ptes() */



  parent reply	other threads:[~2020-06-05 14:17 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 14:14 [PATCH 5.6 00/43] 5.6.17-rc1 review Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 01/43] x86/syscalls: Revert "x86/syscalls: Make __X32_SYSCALL_BIT be unsigned long" Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 02/43] Revert "cgroup: Add memory barriers to plug cgroup_rstat_updated() race window" Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 03/43] ARC: Fix ICCM & DCCM runtime size checks Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 04/43] ARC: [plat-eznps]: Restrict to CONFIG_ISA_ARCOMPACT Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 05/43] efi/libstub: Avoid returning uninitialized data from setup_graphics() Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 06/43] evm: Fix RCU list related warnings Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 07/43] scsi: pm: Balance pm_only counter of request queue during system resume Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 08/43] efi/earlycon: Fix early printk for wider fonts Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 09/43] x86/hyperv: Properly suspend/resume reenlightenment notifications Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 10/43] dmaengine: ti: k3-udma: Fix TR mode flags for slave_sg and memcpy Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 11/43] i2c: altera: Fix race between xfer_msg and isr thread Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 12/43] io_uring: initialize ctx->sqo_wait earlier Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 13/43] io_uring: dont prepare DRAIN reqs twice Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 14/43] io_uring: fix FORCE_ASYNC req preparation Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 15/43] net: phy: propagate an error back to the callers of phy_sfp_probe Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 16/43] x86/mmiotrace: Use cpumask_available() for cpumask_var_t variables Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 17/43] net: bmac: Fix read of MAC address from ROM Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 18/43] drm/edid: Add Oculus Rift S to non-desktop list Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 19/43] s390/mm: fix set_huge_pte_at() for empty ptes Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 20/43] io_uring: reset -EBUSY error when io sq thread is waken up Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 21/43] drm/amd/display: DP training to set properly SCRAMBLING_DISABLE Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 22/43] riscv: Fix print_vm_layout build error if NOMMU Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 23/43] wireguard: selftests: use newer iproute2 for gcc-10 Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 24/43] null_blk: return error for invalid zone size Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 25/43] net: ethernet: ti: fix some return value check of cpsw_ale_create() Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 26/43] net/ethernet/freescale: rework quiesce/activate for ucc_geth Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 27/43] net: ethernet: stmmac: Enable interface clocks on probe for IPQ806x Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 28/43] selftests: mlxsw: qos_mc_aware: Specify arping timeout as an integer Greg Kroah-Hartman
2020-06-05 14:14 ` [PATCH 5.6 29/43] net: Fix return value about devm_platform_ioremap_resource() Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 30/43] net: smsc911x: Fix runtime PM imbalance on error Greg Kroah-Hartman
2020-06-05 14:15 ` Greg Kroah-Hartman [this message]
2020-06-05 14:15 ` [PATCH 5.6 32/43] HID: sony: Fix for broken buttons on DS3 USB dongles Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 33/43] HID: multitouch: enable multi-input as a quirk for some devices Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 34/43] HID: i2c-hid: add Schneider SCL142ALM to descriptor override Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 35/43] p54usb: add AirVasT USB stick device-id Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 36/43] mt76: mt76x02u: Add support for newer versions of the XBox One wifi adapter Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 37/43] crypto: api - Fix use-after-free and race in crypto_spawn_alg Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 38/43] kernel/relay.c: handle alloc_percpu returning NULL in relay_open Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 39/43] mmc: fix compilation of user API Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 40/43] media: Revert "staging: imgu: Address a compiler warning on alignment" Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 41/43] media: staging: ipu3-imgu: Move alignment attribute to field Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 42/43] net: dsa: mt7530: set CPU port to fallback mode Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 5.6 43/43] airo: Fix read overflows sending packets Greg Kroah-Hartman
2020-06-05 15:30 ` [PATCH 5.6 00/43] 5.6.17-rc1 review Shuah Khan
2020-06-05 15:48   ` Greg Kroah-Hartman
2020-06-05 22:13 ` Shuah Khan
2020-06-06  6:27 ` Jon Hunter
2020-06-06 13:34 ` Guenter Roeck
2020-06-06 16:12 ` Naresh Kamboju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200605140154.154168800@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=Fan_Yang@sjtu.edu.cn \
    --cc=dan.j.williams@intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).