Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp164394lqp; Tue, 11 Jun 2024 19:22:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU7IMdGKMS05Id/H5VFVto9/+bG/ieSDBtrLAe6iu4/EbuxOR01j7WhAWHyenqPq34uTTqs5BnLc1CKV9OgpoRyH0RoaFS1GAavty9YdA== X-Google-Smtp-Source: AGHT+IFz5A3EROBExNuwaHkpDhvcp8cPPHUyQAamBlp7olnRnF4lDhuwEnuSGP68GkaHT0AZLL+z X-Received: by 2002:a05:6102:244d:b0:48d:9607:1563 with SMTP id ada2fe7eead31-48d96071926mr136164137.0.1718158936041; Tue, 11 Jun 2024 19:22:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718158936; cv=pass; d=google.com; s=arc-20160816; b=b9mtH/pJ7jwBlshNAUuV5vmoYLHkWDHL2MTrLTqBdUfDN0T0RtTpoJ8kDkfyyoFeLa nj9FyTatslFc+0PP1Wn8DoPoPEuC8dewpn43v6/77PgcS4NixAh+13bZwlEcd2a+f+c0 16WGEAu8w7pQfv3wycSKXy70QgLZM0oCrgKhRbtnPytU8VY79bNRxW7sETL6cwE/K5zC IkYZZj8CvxnQnUkBV495JY4Qa9Cldl6lO55/6vIIinIvRhaWEs+uds++IuEN5HKZY0xL a5qu3Ox6zSZQllwGa7S1fF8kGIgvqsK959iQhMyA2y8+6idw3R1FkVfV9Etr42xW6ZnT xOfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:dlp-filter:cms-type:content-transfer-encoding:date :message-id:cc:to:from:sender:reply-to:subject:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:dkim-signature :dkim-filter; bh=aHiTLqz3DTEetGM77pTEUK8RRyp3MuomMyvuo5JbqcY=; fh=8BG01xWWu/8ci/33R5ShmZp2oR4keyRT6c7dnBLPoiI=; b=LAv5yKOGh5XRs3ibbWsSgrx5KnWsxAC1rMIFj7F6rMLQkaYd6zJY+4bMYFRSFKfeVf YHwa/XlRqB2CIEuqm3fA/Z5ZDLlPwUJQ6OMIiOnkdmyTpymePKo1vrLdi1eTMzRQhI84 KSLXQQByAEp2HDF+AJFo4Xng/dysrHrp1foFFxwvmY/y2ZX9WZfS7aWAcL/oUdfN/PpB Q3jxfKRLyLuE5VKM0ZXz2rGes88acJ1CBo5/XE5Es9c3E8QOpYGwQvOPlgCvD6yQeYNc 3OnBniTzUVzyRcpRca/AeamMfNC2NG3QomlxACixvarCElGfcWKW6j20QvkMSPmHanF2 dJow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=TWrSV3zL; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-210818-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210818-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-79552f20899si939399185a.40.2024.06.11.19.22.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 19:22:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210818-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=TWrSV3zL; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-210818-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210818-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B01531C23373 for ; Wed, 12 Jun 2024 02:22:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63FE0AD5E; Wed, 12 Jun 2024 02:21:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="TWrSV3zL" Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2E8B63BF for ; Wed, 12 Jun 2024 02:21:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718158884; cv=none; b=rMCgvWQfZWdHWjEtQPFnc/W7CilwMtLiEFzKdvecpGcqPk1LgLjATfh+xRpKINYUsyn5m+T836b6lj9EcvEup3m5Feb5IQ5h9kL0Mq5QuEsWB591ATEl9NX1A2PBcBpSCo3VlNqEFLDq9E/M9hb4wvx4zyfv1iapIYyz0e5tZPc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718158884; c=relaxed/simple; bh=2RfIPyM2BaJyeNcdDcFiSSt+OrKJFVJYbx/rL5T1DGU=; h=Mime-Version:Subject:From:To:CC:Message-ID:Date:Content-Type: References; b=Eu1w5ar27tdDNXePSWv+M2Dzfa4HZ91SQbclkFgI0PV4y3n9HFU0NQLf4sStqupVrW+5CIUB+VCZvAqusNWxuLNJLBAS6N63LuySgMmDfRZlYI8oaUb8QeAi3Ewh3Sf5n9N7Vw1+9TQdA83Lc3H109h9Epjc+L1w3f/jpyWQ7iU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=TWrSV3zL; arc=none smtp.client-ip=203.254.224.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20240612022114epoutp0204a5be2943cc8bb6afc89282277ef6fc~YIGSM1Rm61703117031epoutp02q for ; Wed, 12 Jun 2024 02:21:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20240612022114epoutp0204a5be2943cc8bb6afc89282277ef6fc~YIGSM1Rm61703117031epoutp02q 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Subject: [PATCH] f2fs: fix convert inline inode on readonly mode Reply-To: daejun7.park@samsung.com Sender: Daejun Park From: Daejun Park To: "jaegeuk@kernel.org" , "chao@kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" CC: Daejun Park , Dongjin Kim , Seokhwan Kim , Yonggil Song , Eunhee Rho , Jaeyoon Choi , Nayeon Kim , Siwoo Jung 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsWy7bCmua4kW2aawZktTBanp55lsnh5SNNi 1YNwix8nTSx+Pulgs+jf3c5i8WT9LGaLS4vcLS7vmsNm0fLHyeL8xNdMFqs65jJaTD1/hMmB 12PTqk42j90LPjN59G1ZxejxeZNcAEtUtk1GamJKapFCal5yfkpmXrqt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Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240612022012epcms2p77300b5130d18b0397c9fc2877704949d References: 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(-) 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; -- 2.25.1