From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Laszlo Ersek <lersek@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Andy Lutomirski <luto@amacapital.net>,
Matt Fleming <matt.fleming@intel.com>
Subject: [PATCH 4.2 031/110] x86/setup: Extend low identity map to cover whole kernel range
Date: Fri, 6 Nov 2015 11:18:38 -0800 [thread overview]
Message-ID: <20151106191704.836904806@linuxfoundation.org> (raw)
In-Reply-To: <20151106191703.247930828@linuxfoundation.org>
4.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Bonzini <pbonzini@redhat.com>
commit f5f3497cad8c8416a74b9aaceb127908755d020a upstream.
On 32-bit systems, the initial_page_table is reused by
efi_call_phys_prolog as an identity map to call
SetVirtualAddressMap. efi_call_phys_prolog takes care of
converting the current CPU's GDT to a physical address too.
For PAE kernels the identity mapping is achieved by aliasing the
first PDPE for the kernel memory mapping into the first PDPE
of initial_page_table. This makes the EFI stub's trick "just work".
However, for non-PAE kernels there is no guarantee that the identity
mapping in the initial_page_table extends as far as the GDT; in this
case, accesses to the GDT will cause a page fault (which quickly becomes
a triple fault). Fix this by copying the kernel mappings from
swapper_pg_dir to initial_page_table twice, both at PAGE_OFFSET and at
identity mapping.
For some reason, this is only reproducible with QEMU's dynamic translation
mode, and not for example with KVM. However, even under KVM one can clearly
see that the page table is bogus:
$ qemu-system-i386 -pflash OVMF.fd -M q35 vmlinuz0 -s -S -daemonize
$ gdb
(gdb) target remote localhost:1234
(gdb) hb *0x02858f6f
Hardware assisted breakpoint 1 at 0x2858f6f
(gdb) c
Continuing.
Breakpoint 1, 0x02858f6f in ?? ()
(gdb) monitor info registers
...
GDT= 0724e000 000000ff
IDT= fffbb000 000007ff
CR0=0005003b CR2=ff896000 CR3=032b7000 CR4=00000690
...
The page directory is sane:
(gdb) x/4wx 0x32b7000
0x32b7000: 0x03398063 0x03399063 0x0339a063 0x0339b063
(gdb) x/4wx 0x3398000
0x3398000: 0x00000163 0x00001163 0x00002163 0x00003163
(gdb) x/4wx 0x3399000
0x3399000: 0x00400003 0x00401003 0x00402003 0x00403003
but our particular page directory entry is empty:
(gdb) x/1wx 0x32b7000 + (0x724e000 >> 22) * 4
0x32b7070: 0x00000000
[ It appears that you can skate past this issue if you don't receive
any interrupts while the bogus GDT pointer is loaded, or if you avoid
reloading the segment registers in general.
Andy Lutomirski provides some additional insight:
"AFAICT it's entirely permissible for the GDTR and/or LDT
descriptor to point to unmapped memory. Any attempt to use them
(segment loads, interrupts, IRET, etc) will try to access that memory
as if the access came from CPL 0 and, if the access fails, will
generate a valid page fault with CR2 pointing into the GDT or
LDT."
Up until commit 23a0d4e8fa6d ("efi: Disable interrupts around EFI
calls, not in the epilog/prolog calls") interrupts were disabled
around the prolog and epilog calls, and the functional GDT was
re-installed before interrupts were re-enabled.
Which explains why no one has hit this issue until now. ]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
[ Updated changelog. ]
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/x86/kernel/setup.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1198,6 +1198,14 @@ void __init setup_arch(char **cmdline_p)
clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,
swapper_pg_dir + KERNEL_PGD_BOUNDARY,
KERNEL_PGD_PTRS);
+
+ /*
+ * sync back low identity map too. It is used for example
+ * in the 32-bit EFI stub.
+ */
+ clone_pgd_range(initial_page_table,
+ swapper_pg_dir + KERNEL_PGD_BOUNDARY,
+ KERNEL_PGD_PTRS);
#endif
tboot_probe();
next prev parent reply other threads:[~2015-11-06 19:22 UTC|newest]
Thread overview: 113+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-06 19:18 [PATCH 4.2 000/110] 4.2.6-stable review Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 001/110] mac80211: Fix hwflags debugfs file format Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 002/110] ath9k: declare required extra tx headroom Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 003/110] mmc: core: Fix init_card in 52Mhz Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 004/110] iwlwifi: dvm: fix D3 firmware PN programming Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 005/110] iwlwifi: fix firmware filename for 3160 Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 006/110] rtlwifi: rtl8821ae: Fix system lockups on boot Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 007/110] iwlwifi: mvm: clear csa countdown when AP is stopped Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 008/110] iwlwifi: mvm: fix D3 CCMP TX PN assignment Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 009/110] iwlwifi: mvm: fix D3 firmware PN programming Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 010/110] iwlwifi: mvm: init card correctly on ctkill exit check Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 011/110] iwlwifi: mvm: flush fw_dump_wk when mvm fails to start Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 012/110] iwlwifi: pci: add a few more PCI subvendor IDs for the 7265 series Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 013/110] iommu/vt-d: fix range computation when making room for large pages Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 014/110] iommu/amd: Fix BUG when faulting a PROT_NONE VMA Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 015/110] iommu/amd: Dont clear DTE flags when modifying it Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 016/110] powerpc/rtas: Validate rtas.entry before calling enter_rtas() Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 017/110] drm: fix mutex leak in drm_dp_get_mst_branch_device Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 018/110] drm: Correct arguments to list_tail_add in create blob ioctl Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 019/110] drm: crtc: integer overflow in drm_property_create_blob() Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 020/110] [media] m88ds3103: use own reg update_bits() implementation Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 021/110] [media] si2157: Bounds check firmware Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 022/110] [media] si2168: " Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 023/110] [media] rtl28xxu: fix control message flaws Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 024/110] KVM: arm: use GIC support unconditionally Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 025/110] ALSA: hdac: Explicitly add io.h Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 026/110] ALSA: hda - Fix inverted internal mic on Lenovo G50-80 Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 027/110] ALSA: hda - Fix deadlock at error in building PCM Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 028/110] ASoC: Add info callback for SX_TLV controls Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 029/110] ASoC: wm8904: Correct number of EQ registers Greg Kroah-Hartman
2015-11-06 19:18 ` Greg Kroah-Hartman [this message]
2015-11-06 19:33 ` [PATCH 4.2 031/110] x86/setup: Extend low identity map to cover whole kernel range Borislav Petkov
2015-11-06 19:48 ` Greg Kroah-Hartman
2015-11-13 9:20 ` Borislav Petkov
2015-12-07 7:29 ` Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 032/110] x86/ioapic: Prevent NULL pointer dereference in setup_ioapic_dest() Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 033/110] mm: make sendfile(2) killable Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 034/110] fault-inject: fix inverted interval/probability values in printk Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 035/110] tracing: Have stack tracer force RCU to be watching Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 036/110] bus: arm-ccn: Fix irq affinity setting on CPU migration Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 037/110] drm/nouveau/gem: return only valid domain when theres only one Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 038/110] drm/radeon/dpm: dont add pwm attributes if DPM is disabled Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 039/110] drm/amdgpu: add missing dpm check for KV dpm late init Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 043/110] drm/radeon: dont try to recreate sysfs entries on resume Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 044/110] drm/amdgpu: " Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 048/110] iio: st_accel: fix interrupt handling on LIS3LV02 Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 049/110] iio: accel: sca3000: memory corruption in sca3000_read_first_n_hw_rb() Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 050/110] rbd: require stable pages if message data CRCs are enabled Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 051/110] rbd: dont leak parent_spec in rbd_dev_probe_parent() Greg Kroah-Hartman
2015-11-06 19:18 ` [PATCH 4.2 052/110] rbd: prevent kernel stack blow up on rbd map Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 053/110] ARM: EXYNOS: Fix double of_node_put() when parsing child power domains Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 054/110] ARM: orion: Fix DSA platform device after mvmdio conversion Greg Kroah-Hartman
2015-11-06 19:32 ` Florian Fainelli
2015-11-06 19:19 ` [PATCH 4.2 055/110] ARM: mvebu: correct a385-db-ap compatible string Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 056/110] ARM: dts: berlin: change BG2Qs USB PHY compatible Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 057/110] ARM: dts: Fix audio card detection on Peach boards Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 058/110] ARM: dts: imx7d: Fix UART2 base address Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 059/110] ARM: dts: am57xx-beagle-x15: set VDD_SD to always-on Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 060/110] ARM: ux500: modify initial levelshifter status Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 061/110] ARM: OMAP1: fix incorrect INT_DMA_LCD Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 062/110] ARM: 8445/1: fix vdsomunge not to depend on glibc specific byteswap.h Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 063/110] ARM: 8449/1: fix bug in vdsomunge swab32 macro Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 064/110] Revert "ARM64: unwind: Fix PC calculation" Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 065/110] arm64: kernel: fix tcr_el1.t0sz restore on systems with extended idmap Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 066/110] block: dont release bdi while request_queue has live references Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 067/110] dm btree remove: fix a bug when rebalancing nodes after removal Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 068/110] dm cache: the CLEAN_SHUTDOWN flag was not being set Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 069/110] dm btree: fix leak of bufio-backed block in btree_split_beneath error path Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 070/110] nvme: fix 32-bit build warning Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 071/110] Revert "serial: 8250_dma: dont bother DMA with small transfers" Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 073/110] i2c: mv64xxx: really allow I2C offloading Greg Kroah-Hartman
2015-11-07 16:26 ` Ben Hutchings
2015-11-06 19:19 ` [PATCH 4.2 074/110] clkdev: fix clk_add_alias() with a NULL alias device name Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 075/110] fbcon: initialize blink interval before calling fb_set_par Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 076/110] xhci: handle no ping response error properly Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 077/110] xhci: Add spurious wakeup quirk for LynxPoint-LP controllers Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 078/110] xen-blkfront: check for null drvdata in blkback_changed (XenbusStateClosing) Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 079/110] module: Fix locking in symbol_put_addr() Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 080/110] PCI: Prevent out of bounds access in numa_node override Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 081/110] ovl: free stack of paths in ovl_fill_super Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 082/110] ovl: free lower_mnt array in ovl_put_super Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 083/110] ovl: use O_LARGEFILE in ovl_copy_up() Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 084/110] ovl: fix dentry reference leak Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 085/110] ovl: fix open in stacked overlay Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 087/110] crypto: api - Only abort operations on fatal signal Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 088/110] md/raid1: submit_bio_wait() returns 0 on success Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 089/110] md/raid10: " Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 090/110] md/raid5: fix locking in handle_stripe_clean_event() Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 091/110] Revert "md: allow a partially recovered device to be hot-added to an array." Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 092/110] EDAC, sb_edac: Fix TAD presence check for sbridge_mci_bind_devs() Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 093/110] irqchip/tegra: Propagate IRQ type setting to parent Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 095/110] netfilter: ipset: Fix sleeping memory allocation in atomic context Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 096/110] btrfs: fix possible leak in btrfs_ioctl_balance() Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 097/110] kvm: irqchip: fix memory leak Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 098/110] thermal: exynos: Fix register read in TMU Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 099/110] um: Fix kernel mode fault condition Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 100/110] blk-mq: fix use-after-free in blk_mq_free_tag_set() Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 101/110] IB/cm: Fix rb-tree duplicate free and use-after-free Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 102/110] sched/deadline: Fix migration of SCHED_DEADLINE tasks Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 103/110] cpufreq: intel_pstate: Fix divide by zero on Knights Landing (KNL) Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 104/110] arm64: compat: fix stxr failure case in SWP emulation Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 105/110] NVMe: Fix memory leak on retried commands Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 106/110] drm/vmwgfx: Fix up user_dmabuf refcounting Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 107/110] thp: use is_zero_pfn() only after pte_present() check Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 108/110] pinctrl: baytrail: Serialize all register access Greg Kroah-Hartman
2015-11-08 9:38 ` Ben Hutchings
2015-11-06 19:19 ` [PATCH 4.2 109/110] pinctrl: baytrail: Use raw_spinlock for locking Greg Kroah-Hartman
2015-11-06 19:19 ` [PATCH 4.2 110/110] xen: fix backport of previous kexec patch Greg Kroah-Hartman
2015-11-07 1:45 ` [PATCH 4.2 000/110] 4.2.6-stable review Guenter Roeck
2015-11-07 2:44 ` Greg Kroah-Hartman
2015-11-07 2:53 ` Shuah Khan
2015-11-07 3:00 ` Greg Kroah-Hartman
2015-11-09 9:27 ` Sudip Mukherjee
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=20151106191704.836904806@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=lersek@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=matt.fleming@intel.com \
--cc=mingo@kernel.org \
--cc=pbonzini@redhat.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
/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).