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 0A6F7C00144 for ; Mon, 1 Aug 2022 12:05:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DF558E0001; Mon, 1 Aug 2022 08:05:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58EC16B0072; Mon, 1 Aug 2022 08:05:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 456D88E0001; Mon, 1 Aug 2022 08:05:04 -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 334866B0071 for ; Mon, 1 Aug 2022 08:05:04 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E7B2A80930 for ; Mon, 1 Aug 2022 12:05:03 +0000 (UTC) X-FDA: 79750892886.04.E4672B8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 7C27540110 for ; Mon, 1 Aug 2022 12:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659355503; h=from:from: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; bh=nAFx/nR5JRxzgXY+0POxZcF09LGwe2BEj2vlxuyMKXI=; b=X91DKFpWIM+HRSPBVh+c5FcnVC8rSzY5SWf7ys48zAYKaZZJsKXPKyBo3JXESCSmDwmImg VQJAVcg0zjqvNdAU5U0OLCioF9iKvgio2p1/111q4GXiUkqMMDjBvgIKsRgWA+l4+OyePs zCxryfbM1wBH1hx3dGMjd8yxDwHdxh4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-580-oFMBZFnBPHGCW4Cvukx5-w-1; Mon, 01 Aug 2022 08:05:00 -0400 X-MC-Unique: oFMBZFnBPHGCW4Cvukx5-w-1 Received: by mail-wr1-f72.google.com with SMTP id i15-20020adfa50f000000b0021ebd499de2so2475813wrb.7 for ; Mon, 01 Aug 2022 05:04:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=nAFx/nR5JRxzgXY+0POxZcF09LGwe2BEj2vlxuyMKXI=; b=yDvTrwGyfv6q9TgxK1gpRdkJA5tVLi25rq2/SxK36dpWgbBw3w15nw+0zcf0+/RyDl OQWh9f6gn3MDiFP9kJv0e3afBEhIxuweyUo2MihVhm82vEM58xfGZluKwzbrabwMjWEW zki6R9Cfx/j3vpwiZx4ueMCaV7uNrWsQUDPQ/3zzrKiDn3517NPbgeG/UbIQUbAXxQ1W qmisQXN1FPIcwsPXERg2RJkHv1ws50KGZ/2D/Dz5yyN8mhrU5jazpLFEGgZ/frUymHA5 O/9esZ02OU4sYlK3eTF+M3dLwWfjmjwffj7b5E7QXJvAdbbvn1fst9LdV0kJ6Y9LOoMH 9jQw== X-Gm-Message-State: ACgBeo0wmB3E2ExJzFvjoCA02fMmTFCMcsXKe38QSSg4nByVHOB79t2w dsZ46PNpKfrtDe1aBTHSfj4PiQQDfPMuj6wylbdDNZFIfA8f0dQmFFPx43iZTeA6Tb3DtS6HfJq 5nnRBU6ai97U= X-Received: by 2002:a5d:5b18:0:b0:220:63db:c7ca with SMTP id bx24-20020a5d5b18000000b0022063dbc7camr2330066wrb.719.1659355498743; Mon, 01 Aug 2022 05:04:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR4WhA7Gu8I94G14EK2BGE5HtXyv2sE5bayVydnVs25b6svQ5MUeXsCZln3fHArfJ7k0WuOhYw== X-Received: by 2002:a5d:5b18:0:b0:220:63db:c7ca with SMTP id bx24-20020a5d5b18000000b0022063dbc7camr2330033wrb.719.1659355498440; Mon, 01 Aug 2022 05:04:58 -0700 (PDT) Received: from ?IPV6:2003:cb:c704:6900:6d08:8df1:dd2c:bf00? (p200300cbc70469006d088df1dd2cbf00.dip0.t-ipconnect.de. [2003:cb:c704:6900:6d08:8df1:dd2c:bf00]) by smtp.gmail.com with ESMTPSA id n5-20020a05600c3b8500b003a03185231bsm9034633wms.31.2022.08.01.05.04.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Aug 2022 05:04:58 -0700 (PDT) Message-ID: Date: Mon, 1 Aug 2022 14:04:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH V2] mm: fix use-after free of page_ext after race with memory-offline To: Charan Teja Kalla , akpm@linux-foundation.org, quic_pkondeti@quicinc.com, pasha.tatashin@soleen.com, sjpark@amazon.de, sieberf@amazon.com, shakeelb@google.com, dhowells@redhat.com, willy@infradead.org, liuting.0x7c00@bytedance.com, minchan@kernel.org, Michal Hocko Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <1658931303-17024-1-git-send-email-quic_charante@quicinc.com> <6168cf49-bf75-2ebb-ab55-30de473835e3@redhat.com> <3fc8a61b-ad70-8092-9197-4920e0897593@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659355503; 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=nAFx/nR5JRxzgXY+0POxZcF09LGwe2BEj2vlxuyMKXI=; b=NirIntZwO6J+cBbsufSS1dni1ZODc5ncu2e0iJAXLVsMbYc3xDjBj5MXoFbq/1029HUZpr kGva2soG+EQUI7T6ASxioSdZXm63b6KTcd+ncozNNLglowN1HMbkcoaMfdnko4QB0GbOF4 T6PlBvMLr/XDfPHuLTWcZdVp+Z9DpuM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X91DKFpW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659355503; a=rsa-sha256; cv=none; b=RDR2+kXxEmDxV5h3aW6UHRw1zsh9S4UWjeZDwKv84Gy5XlrcSJpI1Id2/XAUQ1DpGnTIRo PJyRXAMvv4j+EpPJPiql+o/ByOVvCGhx3Cx9R50ljiVVg480hmWex+2aAeDkSrxB7j7e1H 5svMp7NUEgLy35Dr/sbtS1nSQt8DA5k= X-Rspamd-Server: rspam02 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X91DKFpW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com X-Stat-Signature: 3mwwj3iykk1nafuz5z3j65cmhqormorr X-Rspamd-Queue-Id: 7C27540110 X-HE-Tag: 1659355503-441350 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 01.08.22 13:50, Charan Teja Kalla wrote: > Thanks David!! > > On 8/1/2022 2:00 PM, David Hildenbrand wrote: >>> Having said that, I am open to go for call_rcu() and infact it will be a >>> much simple change where I can do the freeing of page_ext in the >>> __free_page_ext() itself which is called for every section there by >>> avoid the extra tracking flag PAGE_EXT_INVALID. >>> ........... >>> WRITE_ONCE(ms->page_ext, NULL); >>> call_rcu(rcu_head, fun); // Free in fun() >>> ............. >>> >>> Or your opinion is to use call_rcu () only once in place of >>> synchronize_rcu() after invalidating all the page_ext's of memory block? >> >> Yeah, that would be an option. And if you fail to allocate a temporary >> buffer to hold the data-to-free (structure containing rcu_head), the >> slower fallback path would be synchronize_rcu(). >> > > I will add this as a note in the code that in future If some > optimizations needs to be done in this path, this option can be > considered. Hope this will be fine for now? IMHO yes. But not need to add all these details to the patch description (try keeping it short and precise). You can always just link to the discussion, e.g., via https://lkml.kernel.org/r/a26ce299-aed1-b8ad-711e-a49e82bdd180@quicinc.com -- Thanks, David / dhildenb