Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3235391pxj; Mon, 10 May 2021 23:05:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybEvkhCppqmCjV5G9Ba7xWF+RjJhacrLnFCrBc6ZhnEhkyXzTpa41ss6sAheXB3UgsAsRS X-Received: by 2002:a6b:8b06:: with SMTP id n6mr20589250iod.87.1620713111665; Mon, 10 May 2021 23:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620713111; cv=none; d=google.com; s=arc-20160816; b=d12orv3q7BaiiUKaaf4paHDta0oc4fmVpiKihZTtjZvrbAnuuxOP1504Cixf+T8uIP vTSCdICmEM2nHNoTktPlIhCRWqWZCk1DOCT8hHQGKuXSNtK8bvUn/juEVGmbNEVYSLrw LFRnlHit7a6blYqVyVa6kmCs5shD3jCHIOkz/K7AU5g8LqfpcH4RPlAnvUpotdQqwatv Li1wpvYnTRV9HuxfCNLuNhoguz3/c48N12ROytrhjB3gj9oP/n/iiD8wwIeIN/68r2rL 4tUS7EfUn5ZaKrwVNYvUrOP6CNnvvf6v+B5u0AN3gNHDkSMgd7ptiSFNeopG96i6Yhc5 LyFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=yQzSbA+cux6cJ+eVTlt7vpMasxCFNtAXKFG1MuuvVnk=; b=WBu1n3nsQSVotxfhrPn53XOVSh46GAgbJdWKt9aWoTgeEvbLBSWz/nJToIXLcnVIgV tgDOLCE6M5uggZlY/qtGOazbcvDy0MmUDa4kwsOmJvh6L3lEKVHOJ0mA6R8I+QrjPi3E 3nFXaxfiXTP2ghxOi+i5uVLgZwK1vqRwcR+/rNHmV9+T7lNpPfjBgWR3mEDRqe17xzRq UFA3cxrVi4vednDDn8u5H5iZg+cERG1t9nhZuZYhXAR5nq4Xa50SzVTD+SPLWQCXUfHG YLY3ZJcEvv74edGbwas6SunAcOqNjp843PNHthpLfiQkpw7k6u97Cf+EqlXr++h1+e9J ml4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si18696264jas.111.2021.05.10.23.04.58; Mon, 10 May 2021 23:05:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230154AbhEKGEE (ORCPT + 99 others); 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,