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 3E76CC00144 for ; Mon, 1 Aug 2022 11:50:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 739DE6B0071; Mon, 1 Aug 2022 07:50:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E96A6B0072; Mon, 1 Aug 2022 07:50:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B1268E0001; Mon, 1 Aug 2022 07:50:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 487196B0071 for ; Mon, 1 Aug 2022 07:50:30 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 114A9140946 for ; Mon, 1 Aug 2022 11:50:30 +0000 (UTC) X-FDA: 79750856220.16.4AB8584 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by imf21.hostedemail.com (Postfix) with ESMTP id 6A3CD1C010D for ; Mon, 1 Aug 2022 11:50:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1659354629; x=1690890629; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=NzcCfCscpwoWHMsQNKhneOoJCWfbmeXO5OjY7iwI/rc=; b=W93JPivz4gJqlsapmjex0/U+oYOF8YC4jfYVN+skuwtbelK/6cqw+2wt p+ulZoDZ2uS0voA+AovgNNXnl1rMRYIU5rMJg0lf3JRXhotYW8qxkL0td 8lv+BSeRl4p5hisxu81U/UZHZJ5/maX+5WSd6W38h9/pMjGTjpoBWHypZ Y=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-02.qualcomm.com with ESMTP; 01 Aug 2022 04:50:28 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg01-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2022 04:50:27 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 1 Aug 2022 04:50:27 -0700 Received: from [10.216.43.100] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 1 Aug 2022 04:50:22 -0700 Message-ID: Date: Mon, 1 Aug 2022 17:20:19 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH V2] mm: fix use-after free of page_ext after race with memory-offline Content-Language: en-US To: David Hildenbrand , , , , , , , , , , , Michal Hocko CC: , 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: Charan Teja Kalla In-Reply-To: <3fc8a61b-ad70-8092-9197-4920e0897593@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659354629; 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=NzcCfCscpwoWHMsQNKhneOoJCWfbmeXO5OjY7iwI/rc=; b=wdXwoM4DqmersrQBxrSe5e34T9fh2SLqf/FKeUbIWgeovgn5CmF22tpABLleFt327QuhWV b9kLkBpkLF3oGX/2idtjGE2Z9dzw2usHx3IMTuGG9fgOWtqnHeG/7pnJOaZwydYvihmOKV knMuIHqETvPkgr2C82gUxIkXkILnzUc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=W93JPivz; spf=pass (imf21.hostedemail.com: domain of quic_charante@quicinc.com designates 199.106.114.39 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659354629; a=rsa-sha256; cv=none; b=Z4fTiVkfVhSt6qf4fhlEmTgnrco7SDtJDovVhS13D2QMiX3GyHxVYPNSzPQZP4epCBsiTe 26vYnyfmftCR06uIGHACmiQfc4YueI6ISFCO4X2zuItNsC66o+6bJba7wsx+hnafsWlnl9 742C4joH2mHLyR8PuuCBTs8G1ujmpqU= X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=W93JPivz; spf=pass (imf21.hostedemail.com: domain of quic_charante@quicinc.com designates 199.106.114.39 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com X-Stat-Signature: 9r8pt8azytx9zmn1441fbr8gfhbj9p1q X-Rspamd-Queue-Id: 6A3CD1C010D X-Rspamd-Server: rspam10 X-HE-Tag: 1659354629-857870 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: 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? > But again, I'm also not sure if we have to optimize here right now. Thanks, Charan