Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp502978rwb; Thu, 18 Aug 2022 07:30:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR48S8BMOYa4UwTfpWKsfDqeYQYbzzGRAXSKHi0axIYocBKaGWPVk8p2O8d94agYNlRVDPFO X-Received: by 2002:a05:6a00:893:b0:528:646f:528a with SMTP id q19-20020a056a00089300b00528646f528amr3162239pfj.21.1660833015116; Thu, 18 Aug 2022 07:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660833015; cv=none; d=google.com; s=arc-20160816; b=VfgD1yO6IIZjNnO+CbyZDitntS+Vd4esJ5aJs9/xpIbcQnP3ynjNZXqSDPERcfkNrF JW8Lmx9dInlc8qca2BwRn2YTevZPpXoTXdG429bV5l50pq+ZB2+gZ6NRszzGhahEWLuE DStSt42sXPeB958ra5dFdVtVHuqWg/Ek5DlrAVB8CDfyVVeM4ipu8HATzPrArTO4wbG8 TNMHSNyl5hnqNa0lhBFuk52Gc/hzvrbbBaoYxEfyd0hYNvGY4u7wbIEvjkY3E7Mns/ym dSJHINS2u+hgJplnIdUGBAa0erOzEiA1Fi9yzayDr2xknbe5PMCf0z5nrdUxJurMZXQp H8Jw== 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=1g/BkFyX8It6eFh6KePQfu0ZOeCiGrJHX0cQQC2SOyk=; b=N+nPcI1SPod/5WNFoN859XnuWx7qA+VMJvPu0nT//dYHrIi/9V9pVyvH+ubuJ32kKf tawQvL094hUtj6C5DsinHuo6aJTDVhIWKs5feI4OVvvyNqgx5IhyFTaFaaatfcUdE+PZ xum8FGY7cHxFRHuqlnqizv73307exTAxu/bCqG8zL3ta7XKEKuN6khOcYMPWYiIUHtCt cR+LlijNa819EsM7FZQCBY1MVlrpquO1tpbe00Sq8oYYZa7Ugrc8B101ZN+ubHnJst2F gdjufgKyzaP8gPdvV2jqONfIKEZU6B9Wg+H6/P7h2se5BLG+SYD9xHq7K2GSW8L8MarR UH7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=TTsBMXiw; 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 x138-20020a633190000000b0042890f36268si1437809pgx.857.2022.08.18.07.30.02; Thu, 18 Aug 2022 07:30:15 -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=qcppdkim1 header.b=TTsBMXiw; 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 S244874AbiHROIa (ORCPT + 99 others); Thu, 18 Aug 2022 10:08:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245730AbiHROIC (ORCPT ); Thu, 18 Aug 2022 10:08:02 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 167CDB958B for ; Thu, 18 Aug 2022 07:07:58 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27IAWwak023044; Thu, 18 Aug 2022 14:01:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=1g/BkFyX8It6eFh6KePQfu0ZOeCiGrJHX0cQQC2SOyk=; b=TTsBMXiw56AD9S0aHodHRMIzGde785Ie46GovzTCoDf9DsSzq2WZBFSdCcuieyo8WqNY rNlDkeEPwg4PjwAYJrivfxLW+Lrk1WRAlR6wwUScLSsnTyBMjWs5i1elm/MKBBZZUtzt MMt0n7FpJY59Z4xIjfJt9RUicaWRJMRoowXlfWSJqgUupx+6kDws2J4ss60o6jth+bvX 111v6gpYh9oS6ge73Kh2j10cERRTBrjWP0PQFoY5o3KgyTUgMl0T0Gn4QXc8KeS4Itjc h0hcD65VD1e8jAQyAGICYDSIXp44RuUfWK04FJy4uLu29l7zlvWE7FrEnv2czO26vdsz RA== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3j1hhp1b4f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Aug 2022 14:01:15 +0000 Received: from pps.filterd (NALASPPMTA01.qualcomm.com [127.0.0.1]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 27IE1FYK021171; Thu, 18 Aug 2022 14:01:15 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA01.qualcomm.com (PPS) with ESMTPS id 3hywar3xk3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Aug 2022 14:01:15 +0000 Received: from NALASPPMTA01.qualcomm.com (NALASPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27IE1EfS021164; Thu, 18 Aug 2022 14:01:14 GMT Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (PPS) with ESMTPS id 27IE1EYP021162 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Aug 2022 14:01:14 +0000 Received: from [10.214.20.211] (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; Thu, 18 Aug 2022 07:01:10 -0700 Message-ID: Date: Thu, 18 Aug 2022 19:31:05 +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 V3] mm: fix use-after free of page_ext after race with memory-offline Content-Language: en-US To: Michal Hocko CC: , , , , , , , , , , References: <1660056403-20894-1-git-send-email-quic_charante@quicinc.com> <286e47e7-3d63-133c-aa6c-05100b557d42@quicinc.com> From: Charan Teja Kalla In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: xZS7wHPDsPq84jrGmyNyKiHEySmNd5Xy X-Proofpoint-ORIG-GUID: xZS7wHPDsPq84jrGmyNyKiHEySmNd5Xy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-18_12,2022-08-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 adultscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=262 spamscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208180050 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Hi Michal, On 8/16/2022 9:45 PM, Michal Hocko wrote: >>>> @@ -183,19 +184,26 @@ static inline void __set_page_owner_handle(struct page_ext *page_ext, >>>> noinline void __set_page_owner(struct page *page, unsigned short order, >>>> gfp_t gfp_mask) >>>> { >>>> - struct page_ext *page_ext = lookup_page_ext(page); >>>> + struct page_ext *page_ext = page_ext_get(page); >>>> depot_stack_handle_t handle; >>>> >>>> if (unlikely(!page_ext)) >>>> return; >>> Either add a comment like this >>> /* save_stack can sleep in general so we have to page_ext_put */ >> >> Vlastimil suggested to go for save stack first since !page_ext is mostly >> unlikely. Snip from his comments: >> Why not simply do the save_stack() first and then page_ext_get() just >> once? It should be really rare that it's NULL, so I don't think we save >> much by avoiding an unnecessary save_stack(), while the overhead of >> doing two get/put instead of one will affect every call. > right see below >> https://lore.kernel.org/all/f5fd4942-b03e-1d1c-213b-9cd5283ced91@suse.cz/ >>>> + page_ext_put(); >>>> >>>> handle = save_stack(gfp_mask); >>> or just drop the initial page_ext_get altogether. This function is >>> called only when page_ext is supposed to be initialized and !page_ext >>> case above should be very unlikely. Or is there any reason to keep this? I don't think that !page_ext check is really required as __set_page_owner() is called means page_ext should have been initialized. Will raise a separate change for this suggestion. For now V4 is raised with the earlier suggestion of dropping the initial page_ext. https://lore.kernel.org/all/1660830600-9068-1-git-send-email-quic_charante@quicinc.com/. Thanks, Charan