From nobody Tue Apr 7 05:10:14 2026 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 66A85C4332F for ; Tue, 11 Oct 2022 03:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229809AbiJKDZy (ORCPT ); Mon, 10 Oct 2022 23:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbiJKDZl (ORCPT ); Mon, 10 Oct 2022 23:25:41 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 771DC7B2A7 for ; Mon, 10 Oct 2022 20:25:39 -0700 (PDT) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Mmh1014H6zpVTK; Tue, 11 Oct 2022 11:22:28 +0800 (CST) Received: from kwepemm600013.china.huawei.com (7.193.23.68) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 11 Oct 2022 11:25:23 +0800 Received: from huawei.com (10.175.127.227) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 11 Oct 2022 11:25:22 +0800 From: Zhihao Cheng To: , , CC: , , , Subject: [PATCH 1/6] ubifs: Rectify space budget for ubifs_symlink() if symlink is encrypted Date: Tue, 11 Oct 2022 11:47:27 +0800 Message-ID: <20221011034732.45605-2-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221011034732.45605-1-chengzhihao1@huawei.com> References: <20221011034732.45605-1-chengzhihao1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600013.china.huawei.com (7.193.23.68) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Fix bad space budget when symlink file is encrypted. Bad space budget may let make_reservation() return with -ENOSPC, which could turn ubifs to read-only mode in do_writepage() process. Fetch a reproducer in [Link]. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D216490 Fixes: ca7f85be8d6cf9 ("ubifs: Add support for encrypted symlinks") Signed-off-by: Zhihao Cheng --- fs/ubifs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index bc11276301fd..4705d9a77357 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -1150,7 +1150,6 @@ static int ubifs_symlink(struct user_namespace *mnt_u= serns, struct inode *dir, int err, sz_change, len =3D strlen(symname); struct fscrypt_str disk_link; struct ubifs_budget_req req =3D { .new_ino =3D 1, .new_dent =3D 1, - .new_ino_d =3D ALIGN(len, 8), .dirtied_ino =3D 1 }; struct fscrypt_name nm; =20 @@ -1166,6 +1165,7 @@ static int ubifs_symlink(struct user_namespace *mnt_u= serns, struct inode *dir, * Budget request settings: new inode, new direntry and changing parent * directory inode. */ + req.new_ino_d =3D ALIGN(disk_link.len - 1, 8); err =3D ubifs_budget_space(c, &req); if (err) return err; --=20 2.31.1