Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp910995pxx; Thu, 29 Oct 2020 18:25:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0cTctjWJOVrpOAKRIjXg6gvcJlbJ6e7rArDYZJAvWfs3564AQI5Sq7nx/vlSMQaSSAEnT X-Received: by 2002:a05:6402:1684:: with SMTP id a4mr7232048edv.319.1604021102159; Thu, 29 Oct 2020 18:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604021102; cv=none; d=google.com; s=arc-20160816; b=ajxLIqbjmu196CAKl7NRmyNjvsSigkuOS+mZz0StCAZpuM+NYURYv20NF6IqNFY9K6 Hid+GEY5+3tFtkJl9M3cjY4fhI0TDPu0lX58pPsUmKRZCpGvRjQNfhsns/BcRBJQ8L0/ MSajgxv9GQ1csdb4Y8n4eFbTWULxd8XWsKGx1Qy/BzYDZnfwYO2p/Hng/YeZEdMXFYiV YoXnaPejR20nk2fBsslKy3Da+wxOKpejaXuUCIO/EiFlFTy8avH5N8PzBnFdgGVkrNno CgwVCCihEf2FqiFoCJQDBFpKbuJHluHXb0ApGWXm5t3vu3dFy+O2fk5fLGe9yx4E2JGh qfbg== 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 :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=P8LKwUwDv/n4d/dXqzoGOC16dSTuaedUtj5oBYsbxwc=; b=mG3RGFRayDEFhXgB8oh11GsQUfXGZs9Oi9hEys1XgQXtHdptO9zZBZlHrP0oypjg2c xODaHG2rSjxCITdTNceXo4+NFuPR8VPlLqUW3wp1dnxgNPVT6+HV2rTdCiDHmRKIG0KX eHLJX522b3hONC/bzuAgObfV1qA1RQNssFlUOdCSWyXgAiFrqPwB8BSAxdNIWp2V4+HG JY5p3PJZpJrvVSzJLTOOPgBOmh1q+2QtiaJggVf7DVuYvp5NsVUIliuVsRaHX8bB4VhQ CHs2rXSzqBTtncbr38tFmYw/RmvRAYB4YT2QTOn3Srwuw1j6JAFaKX89yGi7G7nRgnIW nB+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k15si3223197edr.208.2020.10.29.18.24.32; Thu, 29 Oct 2020 18:25:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726062AbgJ3BXo (ORCPT + 99 others); Thu, 29 Oct 2020 21:23:44 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6708 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726017AbgJ3BXo (ORCPT ); Thu, 29 Oct 2020 21:23:44 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CMl2738Gnzkc7m; Fri, 30 Oct 2020 09:23:43 +0800 (CST) Received: from [10.174.179.106] (10.174.179.106) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Fri, 30 Oct 2020 09:23:38 +0800 Subject: Re: [PATCH] ext4: do not use extent after put_bh To: Ritesh Harjani , CC: , , References: <20201028055617.2569255-1-yangerkun@huawei.com> <93d5b1bf-0cf9-a483-ff5d-40a6a9c4b92b@linux.ibm.com> From: yangerkun Message-ID: Date: Fri, 30 Oct 2020 09:23:38 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <93d5b1bf-0cf9-a483-ff5d-40a6a9c4b92b@linux.ibm.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.106] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 在 2020/10/30 0:08, Ritesh Harjani 写道: > > > On 10/28/20 11:26 AM, yangerkun wrote: >> ext4_ext_search_right will read more extent block and call put_bh after >> we get the information we need. However ret_ex will break this and may >> cause use-after-free once pagecache has been freed. Fix it by dup the >> extent we need. > > > It would be good if we have a test case to reproduce it. Do you? > Ideally it should go in fstests, if you have some way to forcefully > reproduce it/simulate it. Let me know, if needed, I can as well help to > get those into fstests. Sorry for that. I found this bug while reading source code. Not with a testcase. And time leave for drop pagecache is so small(time between get_implied_cluster_alloc and ext4_ext_search_right in ext4_ext_map_blocks, other caller for ext4_ext_search_right won't use @ret_ex). It may difficult to reproduce it expect a delay injection. Thanks, Kun. > > -ritesh > .