]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
eventfs: Test for dentries array allocated in eventfs_release()
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Sat, 30 Sep 2023 13:01:06 +0000 (09:01 -0400)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Sat, 30 Sep 2023 20:26:04 +0000 (16:26 -0400)
The dcache_dir_open_wrapper() could be called when a dynamic event is
being deleted leaving a dentry with no children. In this case the
dlist->dentries array will never be allocated. This needs to be checked
for in eventfs_release(), otherwise it will trigger a NULL pointer
dereference.

Link: https://lore.kernel.org/linux-trace-kernel/20230930090106.1c3164e9@rorschach.local.home
Cc: Mark Rutland <mark.rutland@arm.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Fixes: ef36b4f92868 ("eventfs: Remember what dentries were created on dir open")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
fs/tracefs/event_inode.c

index 5f17140898844919eef25daa7976aa6fbcbfc7bd..8c8d64e76103e130aeab0a8f913822abf1b0b5af 100644 (file)
@@ -421,7 +421,7 @@ static int eventfs_release(struct inode *inode, struct file *file)
        if (WARN_ON_ONCE(!dlist))
                return -EINVAL;
 
-       for (i = 0; dlist->dentries[i]; i++) {
+       for (i = 0; dlist->dentries && dlist->dentries[i]; i++) {
                dput(dlist->dentries[i]);
        }