Skip to content

Commit

Permalink
ubifs: Fix off-by-one error
Browse files Browse the repository at this point in the history
[ Upstream commit d984bcf ]

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>
  • Loading branch information
saschahauer authored and gregkh committed Jul 20, 2021
1 parent aab881d commit 6bcc059
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fs/ubifs/journal.c
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/ubifs/xattr.c
Expand Up @@ -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",
Expand Down

0 comments on commit 6bcc059

Please sign in to comment.