Received: by 10.192.165.148 with SMTP id m20csp536212imm; Wed, 25 Apr 2018 03:53:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/pp2ulDQM3GC6AqV8cKC6XVsmJ66I4AltbOEwDpq8oUd5K/91Lc156Pgahzlbhz4woKtJL X-Received: by 10.98.103.86 with SMTP id b83mr27547321pfc.76.1524653591787; Wed, 25 Apr 2018 03:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524653591; cv=none; d=google.com; s=arc-20160816; b=XtqVdfT71FISc2M35sDczgQbbkPwjZj9sUSRpati/EAPQufVSZ8u+ufLK05f+U9DPn SiR/eiNY4DcP1+jGhyIjKOzgqyD2aEgw4sBfcoYjJm2ao1xeVgq9Q2YTDJEIJ+I5e75s cAEpuG6V3V0LLMeaWnIgvWkIPjZ8cZMiBKtpG3Alfje+YZCOxK+GyezwmXSRcfDxXBhu TgwwKRhnFGjDRkrJd8zXOaz/JPmQ1plMaeesvf+wp2CKMlaFeMDGXvyd2abJIEiOtaa4 GCJmvJZpY/Xzk3Q7OGySVYHWUwwUOUAoU/NRTZrgIq0mh4jxAmFCDiOOKCKqTs4B8WId Jdnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=aE3Ds4fkmW5dYH4oQL8TNFjRhqJZCXdfEO33/o+GFPU=; b=XEjo1yRSWFFlLqSdeYo6SfP0m7mT7kmM+LQSIBYFlzLIIYRyqGENDTSTDKdPFjdKCn OeMpzOx7R7dITg0uVRg+ZIKj7Imm8WJulOkG7hwACaQD7YsnS5OSsaR93Trg//hg9vJ5 /LhCYielGe+Hg4vHWAgcstrn2t8iJhgF0H0cY1DQr8Xfv63l0EEIuupak7rJEEur7o97 nsaWWpDsRPtjgNagd+YK23t+spgAo2QfE9HYx8KHH+s1pbBv/OBlaveKuHX01PmTn0RX lfWJSUEHnj1F94DSYe5Pml1bZbQbWLr9IOT4PG2vypf0FGRijYGlWEuWeMWZc34t0ogN BTsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10si13014405pgo.58.2018.04.25.03.52.57; Wed, 25 Apr 2018 03:53:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754279AbeDYKv6 (ORCPT + 99 others); Wed, 25 Apr 2018 06:51:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53194 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752020AbeDYKoB (ORCPT ); Wed, 25 Apr 2018 06:44:01 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 703BB36; Wed, 25 Apr 2018 10:44:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia Zhang , Jiri Olsa , Al Viro , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , jolsa@redhat.com, Ingo Molnar , Sasha Levin Subject: [PATCH 4.14 163/183] vfs/proc/kcore, x86/mm/kcore: Fix SMAP fault when dumping vsyscall user page Date: Wed, 25 Apr 2018 12:36:23 +0200 Message-Id: <20180425103249.076681278@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jia Zhang [ Upstream commit 595dd46ebfc10be041a365d0a3fa99df50b6ba73 ] Commit: df04abfd181a ("fs/proc/kcore.c: Add bounce buffer for ktext data") ... introduced a bounce buffer to work around CONFIG_HARDENED_USERCOPY=y. However, accessing the vsyscall user page will cause an SMAP fault. Replace memcpy() with copy_from_user() to fix this bug works, but adding a common way to handle this sort of user page may be useful for future. Currently, only vsyscall page requires KCORE_USER. Signed-off-by: Jia Zhang Reviewed-by: Jiri Olsa Cc: Al Viro Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: jolsa@redhat.com Link: http://lkml.kernel.org/r/1518446694-21124-2-git-send-email-zhang.jia@linux.alibaba.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/init_64.c | 3 +-- fs/proc/kcore.c | 4 ++++ include/linux/kcore.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1180,8 +1180,7 @@ void __init mem_init(void) after_bootmem = 1; /* Register memory areas for /proc/kcore */ - kclist_add(&kcore_vsyscall, (void *)VSYSCALL_ADDR, - PAGE_SIZE, KCORE_OTHER); + kclist_add(&kcore_vsyscall, (void *)VSYSCALL_ADDR, PAGE_SIZE, KCORE_USER); mem_init_print_info(NULL); } --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -510,6 +510,10 @@ read_kcore(struct file *file, char __use /* we have to zero-fill user buffer even if no read */ if (copy_to_user(buffer, buf, tsz)) return -EFAULT; + } else if (m->type == KCORE_USER) { + /* User page is handled prior to normal kernel page: */ + if (copy_to_user(buffer, (char *)start, tsz)) + return -EFAULT; } else { if (kern_addr_valid(start)) { /* --- a/include/linux/kcore.h +++ b/include/linux/kcore.h @@ -10,6 +10,7 @@ enum kcore_type { KCORE_VMALLOC, KCORE_RAM, KCORE_VMEMMAP, + KCORE_USER, KCORE_OTHER, };