From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753871AbbGUIgL (ORCPT ); Tue, 21 Jul 2015 04:36:11 -0400 Received: from TYO201.gate.nec.co.jp ([210.143.35.51]:42910 "EHLO tyo201.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753602AbbGUIgG convert rfc822-to-8bit (ORCPT ); Tue, 21 Jul 2015 04:36:06 -0400 From: Naoya Horiguchi To: Konstantin Khlebnikov CC: "linux-mm@kvack.org" , Andrew Morton , "Kirill A. Shutemov" , Mark Williamson , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" Subject: Re: [PATCH v4 4/5] pagemap: hide physical addresses from non-privileged users Thread-Topic: [PATCH v4 4/5] pagemap: hide physical addresses from non-privileged users Thread-Index: AQHQvksNRY6LYulLakO7bUlMtkR5PZ3lBlOA Date: Tue, 21 Jul 2015 08:11:50 +0000 Message-ID: <20150721081149.GC4490@hori1.linux.bs1.fc.nec.co.jp> References: <20150714152516.29844.69929.stgit@buzz> <20150714153747.29844.13543.stgit@buzz> In-Reply-To: <20150714153747.29844.13543.stgit@buzz> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.128.101.29] Content-Type: text/plain; charset="iso-2022-jp" Content-ID: <348F569F08A4794D8983C2FAFB19992E@gisp.nec.co.jp> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 14, 2015 at 06:37:47PM +0300, Konstantin Khlebnikov wrote: > This patch makes pagemap readable for normal users and hides physical > addresses from them. For some use-cases PFN isn't required at all. > > Signed-off-by: Konstantin Khlebnikov > Fixes: ab676b7d6fbf ("pagemap: do not leak physical addresses to non-privileged userspace") > Link: http://lkml.kernel.org/r/1425935472-17949-1-git-send-email-kirill@shutemov.name > --- > fs/proc/task_mmu.c | 25 ++++++++++++++----------- > 1 file changed, 14 insertions(+), 11 deletions(-) > > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > index 040721fa405a..3a5d338ea219 100644 > --- a/fs/proc/task_mmu.c > +++ b/fs/proc/task_mmu.c > @@ -937,6 +937,7 @@ typedef struct { > struct pagemapread { > int pos, len; /* units: PM_ENTRY_BYTES, not bytes */ > pagemap_entry_t *buffer; > + bool show_pfn; > }; > > #define PAGEMAP_WALK_SIZE (PMD_SIZE) > @@ -1013,7 +1014,8 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm, > struct page *page = NULL; > > if (pte_present(pte)) { > - frame = pte_pfn(pte); > + if (pm->show_pfn) > + frame = pte_pfn(pte); > flags |= PM_PRESENT; > page = vm_normal_page(vma, addr, pte); > if (pte_soft_dirty(pte)) Don't you need the same if (pm->show_pfn) check in is_swap_pte path, too? (although I don't think that it can be exploited by row hammer attack ...) Thanks, Naoya Horiguchi From mboxrd@z Thu Jan 1 00:00:00 1970 From: Naoya Horiguchi Subject: Re: [PATCH v4 4/5] pagemap: hide physical addresses from non-privileged users Date: Tue, 21 Jul 2015 08:11:50 +0000 Message-ID: <20150721081149.GC4490@hori1.linux.bs1.fc.nec.co.jp> References: <20150714152516.29844.69929.stgit@buzz> <20150714153747.29844.13543.stgit@buzz> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20150714153747.29844.13543.stgit@buzz> Content-Language: ja-JP Content-ID: <348F569F08A4794D8983C2FAFB19992E@gisp.nec.co.jp> Sender: owner-linux-mm@kvack.org To: Konstantin Khlebnikov Cc: "linux-mm@kvack.org" , Andrew Morton , "Kirill A. Shutemov" , Mark Williamson , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" List-Id: linux-api@vger.kernel.org On Tue, Jul 14, 2015 at 06:37:47PM +0300, Konstantin Khlebnikov wrote: > This patch makes pagemap readable for normal users and hides physical > addresses from them. For some use-cases PFN isn't required at all. >=20 > Signed-off-by: Konstantin Khlebnikov > Fixes: ab676b7d6fbf ("pagemap: do not leak physical addresses to non-priv= ileged userspace") > Link: http://lkml.kernel.org/r/1425935472-17949-1-git-send-email-kirill@s= hutemov.name > --- > fs/proc/task_mmu.c | 25 ++++++++++++++----------- > 1 file changed, 14 insertions(+), 11 deletions(-) >=20 > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > index 040721fa405a..3a5d338ea219 100644 > --- a/fs/proc/task_mmu.c > +++ b/fs/proc/task_mmu.c > @@ -937,6 +937,7 @@ typedef struct { > struct pagemapread { > int pos, len; /* units: PM_ENTRY_BYTES, not bytes */ > pagemap_entry_t *buffer; > + bool show_pfn; > }; > =20 > #define PAGEMAP_WALK_SIZE (PMD_SIZE) > @@ -1013,7 +1014,8 @@ static pagemap_entry_t pte_to_pagemap_entry(struct = pagemapread *pm, > struct page *page =3D NULL; > =20 > if (pte_present(pte)) { > - frame =3D pte_pfn(pte); > + if (pm->show_pfn) > + frame =3D pte_pfn(pte); > flags |=3D PM_PRESENT; > page =3D vm_normal_page(vma, addr, pte); > if (pte_soft_dirty(pte)) Don't you need the same if (pm->show_pfn) check in is_swap_pte path, too? (although I don't think that it can be exploited by row hammer attack ...) Thanks, Naoya Horiguchi= -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org