mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
60eb3b9c9f
'ui->dirty' is not protected by 'ui_mutex' in function do_tmpfile() which
may race with ubifs_write_inode[wb_workfn] to access/update 'ui->dirty',
finally dirty space is released twice.
open(O_TMPFILE) wb_workfn
do_tmpfile
ubifs_budget_space(ino_req = { .dirtied_ino = 1})
d_tmpfile // mark inode(tmpfile) dirty
ubifs_jnl_update // without holding tmpfile's ui_mutex
mark_inode_clean(ui)
if (ui->dirty)
ubifs_release_dirty_inode_budget(ui) // release first time
ubifs_write_inode
mutex_lock(&ui->ui_mutex)
ubifs_release_dirty_inode_budget(ui)
// release second time
mutex_unlock(&ui->ui_mutex)
ui->dirty = 0
Run generic/476 can reproduce following message easily
(See reproducer in [Link]):
UBIFS error (ubi0:0 pid 2578): ubifs_assert_failed [ubifs]: UBIFS assert
failed: c->bi.dd_growth >= 0, in fs/ubifs/budget.c:554
UBIFS warning (ubi0:0 pid 2578): ubifs_ro_mode [ubifs]: switched to
read-only mode, error -22
Workqueue: writeback wb_workfn (flush-ubifs_0_0)
Call Trace:
ubifs_ro_mode+0x54/0x60 [ubifs]
ubifs_assert_failed+0x4b/0x80 [ubifs]
ubifs_release_budget+0x468/0x5a0 [ubifs]
ubifs_release_dirty_inode_budget+0x53/0x80 [ubifs]
ubifs_write_inode+0x121/0x1f0 [ubifs]
...
wb_workfn+0x283/0x7b0
Fix it by holding tmpfile ubifs inode lock during ubifs_jnl_update().
Similar problem exists in whiteout renaming, but previous fix("ubifs:
Rename whiteout atomically") has solved the problem.
Fixes:
|
||
---|---|---|
.. | ||
auth.c | ||
budget.c | ||
commit.c | ||
compress.c | ||
crypto.c | ||
debug.c | ||
debug.h | ||
dir.c | ||
file.c | ||
find.c | ||
gc.c | ||
io.c | ||
ioctl.c | ||
journal.c | ||
Kconfig | ||
key.h | ||
log.c | ||
lprops.c | ||
lpt_commit.c | ||
lpt.c | ||
Makefile | ||
master.c | ||
misc.c | ||
misc.h | ||
orphan.c | ||
recovery.c | ||
replay.c | ||
sb.c | ||
scan.c | ||
shrinker.c | ||
super.c | ||
sysfs.c | ||
tnc_commit.c | ||
tnc_misc.c | ||
tnc.c | ||
ubifs-media.h | ||
ubifs.h | ||
xattr.c |