Received: by 10.223.164.202 with SMTP id h10csp1196697wrb; Tue, 7 Nov 2017 23:55:58 -0800 (PST) X-Google-Smtp-Source: ABhQp+TEQjIlNzOzoXXBKmY3Ulv/MsWEDw9oSgsqu/zocay16BhpSkQ3Qc1Ee8uITfR/RIS/ZcSS X-Received: by 10.84.142.129 with SMTP id 1mr1444468plx.341.1510127758265; Tue, 07 Nov 2017 23:55:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510127758; cv=none; d=google.com; s=arc-20160816; b=bL9y8EIFOkvj48ey5iXgurTi3rP+lorC2jn6OllH4K94KDD+9Pgu/1l6493h5MSvu8 OdNa0ifvoicW53c4WroKBxDFlKMghMI7XN6l+LLet6oQDe1TC7BfB62sqjVsq2H9A+Vh sh1szRABkOz9g6McNl6IwpojSmaWT5JT/4g1/rsOczLkXr4gqIA2EJ0EgPRM5R8BxQRt bXwQkbJOoYGHvcIslfkkneK5LAPKvXUgUbUL+3OED9jmXJTf9a2FgFOVsKyrOjjObuiD dVH9l/+QzVE2jMZLq/Cn9v7opY4CkpfRTfXw80ha6Z+1MsirkjKe/RmHc14cR4j34m4S HfGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=coVauWFRA2A1/S4gGwTCcDojVvru9CqSgOYg5vvJDKg=; b=fZg0jDJ8Yzg51T+eOqWwHHS2UaTA5+Y5VTMrOyUK30ZmssWpCVH6KO8UxNpOX/RLWZ TxsLFOo2bHZXSlODUV5f20SexBT74Nh/JOxTYidfnWJEjLk2V0bk1ozb02F9bVMDqX45 xHVy6abgW6KxJs9dzmmIziklMCnRZcaEbLFtRa/YmW3xTYehzfiPM/vVhY08iBxkmQtl Pyzw+KnilFeWGBaklsz39tkgo2v3CZjoVWQOW1X3DPa86JiXh0DUL2imYkH5UVTPfZ5D 3ULn1qJngilW8I7U7rgamk7juu31slWLEJuKnpt7aLNp0VcXvOTplzzWDVfABhtFjxnk Y9Nw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10si2613508plp.818.2017.11.07.23.55.45; Tue, 07 Nov 2017 23:55:58 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751379AbdKHHzK (ORCPT + 89 others); Wed, 8 Nov 2017 02:55:10 -0500 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:33326 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751056AbdKHHzI (ORCPT ); Wed, 8 Nov 2017 02:55:08 -0500 Received: from unknown (HELO lgemrelse6q.lge.com) (156.147.1.121) by 156.147.23.53 with ESMTP; 8 Nov 2017 16:55:06 +0900 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: iamjoonsoo.kim@lge.com Received: from unknown (HELO localhost) (10.177.222.138) by 156.147.1.121 with ESMTP; 8 Nov 2017 16:55:06 +0900 X-Original-SENDERIP: 10.177.222.138 X-Original-MAILFROM: iamjoonsoo.kim@lge.com Date: Wed, 8 Nov 2017 16:59:56 +0900 From: Joonsoo Kim To: Michal Hocko Cc: Jaewon Kim , akpm@linux-foundation.org, vbabka@suse.cz, minchan@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com Subject: Re: [PATCH] mm: page_ext: check if page_ext is not prepared Message-ID: <20171108075956.GC18747@js1304-P5Q-DELUXE> References: <20171107094131.14621-1-jaewon31.kim@samsung.com> <20171107094730.5732nqqltx2miszq@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171107094730.5732nqqltx2miszq@dhcp22.suse.cz> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 07, 2017 at 10:47:30AM +0100, Michal Hocko wrote: > [CC Joonsoo] > > On Tue 07-11-17 18:41:31, Jaewon Kim wrote: > > online_page_ext and page_ext_init allocate page_ext for each section, but > > they do not allocate if the first PFN is !pfn_present(pfn) or > > !pfn_valid(pfn). Then section->page_ext remains as NULL. lookup_page_ext > > checks NULL only if CONFIG_DEBUG_VM is enabled. For a valid PFN, > > __set_page_owner will try to get page_ext through lookup_page_ext. > > Without CONFIG_DEBUG_VM lookup_page_ext will misuse NULL pointer as value > > 0. This incurrs invalid address access. > > > > This is the panic example when PFN 0x100000 is not valid but PFN 0x13FC00 > > is being used for page_ext. section->page_ext is NULL, get_entry returned > > invalid page_ext address as 0x1DFA000 for a PFN 0x13FC00. > > > > To avoid this panic, CONFIG_DEBUG_VM should be removed so that page_ext > > will be checked at all times. > > > > <1>[ 11.618085] Unable to handle kernel paging request at virtual address 01dfa014 > > <1>[ 11.618140] pgd = ffffffc0c6dc9000 > > <1>[ 11.618174] [01dfa014] *pgd=0000000000000000, *pud=0000000000000000 > > <4>[ 11.618240] ------------[ cut here ]------------ > > <2>[ 11.618278] Kernel BUG at ffffff80082371e0 [verbose debug info unavailable] > > <0>[ 11.618338] Internal error: Oops: 96000045 [#1] PREEMPT SMP > > <4>[ 11.618381] Modules linked in: > > <4>[ 11.618524] task: ffffffc0c6ec9180 task.stack: ffffffc0c6f40000 > > <4>[ 11.618569] PC is at __set_page_owner+0x48/0x78 > > <4>[ 11.618607] LR is at __set_page_owner+0x44/0x78 > > <4>[ 11.626025] [] __set_page_owner+0x48/0x78 > > <4>[ 11.626071] [] get_page_from_freelist+0x880/0x8e8 > > <4>[ 11.626118] [] __alloc_pages_nodemask+0x14c/0xc48 > > <4>[ 11.626165] [] __do_page_cache_readahead+0xdc/0x264 > > <4>[ 11.626214] [] filemap_fault+0x2ac/0x550 > > <4>[ 11.626259] [] ext4_filemap_fault+0x3c/0x58 > > <4>[ 11.626305] [] __do_fault+0x80/0x120 > > <4>[ 11.626347] [] handle_mm_fault+0x704/0xbb0 > > <4>[ 11.626393] [] do_page_fault+0x2e8/0x394 > > <4>[ 11.626437] [] do_mem_abort+0x88/0x124 > > > > I suspec this goes all the way down to when page_ext has been > resurrected. It is quite interesting that nobody has noticed this in 3 > years but maybe the feature is not used all that much and the HW has to > be quite special to trigger. Anyway the following should be added > > Fixes: eefa864b701d ("mm/page_ext: resurrect struct page extending code for debugging") > Cc: stable IIRC, caller of lookup_page_ext() doesn't check 'NULL' until f86e427197 ("mm: check the return value of lookup_page_ext for all call sites"). So, this problem would happen old kernel even if this patch is applied to old kernel. IMO, proper fix is to check all the pfn in the section. It is sent from Jaewon in other mail. Thanks. From 1583432553547971273@xxx Tue Nov 07 18:22:38 +0000 2017 X-GM-THRID: 1583408356035992696 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread