From patchwork Thu Jul 4 01:01:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daejun Park X-Patchwork-Id: 13723100 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0A93DC31D97 for ; Thu, 4 Jul 2024 01:02:42 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sPArv-0002KB-He; Thu, 04 Jul 2024 01:02:40 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sPArr-0002K3-HT for linux-f2fs-devel@lists.sourceforge.net; Thu, 04 Jul 2024 01:02:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:Content-Type:Content-Transfer-Encoding: Date:Message-ID:CC:To:From:Sender:Reply-To:Subject:Mime-Version:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=SRywyYtqWBt1JqxXnaHByQq7LKdm/U99W5lYcjMpL4o=; b=hCMW+iqDB2PnaDP0ukowF3SD6G cM+erWeHlsNpKvgStbZRUQhLFlnxbLguWSgJbFifEsN4pnxUf6uvlp7OhNmtyesom6CBAc7C48Xt7 oDRwwO3/jPG5iheI6gjtcGccykkWum7V5kt7VfdYrEz/U97h1UDc3imn6akb+LdaLtKM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:Content-Type:Content-Transfer-Encoding:Date:Message-ID:CC:To: From:Sender:Reply-To:Subject:Mime-Version:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=SRywyYtqWBt1JqxXnaHByQq7LKdm/U99W5lYcjMpL4o=; b=E 5msUQUyfEm0jocWk9KSna/gpVwCeJs+oVHiVJTDlLpZ5txC2q+JZJC20rRC8JXKwHowte1+Pic2p2 fcNaeCdDob/ux0HyE+r0ihzJyhQwgpAJe2tbObFodPHuOS1qQkce7BB4iRx8AbaDSd+pGxDzR/YHu sBodBpijrh0h9gP4=; Received: from mailout2.samsung.com ([203.254.224.25]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1sPArs-0003Ei-3p for linux-f2fs-devel@lists.sourceforge.net; Thu, 04 Jul 2024 01:02:36 +0000 Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240704010223epoutp025b6ce6d6526e696817339d02c8c6b5b6~e3NuAAY531137311373epoutp02B for ; Thu, 4 Jul 2024 01:02:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240704010223epoutp025b6ce6d6526e696817339d02c8c6b5b6~e3NuAAY531137311373epoutp02B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1720054943; bh=SRywyYtqWBt1JqxXnaHByQq7LKdm/U99W5lYcjMpL4o=; h=Subject:Reply-To:From:To:CC:Date:References:From; b=YHsj+YGWXPGSmlhEXGHg6nZcnKBSyW034s0SzLYCLJEEkR9qXfM5ewvEfeZ6C02mJ tEVlbzZ6Sh7jSkJlX//yLZyD4EeYeunKdZOrBpGCs+zFNO0t5N8u8p7xXFgzc/mK64 0NWQeea+YRCguhyQ+b/rnuGyFo9PLIWO5/IR+Hmg= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20240704010222epcas2p243c529630d475eb5cbdafed0775a6576~e3NtasxUr1175911759epcas2p2d; Thu, 4 Jul 2024 01:02:22 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.102]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4WDyzd75Fxz4x9QN; Thu, 4 Jul 2024 01:02:21 +0000 (GMT) X-AuditID: b6c32a45-1c7ff70000002678-3a-6685f49d3e2d Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id B3.92.09848.D94F5866; Thu, 4 Jul 2024 10:02:21 +0900 (KST) Mime-Version: 1.0 From: Daejun Park To: "jaegeuk@kernel.org" , "chao@kernel.org" , "daehojeong@google.com" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20240704010121epcms2p4cff8b25d976d4a1b820ba18f1eb5aa90@epcms2p4> Date: Thu, 04 Jul 2024 10:01:21 +0900 X-CMS-MailID: 20240704010121epcms2p4cff8b25d976d4a1b820ba18f1eb5aa90 X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLJsWRmVeSWpSXmKPExsWy7bCmme7cL61pBo+fWlicnnqWyeLlIU2L qe17GS1WPQi3+HHSxKJ/dzuLxZP1s5gtLi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L6/m2X1p88H5n25cnDn9E4fol4dVxi79bB8mT4/ruVth Z/n6eJL748OCs5aWfTzOqvnfTomlOCPRUIu5qDgRAHRtqtMwBAAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240704010121epcms2p4cff8b25d976d4a1b820ba18f1eb5aa90 References: X-Headers-End: 1sPArs-0003Ei-3p Subject: [f2fs-dev] [PATCH] f2fs: fix null reference error when checking end of zone 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: , Reply-To: daejun7.park@samsung.com Cc: Nayeon Kim , Siwoo Jung , Seokhwan Kim , Dongjin Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This patch fixes a potentially null pointer being accessed by is_end_zone_blkaddr() that checks the last block of a zone when f2fs is mounted as a single device. Fixes: e067dc3c6b9c ("f2fs: maintain six open zones for zoned devices") Signed-off-by: Daejun Park Reviewed-by: Chao Yu Reviewed-by: Daeho Jeong --- fs/f2fs/data.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index b6dcb3bcaef7..1aa7eefa659c 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -925,6 +925,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio) #ifdef CONFIG_BLK_DEV_ZONED static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr) { + struct block_device *bdev = sbi->sb->s_bdev; int devi = 0; if (f2fs_is_multi_device(sbi)) { @@ -935,8 +936,9 @@ static bool is_end_zone_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr) return false; } blkaddr -= FDEV(devi).start_blk; + bdev = FDEV(devi).bdev; } - return bdev_is_zoned(FDEV(devi).bdev) && + return bdev_is_zoned(bdev) && f2fs_blkz_is_seq(sbi, devi, blkaddr) && (blkaddr % sbi->blocks_per_blkz == sbi->blocks_per_blkz - 1); }