Received: by 10.213.65.68 with SMTP id h4csp2120079imn; Sun, 8 Apr 2018 20:12:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx48pnHxFlewRpo7z+z6c3EaGR17HNqYSiwwIK2/73ZHIkt2ROHifWovBoe3Xuxe8kVcMiD9k X-Received: by 10.98.201.15 with SMTP id k15mr27695558pfg.184.1523243521905; Sun, 08 Apr 2018 20:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243521; cv=none; d=google.com; s=arc-20160816; b=N10DzrLbVtxvqpzkxYa3HWcta4AXpA8SDeROwfzwsEZu0LUoKfY3Hpp4BW+Ccu0nSH dpysiBhzYqX97Wljv/K8lpKkt8gQBZuU3jwtAcVVVR66Au2OESb0bi0ZbVrow/6juGyu B+Lo6IrtRLWfk3f/9my0w0mQRGLXJPvQhR/c5lwLcYi+zOBF8DGgjPDcPbEzuJpBpj7O cyhz5ngYObz9g7061+PIVyenFd87TrHIP5sXTjscyOi+KlKAf3WcI7DO9KSuJRQUoOZv eEckPCiU3emMc4kBQUTvVHddVAsoULiHYgr3Wk3yBfSv+vt0+VkMptilrKeHOagXHGRi SO0Q== 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=EX+6U/2Kurz3He+Y7Lo37MR+RlBwaqJbp1fSu6ScrOI=; b=SKUGPt8XCUDc/rNTGLU4H8KlVt1El3ub0RFIgRrB5nlN1iBBcpzPWZ2SurG6n/KoG/ 8kB6NWHUFy7cm6AgnhnR9LCWdQyGUbhnHE1ARD/963/UOv+OYkk6+qzBi0hM+dIWVAtz iaFT2cmXA60BZvKd3A+enVMHwmCUSV2G6fXlAL7HmOCKV4NH5QbEy96Pot2upMhYQUmi +wB9d84GkRtyKqrGRgekJxnZMUdWoIgI5sUXjZHaI+gNwHgyPeHjge+ZBf1W2i2haYgK XUO5LiPwT09wZ1jHsPReVSwMOTfLi4ORrlL+dXSOI3F2IWTGM19TDtBtChcZMKHgzy68 0bUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=G0LNojp8; 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 j21si12025655pfe.132.2018.04.08.20.11.25; Sun, 08 Apr 2018 20:12:01 -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=G0LNojp8; 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 S1755757AbeDICu4 (ORCPT + 98 others); Sun, 8 Apr 2018 22:50:56 -0400 Received: from mail-by2nam03on0131.outbound.protection.outlook.com ([104.47.42.131]:4960 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755311AbeDIA0e (ORCPT ); Sun, 8 Apr 2018 20:26:34 -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=EX+6U/2Kurz3He+Y7Lo37MR+RlBwaqJbp1fSu6ScrOI=; b=G0LNojp8t+KmXaR9l4DNLN2m86bz8O+2Vj/YQQMasLnfnH7tTGO5YFIVa/I0Goev6X5C5iZh9DXD6ygLIi4suXRfrHUPlFDF2Dqr3/ZYBYWowH94eEypD6jNEAENHD0l4yv2dta1YGH0sA1NcrMH6RADzg6UQrq8mUvsn7C6xFk= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0725.namprd21.prod.outlook.com (10.167.107.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:26:23 +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:26:23 +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.14 153/161] vfs/proc/kcore, x86/mm/kcore: Fix SMAP fault when dumping vsyscall user page Thread-Topic: [PATCH AUTOSEL for 4.14 153/161] vfs/proc/kcore, x86/mm/kcore: Fix SMAP fault when dumping vsyscall user page Thread-Index: AQHTz5jFiloHpnDSuE6bCLUXniuigg== Date: Mon, 9 Apr 2018 00:21:58 +0000 Message-ID: <20180409001936.162706-153-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-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;DM5PR2101MB0725;7:Mbl/B000tmii6C83HVQJaC8RzQdbtwTaXC0llEl87hzqy+WJwleL8+R2kSVhX836MeqpGO/wmfq6B6XS+WafSZNqliHWDjt/uTt23FFcE3ILJqAW8noL1mBKeMKjjzkMB4Se3lcuC+DkyJUfiV5Az4Yy4JI1Y7OK5oA8eDmt0m/MAWTPUJxfsNzh3Q52zDGLCMFtev7tHw6ItAhrx+bc3lALxH7C7Az87692QSyV5NCJV7147cdS1+xU9acV/Hq0;20:5VpqM5p7LkfOO5LollkI/P5rp0ZnK5gLZZ8O8uuo3diIN0CAhF52mjxmt2PAOiS6W5lu8IM99nLGYaSatmZZZMEDkRpGNS3RPgj1iqsNUvgdEA0wMsfUOxfyrZ1E9mlofOMwJ2CWKZpB+fO5lc/Gxla1+eTcz+v+xA46WIIbIBM= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 21ff6ae6-000d-44fd-ab05-08d59db08667 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0725; x-ms-traffictypediagnostic: DM5PR2101MB0725: 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)(5005006)(8121501046)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0725;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0725; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(366004)(376002)(396003)(39860400002)(199004)(189003)(6486002)(81166006)(26005)(6512007)(6306002)(4326008)(6666003)(6436002)(81156014)(8676002)(97736004)(186003)(36756003)(72206003)(53936002)(107886003)(2906002)(966005)(86362001)(76176011)(110136005)(305945005)(10090500001)(486006)(3660700001)(102836004)(5660300001)(14454004)(476003)(575784001)(86612001)(446003)(99286004)(68736007)(66066001)(11346002)(54906003)(2616005)(1076002)(7736002)(5250100002)(25786009)(8936002)(478600001)(2900100001)(2501003)(3280700002)(105586002)(316002)(106356001)(22452003)(6506007)(3846002)(10290500003)(6116002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0725;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: 6bNtABwiTtKAHEyPWAAUMAo8bqFkf08XLL629SceXWhAWUT73hcxMreXVAl/fWjpElxah144PM8ecy1P7m06qoXjcrMbUW2WOcXuuYgkvmofqJRye8yvqEnIquho2uYKtooruWmZmRF9OySEzrnp7QBda/AKcq7LlU5w+goKaVV6qV5km+HIqsCe8jPeBZU0OOmr7WGHP9D1/RwHWNBIwCpnihhMH283yD0kwJ4r7KfN9X7iOS3J3FqWlRu07nO+FEz3JkJ59lqpBddkDZXHuFSSpohQW3H5yAIPL41qH505dEv9q+4CNMMX3xVZU/NMHi77JdwfufzAglbBIWjg4bpgsaWYw2SjmZSdRoxDi1l1Dq6z0ev5c42R6tUgL+8/koOZpjRhMHYtfgthiMtM/DnfuS12YPGEmH6rWAIYSUs= 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: 21ff6ae6-000d-44fd-ab05-08d59db08667 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:21:58.6279 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0725 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 fe85d1204db8..642357aff216 100644 --- 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 =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 e8a93bc8285d..d1e82761de81 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -510,6 +510,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 7ff25a808fef..80db19d3a505 100644 --- 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, }; =20 --=20 2.15.1