From: Sascha Hauer Date: Wed, 20 Jan 2021 13:12:53 +0000 (+0100) Subject: ubifs: Fix off-by-one error X-Git-Tag: v5.12-rc1~135^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d984bcf5766dbdbe95d325bb8a1b49a996fecfd4;p=thirdparty%2Fkernel%2Flinux.git ubifs: Fix off-by-one error 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 Signed-off-by: Richard Weinberger --- diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index 03410ae0813a7..2857e64d673d1 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c @@ -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; } diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c index a0b9b349efe65..842d5f14545d6 100644 --- a/fs/ubifs/xattr.c +++ b/fs/ubifs/xattr.c @@ -498,7 +498,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",