linux-stable/fs/ubifs
Mårten Lindahl b8f444a4fa ubifs: Free memory for tmpfile name
commit 1fb815b38b upstream.

When opening a ubifs tmpfile on an encrypted directory, function
fscrypt_setup_filename allocates memory for the name that is to be
stored in the directory entry, but after the name has been copied to the
directory entry inode, the memory 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 'tmpfile' just opening a
tmpfile:

  unreferenced object 0xffff88810178f380 (size 32):
    comm "tmpfile", pid 509, jiffies 4294934744 (age 1524.742s)
    backtrace:
      __kmem_cache_alloc_node
      __kmalloc
      fscrypt_setup_filename
      ubifs_tmpfile
      vfs_tmpfile
      path_openat

Free this memory after it has been copied to the inode.

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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-17 11:47:35 +02:00
..
auth.c
budget.c ubifs: Reserve one leb for each journal head while doing budget 2023-03-11 16:40:10 +01:00
commit.c
compress.c
crypto.c
debug.c
debug.h
dir.c ubifs: Free memory for tmpfile name 2023-05-17 11:47:35 +02:00
file.c ubifs: ubifs_writepage: Mark page dirty after writing inode failed 2023-03-11 16:40:11 +01:00
find.c
gc.c treewide: Change list_sort to use const pointers 2021-09-30 10:11:04 +02:00
io.c ubifs: Fix read out-of-bounds in ubifs_wbuf_write_nolock() 2022-04-08 14:40:39 +02:00
ioctl.c ubifs: setflags: Make dirtied_ino_d 8 bytes aligned 2022-04-08 14:40:39 +02:00
journal.c
Kconfig
key.h
log.c
lprops.c
lpt.c
lpt_commit.c
Makefile
master.c
misc.c
misc.h
orphan.c
recovery.c
replay.c treewide: Change list_sort to use const pointers 2021-09-30 10:11:04 +02:00
sb.c
scan.c
shrinker.c
super.c ubifs: Fix memory leak in alloc_wbufs() 2023-03-11 16:40:10 +01:00
tnc.c ubifs: Fix memleak when insert_old_idx() failed 2023-05-17 11:47:35 +02:00
tnc_commit.c
tnc_misc.c
ubifs-media.h
ubifs.h ubifs: Fix build errors as symbol undefined 2023-03-11 16:40:09 +01:00
xattr.c