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,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 A03EEC433ED for ; Tue, 11 May 2021 01:29:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 733FB6162D for ; Tue, 11 May 2021 01:29:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230139AbhEKBaQ (ORCPT ); Mon, 10 May 2021 21:30:16 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2683 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbhEKBaQ (ORCPT ); Mon, 10 May 2021 21:30:16 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FfKyF6NNmz1BHww; Tue, 11 May 2021 09:26:29 +0800 (CST) Received: from [10.136.110.154] (10.136.110.154) by smtp.huawei.com (10.3.19.203) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 11 May 2021 09:29:07 +0800 Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid null pointer access when handling IPU error To: Jaegeuk Kim , , References: <20210510142804.511265-1-jaegeuk@kernel.org> From: Chao Yu Message-ID: <9df7d088-3580-122b-60a3-799ea665cfeb@huawei.com> Date: Tue, 11 May 2021 09:29:07 +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: <20210510142804.511265-1-jaegeuk@kernel.org> 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/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. Thanks, > + } > } > return err; > } > 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,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 D0448C433B4 for ; Tue, 11 May 2021 01:29:31 +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 8C22D611F0; Tue, 11 May 2021 01:29:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C22D611F0 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 1lgHDF-0007m3-H0; Tue, 11 May 2021 01:29:29 +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 1lgHDD-0007lv-VX for linux-f2fs-devel@lists.sourceforge.net; Tue, 11 May 2021 01:29:27 +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:To:Subject:Sender:Reply-To:Cc: 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=4SNxkZQUNjhEz7k5rD1Zm5mRskXf/rDEPVkHBIq1Gz0=; b=MyymW1k9aC633+2A5ZwPD6ZLua cAlqF63MwUgBuvjhgbWlyXcL5wqKKdxuZx6tICggrSxI3C+FIjEIFpSt429YPKznuy2PVet2lg0lY UxiB5Qt1GPMmMHInsWs5CVykOQsjohKY1k1EyRUlB17AC9/BdJ6CdEEupjUjVzt9nkB8=; 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:To:Subject:Sender:Reply-To:Cc: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=4SNxkZQUNjhEz7k5rD1Zm5mRskXf/rDEPVkHBIq1Gz0=; b=X5l0WLAvSmNjuMyT7Aj7qcibcC d2IEdmjdaWEdYiRAxTLesIDI0h7uIhPVJ/QHALfBjcnRKN6p8Qvo/MhBnFusbsNGFJtAET2Lak755 5esvqmK9ww7orgPTv1SUSg1f7GxNyUNSZpwlDwA3Mh7VN3vH9WqIXVrXhEIqiEn8dyRM=; Received: from szxga04-in.huawei.com ([45.249.212.190]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1lgHD5-0001cw-DM for linux-f2fs-devel@lists.sourceforge.net; Tue, 11 May 2021 01:29:27 +0000 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FfKyF6NNmz1BHww; Tue, 11 May 2021 09:26:29 +0800 (CST) Received: from [10.136.110.154] (10.136.110.154) by smtp.huawei.com (10.3.19.203) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 11 May 2021 09:29:07 +0800 To: Jaegeuk Kim , , References: <20210510142804.511265-1-jaegeuk@kernel.org> From: Chao Yu Message-ID: <9df7d088-3580-122b-60a3-799ea665cfeb@huawei.com> Date: Tue, 11 May 2021 09:29:07 +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: <20210510142804.511265-1-jaegeuk@kernel.org> Content-Language: en-US X-Originating-IP: [10.136.110.154] X-CFilter-Loop: Reflected X-Headers-End: 1lgHD5-0001cw-DM 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: , 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/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. Thanks, > + } > } > return err; > } > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel