]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ubifs: Fix off-by-one error
authorSascha Hauer <s.hauer@pengutronix.de>
Wed, 20 Jan 2021 13:12:53 +0000 (14:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:05:51 +0000 (16:05 +0200)
[ Upstream commit d984bcf5766dbdbe95d325bb8a1b49a996fecfd4 ]

An inode is allowed to have ubifs_xattr_max_cnt() xattrs, so we must
complain only when an inode has more xattrs, having exactly
ubifs_xattr_max_cnt() xattrs is fine.
With this the maximum number of xattrs can be created without hitting
the "has too many xattrs" warning when removing it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ubifs/journal.c
fs/ubifs/xattr.c

index 091c2ad8f21113ac7f04f9b8d89e59b57027880d..7927dea2babac6ee8a68485e08cdad63eb6406df 100644 (file)
@@ -881,7 +881,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
                struct inode *xino;
                struct ubifs_dent_node *xent, *pxent = NULL;
 
-               if (ui->xattr_cnt >= ubifs_xattr_max_cnt(c)) {
+               if (ui->xattr_cnt > ubifs_xattr_max_cnt(c)) {
                        ubifs_err(c, "Cannot delete inode, it has too much xattrs!");
                        goto out_release;
                }
index 09280796fc61075224919bc974b4d4f47c7f2a33..17745f5462f02e863988991b33a546bd2c35b830 100644 (file)
@@ -512,7 +512,7 @@ int ubifs_purge_xattrs(struct inode *host)
        struct fscrypt_name nm = {0};
        int err;
 
-       if (ubifs_inode(host)->xattr_cnt < ubifs_xattr_max_cnt(c))
+       if (ubifs_inode(host)->xattr_cnt <= ubifs_xattr_max_cnt(c))
                return 0;
 
        ubifs_warn(c, "inode %lu has too many xattrs, doing a non-atomic deletion",