Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1939319imn; Mon, 1 Aug 2022 05:48:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR68ukSbtyS2YWQJwXyW2KwOcpAYj9EDtFC2Mxg7BOrKmk8DujSFT+OPlFFn0jl6UQEauRcw X-Received: by 2002:a17:907:9482:b0:730:6e79:7e75 with SMTP id dm2-20020a170907948200b007306e797e75mr5008313ejc.345.1659358133677; Mon, 01 Aug 2022 05:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659358133; cv=none; d=google.com; s=arc-20160816; b=fRbI/vSvGjdRRWoOOg3ckYJMeiiCvk9uqCoruVYeZ3lDKay1KiAybmhB2bBTpwh4Ny CzqMetTKuiDu37L7Et82KP99QJUhch3/+SYgZsRZtZ9R3S4s5asiEyoABmkEbGJbeMcY +WDOoY8lQiafhMn0Q5EZdyz90NcnRi94Nh098lluc1AdECNx07Gi+drwt4HgBnIz4tKs Y0Z+7UTz9tydbnbXm3nve4vkZ001CN6Vgl84xSShC058103W5h1dUD3toO8NbKCDM7fi 3+mew3iCho3UGHbbk62tyCEBSvtGypF9qnaonQJOiM5J4jWeJ+c1wR0ke9kkHSZIPAsv nUWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=NzcCfCscpwoWHMsQNKhneOoJCWfbmeXO5OjY7iwI/rc=; b=j/Sffog1OG75+BcxQtrOpPcCb5S3M+1oaCt4OLOgeNCCcXZ+WTeeLMo0oegnC+RC8F qVG7Bzz/jv+vBhysiGhaJjp3FQi+ABUAhNdj4Ql+uQkt5EWdJDQKCVY12agOydIKIjBM JJiL4Bk7sMl/QdwBuWNKnvHyCKtv9ls64SQqeL6uEWeRMe8VcFjJ6ooGzDvWxHfFAM1U +VzsYn/bphYoemrULtF/gXvKcdTexoRFzatiUUG1f4J41A+/zBsxMxXwrey+1sHIVP7j CoklbXFsfZPuyMlGUleT0cectwb23YcZOD0NrkuN2Aiv885CNUxPcNEgnnFSyLe320iG r50Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=W93JPivz; 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=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v12-20020a056402348c00b0043d6bf39697si5222433edc.570.2022.08.01.05.48.29; Mon, 01 Aug 2022 05:48:53 -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=@quicinc.com header.s=qcdkim header.b=W93JPivz; 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=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232326AbiHALy3 (ORCPT + 99 others); Mon, 1 Aug 2022 07:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232239AbiHALxv (ORCPT ); Mon, 1 Aug 2022 07:53:51 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30DD42FFC7 for ; Mon, 1 Aug 2022 04:50:28 -0700 (PDT) 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-01.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) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 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