Received: by 10.213.65.68 with SMTP id h4csp2114492imn; Sun, 8 Apr 2018 20:04:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+SV3d8sHSwOaRZSLlZA/NnvhtorUgXnJmL05rgDVc/AFma2XtuPflVQjluUtNdQ9kmMHjQ X-Received: by 10.99.108.71 with SMTP id h68mr4131107pgc.273.1523243086078; Sun, 08 Apr 2018 20:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243086; cv=none; d=google.com; s=arc-20160816; b=PXM1XUgHaIuiE+eKSx0G9pFdFrJEjBrg00LiTFl3cMxjrAdKYL9aPWeI/YdTZkFKhB OdXx+ACaRyuaPHCv/O4o9o2X6FusQ8ww/QpB6gIEBqsTYco1upnLwQDWnBImhsb6eK6J UiHyOPjFQ1ihby1FUJMbhciWSHOwkYcvkPGsB+Vy/aOm3iDD5IfaGxbusc+ilDDrn11X HIEMlAH614shQc3BKnpm/CVucnJAIpdw2AkSOc7Q5eymXkp1Gy3UFzVsX3LfaB+bmxR3 /yl50vVZSdViAfghuFQ/H5KWN044MKhSMUoWzhuToMKfPmQ0hEpgLgLikS77Mf/uVqjr MqCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=bUgEYplZQBTdXDXdW133r3jkl0ynNJVC9mWCYmZzgTA=; b=YQaG3qoziboUzTv9wBxOQHmfRfRvEo8/Ug+M7400XsWwRcQ7QpWf08QBIkp2AgqaC4 30aSO+1RGJbBFXvLjmf16ID4gC++Z801//rrMRXeslA6K+cLZYjU7CqFCqyuLoH+FUf1 HWTEFdMMzk/353lVrrvKL//CuXAQD4tHPyzMzMhQA5CLuu4OJLu8m5FnEhZFV1Iskpio AVNdRvYiTZ/PjcB/E7MwekWYJFW0DF2rZ9q9QDrf36Ev5PI33LOvvlJpMcSn3jStf8gm cjnEK/j4TcWadCsITgTJ1V4UtL+BN5b/6ygaPPpAcH1/WkUd40shQKLzq67fwBnptNv6 3JZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=V2NbFgvK; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7-v6si13661309plk.397.2018.04.08.20.04.09; Sun, 08 Apr 2018 20:04:46 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=V2NbFgvK; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932530AbeDIAe5 (ORCPT + 99 others); Sun, 8 Apr 2018 20:34:57 -0400 Received: from mail-by2nam01on0123.outbound.protection.outlook.com ([104.47.34.123]:51296 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755715AbeDIAex (ORCPT ); Sun, 8 Apr 2018 20:34:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=bUgEYplZQBTdXDXdW133r3jkl0ynNJVC9mWCYmZzgTA=; b=V2NbFgvK8rNk8xPE08il+vbwbU3egYPfE9TEQmU7BfeMnmn89H9SxNEwA9vx2YOMvK9sY4KZY4n9kg3vYcxRSqi41fovvNnW4Ed5aVt18Bt2NVzzivWL+jTMvwnPnrvC7xTd26fxKmyX0L6e2WW6kX8rO1TsEUxIFYIc8AzeaS8= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0806.namprd21.prod.outlook.com (10.167.107.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:34:46 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:34:46 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Jia Zhang , Al Viro , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , "jolsa@redhat.com" , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 289/293] vfs/proc/kcore, x86/mm/kcore: Fix SMAP fault when dumping vsyscall user page Thread-Topic: [PATCH AUTOSEL for 4.9 289/293] vfs/proc/kcore, x86/mm/kcore: Fix SMAP fault when dumping vsyscall user page Thread-Index: AQHTz5lvhyvmIvO5jUedhnGF1iComg== Date: Mon, 9 Apr 2018 00:26:42 +0000 Message-ID: <20180409002239.163177-289-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0806;7:/KA8Sc/BIpNAXwlYUp5W+9IV55nFrj5AQpONvKOzkwLSYf7zZqINF3R07yWExsnTOi1t/KSaYUQqf2jcUrmMAnJnOZ72X7+a6zA7k1A6LRs76bWaD0KcS1ajnIXH+JzckSFG3C6FCdVvKAwIR7/0LoTUiIKB4oyNjTb4V0hvGfBOkxXLisYvGIDQhM7OlMXH/5VvjQD10a6dEU2pV8KJMPAZHByqJAcBxZrh/q/7/ggfgBU5gParufNLTm3FVJly;20:wf7NM3is2eCECoXXFbzNlCPApGWWBk6oUMeC2eVTcp3+Z1MvTk+DwXMlfl4Xq5C4qZXnS7CY7YIeaOQ4O1twJhBRGd8bYp49keWPTlSlJTRSUoKFpo/mdeXhvsN3JIyjdDQ1wSBkuAawSbVnSKyJR2if0fPRFOtyGg+nBXMK2GE= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 3598ffb7-6e50-4741-017a-08d59db1b1e6 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0806; x-ms-traffictypediagnostic: DM5PR2101MB0806: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(788757137089)(42068640409301)(168385556255192); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0806;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0806; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(396003)(366004)(39380400002)(199004)(189003)(2906002)(25786009)(2501003)(10290500003)(476003)(11346002)(446003)(97736004)(5250100002)(68736007)(2616005)(102836004)(6506007)(3846002)(3660700001)(486006)(3280700002)(305945005)(6666003)(99286004)(5660300001)(76176011)(1076002)(186003)(26005)(7736002)(6116002)(81156014)(81166006)(86612001)(4326008)(105586002)(10090500001)(2900100001)(54906003)(22452003)(316002)(36756003)(110136005)(107886003)(8676002)(6436002)(478600001)(53936002)(66066001)(6486002)(6512007)(6306002)(575784001)(86362001)(966005)(14454004)(72206003)(8936002)(106356001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0806;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: gKnT3VGpY7DQ9rIHpF5/RtSqS+Lv2ZFpCn+NkhNSxz1ASnI4qLBiznh6xdUbRmmcB6uhu833Yl19/Y+IftAfH9ioxT98hTxVcPIHwWYk2VyCZJWe91pvShOlRGWrlGw+d3LnyOXoB2zLxkLQNrMhKorxJkWzK66BnJHsxbvhjMgVOnRP7Q1ahOUYuLIiJvru/qe25IcHTHEk0yqlDiyDAMEG5mhnCzgubpuPLraHkrJYQkuo0cBMRwqKaHujCR7MY8fYgy67njSS5yBhD5BtAK3P1e0KVMnVUBuQglPbkBq3hvcdnpQGrG/YrHcZQsWLcslWys17jtsAnhJD0Wp06lz5fC2T4rGxgGFhCjF4dLgFLgX44qag297mN6NFndCj9oEpA4tMm16l3rsGTjzw/xE8rCA2inLQgQEbfY7DRDg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3598ffb7-6e50-4741-017a-08d59db1b1e6 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:26:42.4884 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0806 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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=3Dy. 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 --- arch/x86/mm/init_64.c | 3 +-- fs/proc/kcore.c | 4 ++++ include/linux/kcore.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 7df8e3a79dc0..d35d0e4bbf99 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1014,8 +1014,7 @@ void __init mem_init(void) after_bootmem =3D 1; =20 /* 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)= ; =20 mem_init_print_info(NULL); } diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index df7e07986ead..7ed961c0124f 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -505,6 +505,10 @@ read_kcore(struct file *file, char __user *buffer, siz= e_t buflen, loff_t *fpos) /* we have to zero-fill user buffer even if no read */ if (copy_to_user(buffer, buf, tsz)) return -EFAULT; + } else if (m->type =3D=3D 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)) { /* diff --git a/include/linux/kcore.h b/include/linux/kcore.h index d92762286645..3ffade4f2798 100644 --- a/include/linux/kcore.h +++ b/include/linux/kcore.h @@ -9,6 +9,7 @@ enum kcore_type { KCORE_VMALLOC, KCORE_RAM, KCORE_VMEMMAP, + KCORE_USER, KCORE_OTHER, }; =20 --=20 2.15.1