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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E96BEC6FD1F for ; Fri, 10 Mar 2023 14:40:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232695AbjCJOkh (ORCPT ); Fri, 10 Mar 2023 09:40:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232691AbjCJOkh (ORCPT ); Fri, 10 Mar 2023 09:40:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73DB05C115 for ; Fri, 10 Mar 2023 06:40:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0FBEA616F0 for ; Fri, 10 Mar 2023 14:40:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A32EC433D2; Fri, 10 Mar 2023 14:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678459235; bh=nASo2f4JR8ZSOoYzvCW9dDL1De1xlQ+pb1BhFDIja5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uy407Hls1Ha6INccJrJRuAdhAsAfxwvynnGETSK1cBdIbgx1Oifv5vgzXG0b5vnI7 rfdKAhQXSyzQCvtQARsYbzvI7E6LBuYZFJZqhkW7xkt6owGWyfwkFIQtcRugshg2G/ 5+ZFkuqliTN6jq2M6lNGLhXESz1+NV79rpHfziAs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhihao Cheng , Richard Weinberger , Sasha Levin Subject: [PATCH 5.4 294/357] ubifs: Rectify space budget for ubifs_xrename() Date: Fri, 10 Mar 2023 14:39:43 +0100 Message-Id: <20230310133747.734492728@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310133733.973883071@linuxfoundation.org> References: <20230310133733.973883071@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Zhihao Cheng [ Upstream commit 1b2ba09060e41adb356b9ae58ef94a7390928004 ] There is no space budget for ubifs_xrename(). It may let make_reservation() return with -ENOSPC, which could turn ubifs to read-only mode in do_writepage() process. Fix it by adding space budget for ubifs_xrename(). Fetch a reproducer in [Link]. Link: https://bugzilla.kernel.org/show_bug.cgi?id=216569 Fixes: 9ec64962afb170 ("ubifs: Implement RENAME_EXCHANGE") Signed-off-by: Zhihao Cheng Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- fs/ubifs/dir.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 0c012f8fabbb2..9a4f9563aceea 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -1538,6 +1538,10 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry, return err; } + err = ubifs_budget_space(c, &req); + if (err) + goto out; + lock_4_inodes(old_dir, new_dir, NULL, NULL); time = current_time(old_dir); @@ -1563,6 +1567,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry, unlock_4_inodes(old_dir, new_dir, NULL, NULL); ubifs_release_budget(c, &req); +out: fscrypt_free_filename(&fst_nm); fscrypt_free_filename(&snd_nm); return err; -- 2.39.2