WSL2-Linux-Kernel/fs/ubifs
Mårten Lindahl 43b2f7d690 ubifs: Fix memory leak in do_rename
[ Upstream commit 3a36d20e01 ]

If renaming a file in an encrypted directory, function
fscrypt_setup_filename allocates memory for a file name. This name is
never used, and before returning to the caller the memory for it is not
freed.

When running kmemleak on it we see that it is registered as a leak. The
report below is triggered by a simple program 'rename' that renames a
file in an encrypted directory:

  unreferenced object 0xffff888101502840 (size 32):
    comm "rename", pid 9404, jiffies 4302582475 (age 435.735s)
    backtrace:
      __kmem_cache_alloc_node
      __kmalloc
      fscrypt_setup_filename
      do_rename
      ubifs_rename
      vfs_rename
      do_renameat2

To fix this we can remove the call to fscrypt_setup_filename as it's not
needed.

Fixes: 278d9a2436 ("ubifs: Rename whiteout atomically")
Reported-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Cc: stable@vger.kernel.org
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-17 11:50:14 +02:00
..
Kconfig
Makefile
auth.c
budget.c ubifs: Reserve one leb for each journal head while doing budget 2023-03-11 13:57:24 +01:00
commit.c
compress.c
crypto.c
debug.c ubifs: fix snprintf() checking 2021-06-18 22:04:47 +02:00
debug.h
dir.c ubifs: Fix memory leak in do_rename 2023-05-17 11:50:14 +02:00
file.c ubifs: ubifs_writepage: Mark page dirty after writing inode failed 2023-03-11 13:57:25 +01:00
find.c
gc.c
io.c ubifs: Fix read out-of-bounds in ubifs_wbuf_write_nolock() 2022-04-08 14:24:08 +02:00
ioctl.c ubifs: setflags: Make dirtied_ino_d 8 bytes aligned 2022-04-08 14:24:08 +02:00
journal.c ubifs: Rename whiteout atomically 2022-04-08 14:24:08 +02:00
key.h
log.c
lprops.c
lpt.c
lpt_commit.c
master.c ubifs: Fix spelling mistakes 2021-06-22 09:21:39 +02:00
misc.c
misc.h
orphan.c
recovery.c
replay.c ubifs: Fix spelling mistakes 2021-06-22 09:21:39 +02:00
sb.c
scan.c
shrinker.c
super.c ubifs: Fix memory leak in alloc_wbufs() 2023-03-11 13:57:25 +01:00
tnc.c ubifs: Fix memleak when insert_old_idx() failed 2023-05-11 23:00:18 +09:00
tnc_commit.c ubifs: Fix spelling mistakes 2021-06-22 09:21:39 +02:00
tnc_misc.c
ubifs-media.h
ubifs.h ubifs: Fix AA deadlock when setting xattr for encrypted file 2023-05-17 11:50:13 +02:00
xattr.c ubifs: Fix AA deadlock when setting xattr for encrypted file 2023-05-17 11:50:13 +02:00