All of lore.kernel.org
 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,
	"Kirill A. Shutemov" <kirill@shutemov.name>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
	Alexander Potapenko <glider@google.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	kasan-dev@googlegroups.com
Subject: [PATCH 4.19 70/75] x86/kasan: Fix boot with 5-level paging and KASAN
Date: Mon, 17 Jun 2019 23:10:21 +0200	[thread overview]
Message-ID: <20190617210755.943656383@linuxfoundation.org> (raw)
In-Reply-To: <20190617210752.799453599@linuxfoundation.org>

From: Andrey Ryabinin <aryabinin@virtuozzo.com>

commit f3176ec9420de0c385023afa3e4970129444ac2f upstream.

Since commit d52888aa2753 ("x86/mm: Move LDT remap out of KASLR region on
5-level paging") kernel doesn't boot with KASAN on 5-level paging machines.
The bug is actually in early_p4d_offset() and introduced by commit
12a8cc7fcf54 ("x86/kasan: Use the same shadow offset for 4- and 5-level paging")

early_p4d_offset() tries to convert pgd_val(*pgd) value to a physical
address. This doesn't make sense because pgd_val() already contains the
physical address.

It did work prior to commit d52888aa2753 because the result of
"__pa_nodebug(pgd_val(*pgd)) & PTE_PFN_MASK" was the same as "pgd_val(*pgd)
& PTE_PFN_MASK". __pa_nodebug() just set some high bits which were masked
out by applying PTE_PFN_MASK.

After the change of the PAGE_OFFSET offset in commit d52888aa2753
__pa_nodebug(pgd_val(*pgd)) started to return a value with more high bits
set and PTE_PFN_MASK wasn't enough to mask out all of them. So it returns a
wrong not even canonical address and crashes on the attempt to dereference
it.

Switch back to pgd_val() & PTE_PFN_MASK to cure the issue.

Fixes: 12a8cc7fcf54 ("x86/kasan: Use the same shadow offset for 4- and 5-level paging")
Reported-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: kasan-dev@googlegroups.com
Cc: stable@vger.kernel.org
Cc: <stable@vger.kernel.org>
Link: https://lkml.kernel.org/r/20190614143149.2227-1-aryabinin@virtuozzo.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/mm/kasan_init_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/mm/kasan_init_64.c
+++ b/arch/x86/mm/kasan_init_64.c
@@ -198,7 +198,7 @@ static inline p4d_t *early_p4d_offset(pg
 	if (!pgtable_l5_enabled())
 		return (p4d_t *)pgd;
 
-	p4d = __pa_nodebug(pgd_val(*pgd)) & PTE_PFN_MASK;
+	p4d = pgd_val(*pgd) & PTE_PFN_MASK;
 	p4d += __START_KERNEL_map - phys_base;
 	return (p4d_t *)p4d + p4d_index(addr);
 }



  parent reply	other threads:[~2019-06-17 21:32 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17 21:09 [PATCH 4.19 00/75] 4.19.53-stable review Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 01/75] drm/nouveau: add kconfig option to turn off nouveau legacy contexts. (v3) Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 02/75] nouveau: Fix build with CONFIG_NOUVEAU_LEGACY_CTX_SUPPORT disabled Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 03/75] HID: multitouch: handle faulty Elo touch device Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 04/75] HID: wacom: Dont set tool type until were in range Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 05/75] HID: wacom: Dont report anything prior to the tool entering range Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 06/75] HID: wacom: Send BTN_TOUCH in response to INTUOSP2_BT eraser contact Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 07/75] HID: wacom: Correct button numbering 2nd-gen Intuos Pro over Bluetooth Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 08/75] HID: wacom: Sync INTUOSP2_BT touch state after each frame if necessary Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 09/75] Revert "ALSA: hda/realtek - Improve the headset mic for Acer Aspire laptops" Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 10/75] ALSA: oxfw: allow PCM capture for Stanton SCS.1m Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 11/75] ALSA: hda/realtek - Update headset mode for ALC256 Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 12/75] ALSA: firewire-motu: fix destruction of data for isochronous resources Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 13/75] libata: Extend quirks for the ST1000LM024 drives with NOLPM quirk Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 14/75] mm/list_lru.c: fix memory leak in __memcg_init_list_lru_node Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 15/75] fs/ocfs2: fix race in ocfs2_dentry_attach_lock() Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 16/75] mm/vmscan.c: fix trying to reclaim unevictable LRU page Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 17/75] [PATCH] signal/ptrace: Dont leak unitialized kernel memory with PTRACE_PEEK_SIGINFO Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 18/75] ptrace: restore smp_rmb() in __ptrace_may_access() Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 19/75] iommu/arm-smmu: Avoid constant zero in TLBI writes Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 20/75] i2c: acorn: fix i2c warning Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 21/75] bcache: fix stack corruption by PRECEDING_KEY() Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 22/75] bcache: only set BCACHE_DEV_WB_RUNNING when cached device attached Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 23/75] cgroup: Use css_tryget() instead of css_tryget_online() in task_get_css() Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 24/75] ASoC: cs42xx8: Add regcache mask dirty Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 25/75] ASoC: fsl_asrc: Fix the issue about unsupported rate Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 26/75] drm/i915/sdvo: Implement proper HDMI audio support for SDVO Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 27/75] x86/uaccess, kcov: Disable stack protector Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 28/75] ALSA: seq: Protect in-kernel ioctl calls with mutex Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 29/75] ALSA: seq: Fix race of get-subscription call vs port-delete ioctls Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 30/75] Revert "ALSA: seq: Protect in-kernel ioctl calls with mutex" Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 31/75] s390/kasan: fix strncpy_from_user kasan checks Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 32/75] Drivers: misc: fix out-of-bounds access in function param_set_kgdbts_var Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 33/75] f2fs: fix to avoid accessing xattr across the boundary Greg Kroah-Hartman
