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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 C966CC433ED for ; Tue, 11 May 2021 06:03:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91AD561926 for ; Tue, 11 May 2021 06:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230322AbhEKGEE (ORCPT ); Tue, 11 May 2021 02:04:04 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2618 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbhEKGED (ORCPT ); Tue, 11 May 2021 02:04:03 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FfS1M0VLwzPwLd; Tue, 11 May 2021 13:59:35 +0800 (CST) Received: from [10.136.110.154] (10.136.110.154) by smtp.huawei.com (10.3.19.201) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 11 May 2021 14:02:54 +0800 Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid null pointer access when handling IPU error To: Jaegeuk Kim CC: , References: <20210510142804.511265-1-jaegeuk@kernel.org> <9df7d088-3580-122b-60a3-799ea665cfeb@huawei.com> From: Chao Yu Message-ID: Date: Tue, 11 May 2021 14:02:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.136.110.154] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/5/11 13:07, Jaegeuk Kim wrote: > On 05/11, Chao Yu wrote: >> On 2021/5/10 22:28, Jaegeuk Kim wrote: >>> Unable to handle kernel NULL pointer dereference at virtual address 000000000000001a >>> pc : f2fs_inplace_write_data+0x144/0x208 >>> lr : f2fs_inplace_write_data+0x134/0x208 >>> Call trace: >>> f2fs_inplace_write_data+0x144/0x208 >>> f2fs_do_write_data_page+0x270/0x770 >>> f2fs_write_single_data_page+0x47c/0x830 >>> __f2fs_write_data_pages+0x444/0x98c >>> f2fs_write_data_pages.llvm.16514453770497736882+0x2c/0x38 >>> do_writepages+0x58/0x118 >>> __writeback_single_inode+0x44/0x300 >>> writeback_sb_inodes+0x4b8/0x9c8 >>> wb_writeback+0x148/0x42c >>> wb_do_writeback+0xc8/0x390 >>> wb_workfn+0xb0/0x2f4 >>> process_one_work+0x1fc/0x444 >>> worker_thread+0x268/0x4b4 >>> kthread+0x13c/0x158 >>> ret_from_fork+0x10/0x18 >>> >>> Fixes: 955772787667 ("f2fs: drop inplace IO if fs status is abnormal") >> >> My bad, thanks for fixing this. >> >>> Signed-off-by: Jaegeuk Kim >>> --- >>> fs/f2fs/segment.c | 8 +++++--- >>> 1 file changed, 5 insertions(+), 3 deletions(-) >>> >>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >>> index c605415840b5..ae875557d693 100644 >>> --- a/fs/f2fs/segment.c >>> +++ b/fs/f2fs/segment.c >>> @@ -3577,9 +3577,11 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio) >>> if (fio->bio) { >>> struct bio *bio = *(fio->bio); >>> - bio->bi_status = BLK_STS_IOERR; >>> - bio_endio(bio); >>> - fio->bio = NULL; >>> + if (bio) { >>> + bio->bi_status = BLK_STS_IOERR; >>> + bio_endio(bio); >>> + fio->bio = NULL; >> >> fio->bio points a bio assigned in writepages(), so it should reset >> that bio to NULL by *(fio->bio) = NULL. > > Good timing. I hit other kernel panic, and it seems this is the root cause. > Let me give it a try. :) > > --- v2 --- > > Unable to handle kernel NULL pointer dereference at virtual address 000000000000001a > pc : f2fs_inplace_write_data+0x144/0x208 > lr : f2fs_inplace_write_data+0x134/0x208 > Call trace: > f2fs_inplace_write_data+0x144/0x208 > f2fs_do_write_data_page+0x270/0x770 > f2fs_write_single_data_page+0x47c/0x830 > __f2fs_write_data_pages+0x444/0x98c > f2fs_write_data_pages.llvm.16514453770497736882+0x2c/0x38 > do_writepages+0x58/0x118 > __writeback_single_inode+0x44/0x300 > writeback_sb_inodes+0x4b8/0x9c8 > wb_writeback+0x148/0x42c > wb_do_writeback+0xc8/0x390 > wb_workfn+0xb0/0x2f4 > process_one_work+0x1fc/0x444 > worker_thread+0x268/0x4b4 > kthread+0x13c/0x158 > ret_from_fork+0x10/0x18 > > Fixes: 955772787667 ("f2fs: drop inplace IO if fs status is abnormal") > Signed-off-by: Jaegeuk Kim Reviewed-by: Chao Yu Thanks, 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=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 1A2D9C433B4 for ; Tue, 11 May 2021 06:03:18 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF0B261926; Tue, 11 May 2021 06:03:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF0B261926 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.92.3) (envelope-from ) id 1lgLUA-0002Vw-Ui; Tue, 11 May 2021 06:03:14 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) (envelope-from ) id 1lgLU8-0002Vk-6Z for linux-f2fs-devel@lists.sourceforge.net; Tue, 11 May 2021 06:03:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:CC:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=yQzSbA+cux6cJ+eVTlt7vpMasxCFNtAXKFG1MuuvVnk=; b=QXx5Zy9SRYIxKoamI0/YIs5AvE eko10LqgHT16h1JuNQTke1fgwD+D8AMqApBlesRl0kY4aAYqiIoCgeH5jruQahuqqoArYkhoveXAB 2UVudVOIpaxvG6TV7+u4JJO+UmEZRyiw1WI65BoNgliBXgP8KAdyQ741IGOWbq8f5X7E=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:CC:To:Subject:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=yQzSbA+cux6cJ+eVTlt7vpMasxCFNtAXKFG1MuuvVnk=; b=FoMtw4I6XVldnsPNKt4EE9Bkde s/Pcxs1/SOQgK5UycjoF670TulsSYKT7XoTKHAzzxRsdW/z/1SWQnZtGzVeCHMVFGR29P2pV47Pjl NV0wMC9ZCej52b5YAfThk7OyE9EdMTImrcBRrpPXVWKqpHqTgEHERgs8ergKx1sZIa6k=; Received: from szxga05-in.huawei.com ([45.249.212.191]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1lgLU2-0006ie-Gi for linux-f2fs-devel@lists.sourceforge.net; Tue, 11 May 2021 06:03:12 +0000 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FfS1M0VLwzPwLd; Tue, 11 May 2021 13:59:35 +0800 (CST) Received: from [10.136.110.154] (10.136.110.154) by smtp.huawei.com (10.3.19.201) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 11 May 2021 14:02:54 +0800 To: Jaegeuk Kim References: <20210510142804.511265-1-jaegeuk@kernel.org> <9df7d088-3580-122b-60a3-799ea665cfeb@huawei.com> From: Chao Yu Message-ID: Date: Tue, 11 May 2021 14:02:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Originating-IP: [10.136.110.154] X-CFilter-Loop: Reflected X-Headers-End: 1lgLU2-0006ie-Gi Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid null pointer access when handling IPU error X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 2021/5/11 13:07, Jaegeuk Kim wrote: > On 05/11, Chao Yu wrote: >> On 2021/5/10 22:28, Jaegeuk Kim wrote: >>> Unable to handle kernel NULL pointer dereference at virtual address 000000000000001a >>> pc : f2fs_inplace_write_data+0x144/0x208 >>> lr : f2fs_inplace_write_data+0x134/0x208 >>> Call trace: >>> f2fs_inplace_write_data+0x144/0x208 >>> f2fs_do_write_data_page+0x270/0x770 >>> f2fs_write_single_data_page+0x47c/0x830 >>> __f2fs_write_data_pages+0x444/0x98c >>> f2fs_write_data_pages.llvm.16514453770497736882+0x2c/0x38 >>> do_writepages+0x58/0x118 >>> __writeback_single_inode+0x44/0x300 >>> writeback_sb_inodes+0x4b8/0x9c8 >>> wb_writeback+0x148/0x42c >>> wb_do_writeback+0xc8/0x390 >>> wb_workfn+0xb0/0x2f4 >>> process_one_work+0x1fc/0x444 >>> worker_thread+0x268/0x4b4 >>> kthread+0x13c/0x158 >>> ret_from_fork+0x10/0x18 >>> >>> Fixes: 955772787667 ("f2fs: drop inplace IO if fs status is abnormal") >> >> My bad, thanks for fixing this. >> >>> Signed-off-by: Jaegeuk Kim >>> --- >>> fs/f2fs/segment.c | 8 +++++--- >>> 1 file changed, 5 insertions(+), 3 deletions(-) >>> >>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >>> index c605415840b5..ae875557d693 100644 >>> --- a/fs/f2fs/segment.c >>> +++ b/fs/f2fs/segment.c >>> @@ -3577,9 +3577,11 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio) >>> if (fio->bio) { >>> struct bio *bio = *(fio->bio); >>> - bio->bi_status = BLK_STS_IOERR; >>> - bio_endio(bio); >>> - fio->bio = NULL; >>> + if (bio) { >>> + bio->bi_status = BLK_STS_IOERR; >>> + bio_endio(bio); >>> + fio->bio = NULL; >> >> fio->bio points a bio assigned in writepages(), so it should reset >> that bio to NULL by *(fio->bio) = NULL. > > Good timing. I hit other kernel panic, and it seems this is the root cause. > Let me give it a try. :) > > --- v2 --- > > Unable to handle kernel NULL pointer dereference at virtual address 000000000000001a > pc : f2fs_inplace_write_data+0x144/0x208 > lr : f2fs_inplace_write_data+0x134/0x208 > Call trace: > f2fs_inplace_write_data+0x144/0x208 > f2fs_do_write_data_page+0x270/0x770 > f2fs_write_single_data_page+0x47c/0x830 > __f2fs_write_data_pages+0x444/0x98c > f2fs_write_data_pages.llvm.16514453770497736882+0x2c/0x38 > do_writepages+0x58/0x118 > __writeback_single_inode+0x44/0x300 > writeback_sb_inodes+0x4b8/0x9c8 > wb_writeback+0x148/0x42c > wb_do_writeback+0xc8/0x390 > wb_workfn+0xb0/0x2f4 > process_one_work+0x1fc/0x444 > worker_thread+0x268/0x4b4 > kthread+0x13c/0x158 > ret_from_fork+0x10/0x18 > > Fixes: 955772787667 ("f2fs: drop inplace IO if fs status is abnormal") > Signed-off-by: Jaegeuk Kim Reviewed-by: Chao Yu Thanks, _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel