2020-08-17 21:18:41

by Zhihao Cheng

[permalink] [raw]
Subject: [PATCH] ubifs: ubifs_jnl_change_xattr: Remove assertion 'nlink > 0' for host inode

Changing xattr of a temp file will trigger following assertion failed
and make ubifs turn into readonly filesystem:
ubifs_assert_failed [ubifs]: UBIFS assert failed: host->i_nlink > 0,
in fs/ubifs/journal.c:1801

Reproducer:
1. fd = open(__O_TMPFILE)
2. fsetxattr(fd, key, value2, XATTR_CREATE)
3. fsetxattr(fd, key, value2, XATTR_REPLACE)

Fix this by removing assertion 'nlink > 0' for host inode.

Reported-by: Chengsong Ke <[email protected]>
Signed-off-by: Zhihao Cheng <[email protected]>
---
fs/ubifs/journal.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index 4a5b06f8d812..0b9f686d1d42 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -1798,7 +1798,6 @@ int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode,
u8 hash[UBIFS_HASH_ARR_SZ];

dbg_jnl("ino %lu, ino %lu", host->i_ino, inode->i_ino);
- ubifs_assert(c, host->i_nlink > 0);
ubifs_assert(c, inode->i_nlink > 0);
ubifs_assert(c, mutex_is_locked(&host_ui->ui_mutex));

--
2.25.4


2020-09-13 18:43:48

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH] ubifs: ubifs_jnl_change_xattr: Remove assertion 'nlink > 0' for host inode

On Mon, Aug 17, 2020 at 4:29 PM Zhihao Cheng <[email protected]> wrote:
>
> Changing xattr of a temp file will trigger following assertion failed
> and make ubifs turn into readonly filesystem:
> ubifs_assert_failed [ubifs]: UBIFS assert failed: host->i_nlink > 0,
> in fs/ubifs/journal.c:1801
>
> Reproducer:
> 1. fd = open(__O_TMPFILE)
> 2. fsetxattr(fd, key, value2, XATTR_CREATE)
> 3. fsetxattr(fd, key, value2, XATTR_REPLACE)
>
> Fix this by removing assertion 'nlink > 0' for host inode.
>
> Reported-by: Chengsong Ke <[email protected]>
> Signed-off-by: Zhihao Cheng <[email protected]>

Applied to fixes, thanks!

--
Thanks,
//richard