From patchwork Wed Jun 12 02:20:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daejun Park X-Patchwork-Id: 13694370 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 4CBF4C27C78 for ; Wed, 12 Jun 2024 02:21:25 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sHDc3-0001oi-2e; Wed, 12 Jun 2024 02:21:23 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sHDc2-0001oc-4U for linux-f2fs-devel@lists.sourceforge.net; Wed, 12 Jun 2024 02:21:22 +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=aHiTLqz3DTEetGM77pTEUK8RRyp3MuomMyvuo5JbqcY=; b=F+GQNMeQ4MzB6D44UQrIKgeMYZ DVhJ1jQ/EHCkxpkW73dQ4l+bc3y8XlT80SC/5ZS3B4okNcw1yi0A1JP9jB7JPRvYSXMXik6Uflz/N g83ULfUGHl8SV8xrWUqH8FuMq31lhT2UgmmqWdHVPdVDAwuRFBIsOICF0iLRUo6r+zP8=; 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=aHiTLqz3DTEetGM77pTEUK8RRyp3MuomMyvuo5JbqcY=; b=c UjsnnqAxoBQOq9l60NnwY0erWLwDgNCPeergTOLdfPseCtjEimKudUNq/7C5Zho3RZWl80uNUbNNr 5ooKiuFvpYXwGXYR0fW9Y4VF6AS1lmgM5q3AlyPMfkk5I3BY1hum/+71fKYff1c1ep/MXkXTElrYx DNBZj2Qjc3k2+AnE=; 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 1sHDc2-0001fZ-23 for linux-f2fs-devel@lists.sourceforge.net; Wed, 12 Jun 2024 02:21:22 +0000 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240612022114epoutp02c1f1261ede274c303d72df5b166ba08d~YIGSMb5S_1733417334epoutp02E for ; Wed, 12 Jun 2024 02:21:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240612022114epoutp02c1f1261ede274c303d72df5b166ba08d~YIGSMb5S_1733417334epoutp02E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1718158874; bh=aHiTLqz3DTEetGM77pTEUK8RRyp3MuomMyvuo5JbqcY=; h=Subject:Reply-To:From:To:CC:Date:References:From; b=TWrSV3zL3WX7ncK0gCU8tR+LluTJOxaTm4/cj6sSMmFtSTxJdZVCculQFuGzzO0cc K1mOXeRpDRuYGApD9KCe9qWXUO1Jq+ZY9F/I7cHrdCu3w6t1aBZmDagns3molgr6cr Zd5O/mscRw5gs+KuQ4aX3n9zAQ+KnP798i9hpL+c= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20240612022113epcas2p388bb2006691b6ca36d3fe0ce4a07c590~YIGRpYg_n2118421184epcas2p34; Wed, 12 Jun 2024 02:21:13 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.98]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4VzTmn0hqqz4x9Q6; Wed, 12 Jun 2024 02:21:13 +0000 (GMT) X-AuditID: b6c32a47-4f767a800000264e-db-666906188eb0 Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 78.A3.09806.81609666; Wed, 12 Jun 2024 11:21:13 +0900 (KST) Mime-Version: 1.0 From: Daejun Park To: "jaegeuk@kernel.org" , "chao@kernel.org" , "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: <20240612022012epcms2p77300b5130d18b0397c9fc2877704949d@epcms2p7> Date: Wed, 12 Jun 2024 11:20:12 +0900 X-CMS-MailID: 20240612022012epcms2p77300b5130d18b0397c9fc2877704949d X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsWy7bCmua4kW2aawZktTBanp55lsnh5SNNi 1YNwix8nTSx+Pulgs+jf3c5i8WT9LGaLS4vcLS7vmsNm0fLHy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q9Z6k+1kjQfNvhbP2356dFt evneJ7uItf+W7vUq8VRiKc5INNRiLipOBACaB+P9KwQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240612022012epcms2p77300b5130d18b0397c9fc2877704949d References: X-Headers-End: 1sHDc2-0001fZ-23 Subject: [f2fs-dev] [PATCH] f2fs: fix convert inline inode on readonly mode 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 syzbot reported a bug in f2fs_vm_page_mkwrite() which checks for f2fs_has_inline_data(inode). The bug was caused by f2fs_convert_inline_inode() not returning an error when called on a read-only filesystem, but returning with the inline attribute as set. This patch fixes the problem by ensuring that f2fs_convert_inline_inode() returns -EROFS on readonly. Fixes: ec2ddf499402 ("f2fs: don't allow any writes on readonly mount") Reported-by: syzbot+f195123a45ad487ca66c@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=f195123a45ad487ca66c Signed-off-by: Daejun Park --- fs/f2fs/inline.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index 7638d0d7b7ee..ae1d8f2d82c9 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -203,10 +203,12 @@ int f2fs_convert_inline_inode(struct inode *inode) struct page *ipage, *page; int err = 0; - if (!f2fs_has_inline_data(inode) || - f2fs_hw_is_readonly(sbi) || f2fs_readonly(sbi->sb)) + if (!f2fs_has_inline_data(inode)) return 0; + if (unlikely(f2fs_hw_is_readonly(sbi) || f2fs_readonly(sbi->sb))) + return -EROFS; + err = f2fs_dquot_initialize(inode); if (err) return err;