2019-06-19 12:32   ` Pavel Machek
2019-06-20  1:46     ` Chao Yu
2019-06-17 21:09 ` [PATCH 4.19 34/75] scsi: qedi: remove memset/memcpy to nfunc and use func instead Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 35/75] scsi: qedi: remove set but not used variables cdev and udev Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 36/75] scsi: lpfc: correct rcu unlock issue in lpfc_nvme_info_show Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 37/75] scsi: lpfc: add check for loss of ndlp when sending RRQ Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 38/75] arm64/mm: Inhibit huge-vmap with ptdump Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 39/75] nvme: fix srcu locking on error return in nvme_get_ns_from_disk Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 40/75] nvme: remove the ifdef around nvme_nvm_ioctl Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 41/75] nvme: merge nvme_ns_ioctl into nvme_ioctl Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 42/75] nvme: release namespace SRCU protection before performing controller ioctls Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 43/75] nvme: fix memory leak for power latency tolerance Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 44/75] platform/x86: pmc_atom: Add Lex 3I380D industrial PC to critclk_systems DMI table Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 45/75] platform/x86: pmc_atom: Add several Beckhoff Automation boards " Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 46/75] scsi: bnx2fc: fix incorrect cast to u64 on shift operation Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 47/75] libnvdimm: Fix compilation warnings with W=1 Greg Kroah-Hartman
2019-06-17 21:09 ` [PATCH 4.19 48/75] selftests: fib_rule_tests: fix local IPv4 address typo Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 49/75] selftests/timers: Add missing fflush(stdout) calls Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 50/75] tracing: Prevent hist_field_var_ref() from accessing NULL tracing_map_elts Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 51/75] usbnet: ipheth: fix racing condition Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 52/75] KVM: arm/arm64: Move cc/it checks under hyps Makefile to avoid instrumentation Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 53/75] KVM: x86/pmu: mask the result of rdpmc according to the width of the counters Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 54/75] KVM: x86/pmu: do not mask the value that is written to fixed PMUs Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 55/75] KVM: s390: fix memory slot handling for KVM_SET_USER_MEMORY_REGION Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 56/75] tools/kvm_stat: fix fields filter for child events Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 57/75] drm/vmwgfx: integer underflow in vmw_cmd_dx_set_shader() leading to an invalid read Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 58/75] drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define() Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 59/75] usb: dwc2: Fix DMA cache alignment issues Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 60/75] usb: dwc2: host: Fix wMaxPacketSize handling (fix webcam regression) Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 61/75] USB: Fix chipmunk-like voice when using Logitech C270 for recording audio Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 62/75] USB: usb-storage: Add new ID to ums-realtek Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 63/75] USB: serial: pl2303: add Allied Telesis VT-Kit3 Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 64/75] USB: serial: option: add support for Simcom SIM7500/SIM7600 RNDIS mode Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 65/75] USB: serial: option: add Telit 0x1260 and 0x1261 compositions Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 66/75] timekeeping: Repair ktime_get_coarse*() granularity Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 67/75] RAS/CEC: Convert the timer callback to a workqueue Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 68/75] RAS/CEC: Fix binary search function Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 69/75] x86/microcode, cpuhotplug: Add a microcode loader CPU hotplug callback Greg Kroah-Hartman
2019-06-17 21:10 ` Greg Kroah-Hartman [this message]
2019-06-17 21:10 ` [PATCH 4.19 71/75] x86/mm/KASLR: Compute the size of the vmemmap section properly Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 72/75] x86/resctrl: Prevent NULL pointer dereference when local MBM is disabled Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 73/75] drm/edid: abstract override/firmware EDID retrieval Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 74/75] drm: add fallback override/firmware EDID modes workaround Greg Kroah-Hartman
2019-06-17 21:10 ` [PATCH 4.19 75/75] rtc: pcf8523: dont return invalid date when battery is low Greg Kroah-Hartman
2019-06-18  2:10 ` [PATCH 4.19 00/75] 4.19.53-stable review kernelci.org bot
2019-06-18  7:44 ` Naresh Kamboju
2019-06-18 13:42 ` shuah
2019-06-18 16:37 ` Guenter Roeck
2019-06-19  8:45 ` Jon Hunter
2019-06-19  8:45   ` Jon Hunter

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=20190617210755.943656383@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=bp@alien8.de \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=hpa@zytor.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.