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 5781DC00144 for ; Mon, 1 Aug 2022 13:08:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 979016B0071; Mon, 1 Aug 2022 09:08:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8DA846B0072; Mon, 1 Aug 2022 09:08:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72CFB8E0001; Mon, 1 Aug 2022 09:08:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5C3D36B0071 for ; Mon, 1 Aug 2022 09:08:24 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 204A0C0AA9 for ; Mon, 1 Aug 2022 13:08:24 +0000 (UTC) X-FDA: 79751052528.04.C051FB2 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf24.hostedemail.com (Postfix) with ESMTP id 76AFE18010C for ; Mon, 1 Aug 2022 13:08:23 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 181DA207D7; Mon, 1 Aug 2022 13:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1659359302; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Beg13MRW0kvMPBqsKXzcnAP8k+2gavzK1o56D6LA6j8=; b=YVyFRO/kg+BZCfK5rvegllNMv4ruh/nICAcojra3Bv63KZeN8hMk6UpHHQr6eCmx3wqjH4 IIE1tYYwlM5w4cHYu4rveapfm5/5pUCMFv6OGi0HJ+h7KHlkxS8J17cdZFwTkig6K64r9j mYILGeTJuwWaQm8TUh6ewYntbe0wsrs= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 556E113A72; Mon, 1 Aug 2022 13:08:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id zEvwB0XQ52I/MwAAMHmgww (envelope-from ); Mon, 01 Aug 2022 13:08:21 +0000 Date: Mon, 1 Aug 2022 15:08:17 +0200 From: Michal Hocko To: Charan Teja Kalla Cc: akpm@linux-foundation.org, david@redhat.com, quic_pkondeti@quicinc.com, pasha.tatashin@soleen.com, sjpark@amazon.de, sieberf@amazon.com, shakeelb@google.com, dhowells@redhat.com, willy@infradead.org, minchan@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH V2] mm: fix use-after free of page_ext after race with memory-offline Message-ID: References: <1658931303-17024-1-git-send-email-quic_charante@quicinc.com> <6b646ff2-b6f6-052e-f3f4-3bf05243f049@quicinc.com> <54e4ce7d-7cbd-480c-28ba-cba684341b37@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54e4ce7d-7cbd-480c-28ba-cba684341b37@quicinc.com> ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="YVyFRO/k"; spf=pass (imf24.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659359303; a=rsa-sha256; cv=none; b=db5236bSEOwyZeiNoIcrRky7CU5R+2TkrTKhZ3sfNLU0XnAAfv36hmafkkqw2iXfgBO+KN LzCMgx17ebch04M4DwIsxyh6XEU7z8ALoUG/47gKMHKsDmSXuz1ba2l3sp3wvcX4P+mS0S tYpow4Z/SKfmu/6yBGjoU3eLCEerwnA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659359303; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Beg13MRW0kvMPBqsKXzcnAP8k+2gavzK1o56D6LA6j8=; b=PTNImRylJGPHLjFrM08CZ84RA5LdN5tEJ1EeYhT6lqfJW0NjRyMXbQI0LyEmHvDJP26qjw 2/oZnA8En3G20Saks6nqDE1Cm7aVTfAdVal0hmtcF4yVAHy/NZzwOLuAziTfLlb4vXj0t9 /PjOtRJ50zkyxiJAZFhFXcqk2l4AgJg= X-Stat-Signature: gzkgiokp36b8ienwakkcqxiy7yh8t89c X-Rspamd-Queue-Id: 76AFE18010C X-Rspam-User: X-Rspamd-Server: rspam05 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="YVyFRO/k"; spf=pass (imf24.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-HE-Tag: 1659359303-286033 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 Mon 01-08-22 18:31:45, Charan Teja Kalla wrote: [...] > >> The roll back operation in the online_page_ext(), where we free the > >> allocated page_ext's, will not have the PAGE_EXT_INVALID flag thus > >> WARN() may not work here. no? > > Wouldn't ms->page_ext be NULL in that case? > I don't think that ms->page_ext would be NULL here. > online_page_ext(): > (a) for (pfn = start; !fail && pfn < end; pfn += PAGES_PER_SECTION) > fail = init_section_page_ext(): > ms->page_ext = (void *)base - page_ext_size * pfn; > > //If fail = -ERROR in the middle, roll back operation. > (b) for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) > __free_page_ext(); > > Here (b) can be called on the sections without PAGE_EXT_INVALID with > ms->page_ext != NULL. > You are right. My sloppy code reading. A tiny comment would be nice. Because this shouldn't really happen for normal calls. -- Michal Hocko SUSE Labs