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 X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45DB0C2D0A3 for ; Fri, 30 Oct 2020 01:23:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8A71206B5 for ; Fri, 30 Oct 2020 01:23:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726063AbgJ3BXo (ORCPT ); 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 > .