Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1958263imn; Mon, 1 Aug 2022 06:18:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vT/YQmrpqS7/K9o2n6TyAzg3S4Sb3TwkBwopkoxUCJ9UsM4gD1XeWEXbrvTxWdw5ZRKhlC X-Received: by 2002:a63:2c10:0:b0:411:4fd8:9fc8 with SMTP id s16-20020a632c10000000b004114fd89fc8mr13625002pgs.313.1659359930233; Mon, 01 Aug 2022 06:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659359930; cv=none; d=google.com; s=arc-20160816; b=DjLn0i/gse1T7s4muiPQTMLzmqHGrn/qUvQSyDwR5wt0cvkTqcbL73LSEtmAdLWTTH B0zlN5aKdIQeQj5u2RYK9UdlF+dtmI9MB0Bk9vB98838+mBQDuWQ5wtWGCHlj5mABK5J MtD89f+HtE8QIGmRMw3m6NkLEf/gpdE3+P0Hd5/yw2J3hXLPMbS2FfebzqRYsFZRjN0O z4EZ28zKNO2JvFxNUfnTP4ZyFwwWQ1OjWyxdrlXLjIx05YkVe0j6Q6uED7C98zpBZLgB x7b4CYR9PH0gmh1PGTFGDW7GK9TiZueHuktr14NSWNXkdhaB21+GMO+OF8xlhtPToH0L Fosg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Beg13MRW0kvMPBqsKXzcnAP8k+2gavzK1o56D6LA6j8=; b=dUD3syQSn6BiF2KgDwPVgP9i6s0obenV3lpnaBhGeg0JVPCuKJcy7SaRRIKy/2fwJA w4RES4WZ54EyK8J6/QdnZhXYCXI0ZfohsIoeAP3w1Z2OlOa9ptdC4k/4HdAEg9A677vJ QmFGVBub4WhoLvTpzoVdcvDV1yMqvFaOyEmK2zNRqSmihYvpq89Y6Qkgy+wbuqnptcR9 TaN1iCmhc5OSOKU6xPX4YOQ4YHU0in96FkUZx6Uz53F7LJDQDHURdFqTvhZoALgUZ/6q vTsSBHpfJGn8tq6YxJc/onm/CSzDPhGS+CJzcYhcv/0NtcQwrMFxG3wNnRmJSGktkzqu bA8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="YVyFRO/k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a62e50c000000b0052bee98ed2dsi10911908pff.81.2022.08.01.06.18.25; Mon, 01 Aug 2022 06:18:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="YVyFRO/k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231336AbiHANI0 (ORCPT + 99 others); Mon, 1 Aug 2022 09:08:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbiHANIY (ORCPT ); Mon, 1 Aug 2022 09:08:24 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6556B1C3 for ; Mon, 1 Aug 2022 06:08:23 -0700 (PDT) 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> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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