From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933041AbdJaTPK (ORCPT ); Tue, 31 Oct 2017 15:15:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42062 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932687AbdJaTPI (ORCPT ); Tue, 31 Oct 2017 15:15:08 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 01E1B3683C Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=aarcange@redhat.com Date: Tue, 31 Oct 2017 20:15:06 +0100 From: Andrea Arcangeli To: Vlastimil Babka Cc: "Kirill A. Shutemov" , Dmitry Vyukov , syzbot , Jan Beulich , "H. Peter Anvin" , Josh Poimboeuf , "Kirill A. Shutemov" , ldufour@linux.vnet.ibm.com, LKML , Andy Lutomirski , Ingo Molnar , syzkaller-bugs@googlegroups.com, Thomas Gleixner , the arch/x86 maintainers , Andrew Morton , Michal Hocko , Hugh Dickins , David Rientjes , linux-mm@kvack.org, Linus Torvalds , Thorsten Leemhuis Subject: Re: KASAN: use-after-free Read in __do_page_fault Message-ID: <20171031191506.GB2799@redhat.com> References: <94eb2c0433c8f42cac055cc86991@google.com> <8e92c891-a9e0-efed-f0b9-9bf567d8fbcd@suse.cz> <4bc852be-7ef3-0b60-6dbb-81139d25a817@suse.cz> <20171031141152.tzx47fy26pvx7xug@node.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 31 Oct 2017 19:15:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 31, 2017 at 03:28:26PM +0100, Vlastimil Babka wrote: > Hmm that could indeed work, Dmitry can you try the patch below? > But it still seems rather fragile so I'd hope Andrea can do it more > robust, or at least make sure that we don't reintroduce this kind of > problem in the future (explicitly set vma to NULL with a comment?). Reviewed-by: Andrea Arcangeli > > ----8<---- > diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c > index e2baeaa053a5..9bd16fc621db 100644 > --- a/arch/x86/mm/fault.c > +++ b/arch/x86/mm/fault.c > @@ -1441,6 +1441,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code, > * the fault. Since we never set FAULT_FLAG_RETRY_NOWAIT, if > * we get VM_FAULT_RETRY back, the mmap_sem has been unlocked. > */ > + pkey = vma_pkey(vma); > fault = handle_mm_fault(vma, address, flags); > major |= fault & VM_FAULT_MAJOR; > > @@ -1467,7 +1468,6 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code, > return; > } > > - pkey = vma_pkey(vma); > up_read(&mm->mmap_sem); > if (unlikely(fault & VM_FAULT_ERROR)) { > mm_fault_error(regs, error_code, address, &pkey, fault); > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f72.google.com (mail-oi0-f72.google.com [209.85.218.72]) by kanga.kvack.org (Postfix) with ESMTP id 8A2706B025F for ; Tue, 31 Oct 2017 15:15:09 -0400 (EDT) Received: by mail-oi0-f72.google.com with SMTP id m198so14133oig.20 for ; Tue, 31 Oct 2017 12:15:09 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id x206si1227130oia.52.2017.10.31.12.15.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Oct 2017 12:15:08 -0700 (PDT) Date: Tue, 31 Oct 2017 20:15:06 +0100 From: Andrea Arcangeli Subject: Re: KASAN: use-after-free Read in __do_page_fault Message-ID: <20171031191506.GB2799@redhat.com> References: <94eb2c0433c8f42cac055cc86991@google.com> <8e92c891-a9e0-efed-f0b9-9bf567d8fbcd@suse.cz> <4bc852be-7ef3-0b60-6dbb-81139d25a817@suse.cz> <20171031141152.tzx47fy26pvx7xug@node.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: "Kirill A. Shutemov" , Dmitry Vyukov , syzbot , Jan Beulich , "H. Peter Anvin" , Josh Poimboeuf , "Kirill A. Shutemov" , ldufour@linux.vnet.ibm.com, LKML , Andy Lutomirski , Ingo Molnar , syzkaller-bugs@googlegroups.com, Thomas Gleixner , the arch/x86 maintainers , Andrew Morton , Michal Hocko , Hugh Dickins , David Rientjes , linux-mm@kvack.org, Linus Torvalds , Thorsten Leemhuis On Tue, Oct 31, 2017 at 03:28:26PM +0100, Vlastimil Babka wrote: > Hmm that could indeed work, Dmitry can you try the patch below? > But it still seems rather fragile so I'd hope Andrea can do it more > robust, or at least make sure that we don't reintroduce this kind of > problem in the future (explicitly set vma to NULL with a comment?). Reviewed-by: Andrea Arcangeli > > ----8<---- > diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c > index e2baeaa053a5..9bd16fc621db 100644 > --- a/arch/x86/mm/fault.c > +++ b/arch/x86/mm/fault.c > @@ -1441,6 +1441,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code, > * the fault. Since we never set FAULT_FLAG_RETRY_NOWAIT, if > * we get VM_FAULT_RETRY back, the mmap_sem has been unlocked. > */ > + pkey = vma_pkey(vma); > fault = handle_mm_fault(vma, address, flags); > major |= fault & VM_FAULT_MAJOR; > > @@ -1467,7 +1468,6 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code, > return; > } > > - pkey = vma_pkey(vma); > up_read(&mm->mmap_sem); > if (unlikely(fault & VM_FAULT_ERROR)) { > mm_fault_error(regs, error_code, address, &pkey, fault); > -- 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