linux/fs/ubifs
Zhihao Cheng 7efc34b53b ubifs: Fix adding orphan entry twice for the same inode
The tmpfile could be added into orphan list twice, first time is
creation, the second time is removing after it is linked. The orphan
entry could be added twice for tmpfile if following sequence is
satisfied:

ubifs_tmpfile
 ubifs_jnl_update
  ubifs_add_orphan // first time to add orphan entry

    P1                        P2
ubifs_link                 do_commit
                            ubifs_orphan_start_commit
			     orphan->cmt = 1
 ubifs_delete_orphan
  orphan_delete
   if (orph->cmt)
    orph->del = 1; // orphan entry is not deleted from tree
    return
ubifs_unlink
 ubifs_jnl_update
  ubifs_add_orphan
   orphan_add // found old orphan entry, second time to add orphan entry
    ubifs_err(c, "orphaned twice")
    return -EINVAL // unlink failed!
                            ubifs_orphan_end_commit
			     erase_deleted // delete old orphan entry
			      rb_erase(&orphan->rb, &c->orph_tree)

Fix it by removing orphan entry from orphan tree in advance, rather than
remove it from orphan tree in committing process.

Fixes: 32fe905c17 ("ubifs: Fix O_TMPFILE corner case in ubifs_link()")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=218672
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
2024-07-12 21:39:17 +02:00
..
auth.c ubifs: auth.c: fix kernel-doc function prototype warning 2024-01-05 16:34:39 +01:00
budget.c ubifs: Reserve one leb for each journal head while doing budget 2023-02-02 21:13:40 +01:00
commit.c ubifs: Check @c->dirty_[n|p]n_cnt and @c->nroot state under @c->lp_mutex 2024-01-05 17:03:41 +01:00
compress.c ubifs: Remove return in compr_exit() 2023-04-21 22:31:03 +02:00
crypto.c fscrypt: make the bounce page pool opt-in instead of opt-out 2023-09-24 23:03:09 -07:00
debug.c ubifs: dbg_check_idx_size: Fix kmemleak if loading znode failed 2024-02-25 21:40:11 +01:00
debug.h ubifs: ubifs_dump_sleb: Remove unused function 2020-12-13 22:12:38 +01:00
dir.c Revert "ubifs: ubifs_symlink: Fix memleak of inode->i_link in error path" 2024-07-12 21:35:00 +02:00
file.c ubifs: Convert populate_page() to take a folio 2024-02-25 21:08:02 +01:00
find.c ubifs: fix function pointer cast warnings 2024-02-25 21:22:21 +01:00
gc.c ubifs: read-only if LEB may always be taken in ubifs_garbage_collect 2021-12-23 22:30:38 +01:00
io.c ubifs: Fix kernel-doc 2023-02-02 21:13:53 +01:00
ioctl.c ubifs: convert to ctime accessor functions 2023-07-24 10:30:05 +02:00
journal.c ubifs: Queue up space reservation tasks if retrying many times 2024-02-25 22:09:27 +01:00
Kconfig fscrypt: Allow modular crypto algorithms 2019-12-31 10:33:51 -06:00
key.h ubifs: allow both hash and disk name to be provided in no-key names 2020-01-22 14:49:56 -08:00
log.c ubifs: remove unnecessary check in ubifs_log_start_commit 2019-07-08 19:43:51 +02:00
lprops.c ubifs: fix function pointer cast warnings 2024-02-25 21:22:21 +01:00
lpt_commit.c ubifs: Remove unreachable code in dbg_check_ltab_lnum 2024-02-25 21:29:30 +01:00
lpt.c ubifs: Fix the printing type of c->big_lpt 2020-12-13 21:57:10 +01:00
Makefile ubifs: Export filesystem error counters 2021-12-23 20:23:42 +01:00
master.c ubifs: Fix spelling mistakes 2021-06-22 09:21:39 +02:00
misc.c
misc.h ubifs: misc.h: delete a duplicated word 2020-08-02 22:59:03 +02:00
orphan.c ubifs: Fix adding orphan entry twice for the same inode 2024-07-12 21:39:17 +02:00
recovery.c ubifs: Pass node length in all node dumping callers 2020-12-13 22:12:32 +01:00
replay.c ubifs: describe function parameters 2024-01-05 16:35:25 +01:00
sb.c ubifs: Default to zstd compression 2021-04-15 22:00:26 +02:00
scan.c ubifs: Pass node length in all node dumping callers 2020-12-13 22:12:32 +01:00
shrinker.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 336 2019-06-05 17:37:07 +02:00
super.c This pull request contains updates for UBI and UBIFS: 2024-03-21 15:09:29 -07:00
sysfs.c ubifs: make kobj_type structures constant 2023-02-13 22:29:54 +01:00
tnc_commit.c treewide: use get_random_u32_below() instead of deprecated function 2022-11-18 02:15:15 +01:00
tnc_misc.c ubifs: dbg_check_idx_size: Fix kmemleak if loading znode failed 2024-02-25 21:40:11 +01:00
tnc.c ubifs: dbg_check_idx_size: Fix kmemleak if loading znode failed 2024-02-25 21:40:11 +01:00
ubifs-media.h ubifs: Add support for zstd compression. 2019-07-08 19:43:53 +02:00
ubifs.h ubifs: Don't add xattr inode into orphan area 2024-07-12 21:33:50 +02:00
xattr.c ubifs: move ubifs_xattr_handlers to .rodata 2023-10-10 13:49:20 +02:00