Received: by 10.223.176.5 with SMTP id f5csp2100284wra; Wed, 31 Jan 2018 17:03:40 -0800 (PST) X-Google-Smtp-Source: AH8x225VwkxIjBrzip98xWwswATQU5SwyeZRySJBQW9MDiNAU63PWejHf6FpI/jo8b5IkajTWmeD X-Received: by 10.101.69.7 with SMTP id n7mr27986430pgq.62.1517447020781; Wed, 31 Jan 2018 17:03:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517447020; cv=none; d=google.com; s=arc-20160816; b=AFJnCoRTPv+uaS3Q1YtmZUO5MF7OIBwUUe7+iDAa/uBGET+VHeEPezKxZyCo5PKzn7 ufm3v/F9vjCBuFn6ydxzTTKLrlAXF9r1XeuNVe5v+aTzkZDSYLwB+MEOv67GdsKXPk/i ZiCkp0hE+cVp66V6XJWXn+snzwQO3tKfjlRtmHDlSkyhT0VzJQ9zrc/BV0qD5w+a7Iru MvknW8Vjw1XiSAAyE8uiJ/uy7ekJifl+ea5zWsbTGnKoWgEFzPBUCT3S+752ZcBfQedn H935VBl/8sEgxR9fF9Kzz3cgvoR9QMBUk6I60lfiZwKFMFDYj1C4HN1D8dvUn2aHe0Bv toRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=V0diins78JaVIxqpaeoUYNu8BwHZZXWO4lvRcz/CCjI=; b=MEkGA0PBQ/j/4wxhka7miWbxeOWEaYNnoMKR3F4t79PkuznqwFBZGET9JIRQUnx3fI Ag/Oyn1F5vj7y3e/0/d1Emjm7oR08tyPcA02jLgkegAfdqoybn6hbkUb0Ok0trjF2+Ug a03ex1rdu9FSoMKF1vTfsshGd94a2Rq1xRXOeDYpFxiVqQDj6a2KAeI3t4eyrhoDAgcs E0Odowev+Qrvf/ap8loSAbEHF31TYH678chDTKnQ/pO4d3zd/4xY51klGCd5OnYOeP1e 8LEUCPX2q8uvDVLE3xaZuflCcVWvpnfrF1gdQiJZfxFUZB4s6t4/iG1d9Y70m8RZM93a yGWQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16-v6si806162plm.392.2018.01.31.17.03.26; Wed, 31 Jan 2018 17:03:40 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932141AbeBABDD (ORCPT + 99 others); Wed, 31 Jan 2018 20:03:03 -0500 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:56385 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754559AbeBABDA (ORCPT ); Wed, 31 Jan 2018 20:03:00 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04452;MF=zhang.jia@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0SxSki19_1517446964; Received: from ali-6c96cfd98fb5.local(mailfrom:zhang.jia@linux.alibaba.com fp:106.11.34.19) by smtp.aliyun-inc.com(127.0.0.1); Thu, 01 Feb 2018 09:02:45 +0800 Subject: Re: [PATCH 1/2] /proc/kcore: Fix SMAP violation when dumping vsyscall user page To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org References: <1517294579-117473-1-git-send-email-zhang.jia@linux.alibaba.com> From: Jia Zhang Message-ID: <2166a2cd-be40-ff3f-409d-7f32af4a7a10@linux.alibaba.com> Date: Thu, 1 Feb 2018 09:03:11 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1517294579-117473-1-git-send-email-zhang.jia@linux.alibaba.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Are there any comments here? Thanks, Jia On 2018/1/30 下午2:42, Jia Zhang wrote: > The commit df04abfd181a > ("fs/proc/kcore.c: Add bounce buffer for ktext data") introduces a > bounce buffer to work around CONFIG_HARDENED_USERCOPY=y. However, > accessing vsyscall user page will cause SMAP violation in this way. > > In order to fix this issue, simply replace memcpy() with copy_from_user() > may work, but using 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 > --- > arch/x86/mm/init_64.c | 2 +- > fs/proc/kcore.c | 4 ++++ > include/linux/kcore.h | 1 + > 3 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c > index 4a83728..dab78f6 100644 > --- a/arch/x86/mm/init_64.c > +++ b/arch/x86/mm/init_64.c > @@ -1187,7 +1187,7 @@ void __init mem_init(void) > > /* Register memory areas for /proc/kcore */ > kclist_add(&kcore_vsyscall, (void *)VSYSCALL_ADDR, > - PAGE_SIZE, KCORE_OTHER); > + PAGE_SIZE, KCORE_USER); > > mem_init_print_info(NULL); > } > diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c > index 4bc85cb..e4b0204 100644 > --- a/fs/proc/kcore.c > +++ b/fs/proc/kcore.c > @@ -510,6 +510,10 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff) > /* 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)) { > unsigned long n; > diff --git a/include/linux/kcore.h b/include/linux/kcore.h > index 7ff25a8..80db19d 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, > }; > >