From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7EC3ECAAD4 for ; Sat, 27 Aug 2022 03:12:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B416940007; Fri, 26 Aug 2022 23:12:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43C8F6B0078; Fri, 26 Aug 2022 23:12:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3038B940007; Fri, 26 Aug 2022 23:12:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1CD7E6B0074 for ; Fri, 26 Aug 2022 23:12:46 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EB5A1C03D5 for ; Sat, 27 Aug 2022 03:12:45 +0000 (UTC) X-FDA: 79843900290.25.6101012 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 876451C001A for ; Sat, 27 Aug 2022 03:12:45 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BCFF261DC4; Sat, 27 Aug 2022 03:12:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE843C433D6; Sat, 27 Aug 2022 03:12:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1661569964; bh=PkNFJBIXlxGTFGa9sfOyJ1hkMvHVayd6VKip+kMlVgM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Xb7ZaS4wfFRvselZgPCbtJc7ZGkc9kh7V7z5fKEgK0mEl4tuyGwEvtw5/hln7N1N1 WoClXMLvLGGnfkNgGSxciXWngZ2t6ohso2Oz3JsYDrxTNPT9y1VZNHoJxszFXZHY90 cf9V14Vi480HkMw2AJA94lYJCNEao0xbUkALyKew= Date: Fri, 26 Aug 2022 20:12:42 -0700 From: Andrew Morton To: Michal Hocko Cc: Charan Teja Kalla , david@redhat.com, vbabka@suse.cz, pasha.tatashin@soleen.com, shakeelb@google.com, sieberf@amazon.com, sjpark@amazon.de, william.kucharski@oracle.com, willy@infradead.org, quic_pkondeti@quicinc.com, minchan@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH V5] mm: fix use-after free of page_ext after race with memory-offline Message-Id: <20220826201242.bbf4948e5221c883dadfc2d6@linux-foundation.org> In-Reply-To: References: <1661496993-11473-1-git-send-email-quic_charante@quicinc.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661569965; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=W55EoXS4GP6hFW9Jqiy/3k8V17K1N5Z/PPzCLWPmnno=; b=LyL20y3Y4ffMc5sx3og53t98iXcsHk6t1JVEyAhkw72R8mJmOsDu0Q8BODfCvkxczaucXx np5Mx/CTS+CeZ3Thv23ThX7sUZ9m8Fa6yZsAUe/DNHSHNRCmEQNnv7GEthvNJjWOaliAcF PdUL/FfpbCiLE3O3tQjXERirtCFIQQo= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=Xb7ZaS4w; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661569965; a=rsa-sha256; cv=none; b=Pac24bPro6LeG9F89b9IiC9Pz6BfHOVhKyjAg7jdw4Jdlo2gbr2EyrZFaaxmPvnP+zYf3q NW6HPX96kD0XJspq+0udzreLuGG1IBVJnPXyzxbM2uiVRHOHZqL6fTR5uFWMYGrja2osQO 2XsfUXsFglbMmPXnteS7TTqEJI7Cv/c= X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=Xb7ZaS4w; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam05 X-Stat-Signature: izzzs1rg14e85hwx64nmjf48wm5cjd3e X-Rspamd-Queue-Id: 876451C001A X-HE-Tag: 1661569965-9848 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, 26 Aug 2022 09:40:52 +0200 Michal Hocko wrote: > > Changes in V5: > > o Used the loop variable name as ext_put_continue -- David > > If this is the only change since the last version (I didn't have much > time to read through the whole patch) then my ack still applies. yup. --- a/mm/page_owner.c~mm-fix-use-after-free-of-page_ext-after-race-with-memory-offline-v5 +++ a/mm/page_owner.c @@ -326,7 +326,7 @@ void pagetypeinfo_showmixedcount_print(s continue; if (!test_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags)) - goto loop; + goto ext_put_continue; page_owner = get_page_owner(page_ext); page_mt = gfp_migratetype(page_owner->gfp_mask); @@ -341,7 +341,7 @@ void pagetypeinfo_showmixedcount_print(s break; } pfn += (1UL << page_owner->order) - 1; -loop: +ext_put_continue: page_ext_put(page_ext); } } @@ -561,14 +561,14 @@ read_page_owner(struct file *file, char * because we don't hold the zone lock. */ if (!test_bit(PAGE_EXT_OWNER, &page_ext->flags)) - goto loop; + goto ext_put_continue; /* * Although we do have the info about past allocation of free * pages, it's not relevant for current memory usage. */ if (!test_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags)) - goto loop; + goto ext_put_continue; page_owner = get_page_owner(page_ext); @@ -577,7 +577,7 @@ read_page_owner(struct file *file, char * would inflate the stats. */ if (!IS_ALIGNED(pfn, 1 << page_owner->order)) - goto loop; + goto ext_put_continue; /* * Access to page_ext->handle isn't synchronous so we should @@ -585,7 +585,7 @@ read_page_owner(struct file *file, char */ handle = READ_ONCE(page_owner->handle); if (!handle) - goto loop; + goto ext_put_continue; /* Record the next PFN to read in the file offset */ *ppos = (pfn - min_low_pfn) + 1; @@ -594,7 +594,7 @@ read_page_owner(struct file *file, char page_ext_put(page_ext); return print_page_owner(buf, count, pfn, page, &page_owner_tmp, handle); -loop: +ext_put_continue: page_ext_put(page_ext); } @@ -654,13 +654,13 @@ static void init_pages_in_zone(pg_data_t /* Maybe overlapping zone */ if (test_bit(PAGE_EXT_OWNER, &page_ext->flags)) - goto loop; + goto ext_put_continue; /* Found early allocated page */ __set_page_owner_handle(page_ext, early_handle, 0, 0); count++; -loop: +ext_put_continue: page_ext_put(page_ext); } cond_resched(); _