linux-stable/fs/ubifs
Mårten Lindahl ce84028492 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-11 23:00:18 +09:00
..
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
debug.h
dir.c ubifs: Free memory for tmpfile name 2023-05-11 23:00:18 +09: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
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
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
tnc_misc.c
ubifs-media.h
ubifs.h ubifs: Fix build errors as symbol undefined 2023-03-11 13:57:24 +01:00
xattr.c