]> git.ipfire.org Git - thirdparty/linux.git/commit
hugetlb: fix NULL pointer dereference in trace_hugetlbfs_alloc_inode
authorMuchun Song <songmuchun@bytedance.com>
Mon, 6 Jan 2025 03:31:17 +0000 (11:31 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 13 Jan 2025 03:03:36 +0000 (19:03 -0800)
commit9ab96b524dce598c041388a599e3a227c7a7926c
treef81087317bc2068f5b501e68cbfac95ce9540eb4
parent4ce718f39776b5e162ea6b8010da7a6f02b13dc0
hugetlb: fix NULL pointer dereference in trace_hugetlbfs_alloc_inode

hugetlb_file_setup() will pass a NULL @dir to hugetlbfs_get_inode(), so we
will access a NULL pointer for @dir.  Fix it and set __entry->dr to 0 if
@dir is NULL.  Because ->i_ino cannot be 0 (see get_next_ino()), there is
no confusing if user sees a 0 inode number.

Link: https://lkml.kernel.org/r/20250106033118.4640-1-songmuchun@bytedance.com
Fixes: 318580ad7f28 ("hugetlbfs: support tracepoint")
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Reported-by: Cheung Wall <zzqq0103.hey@gmail.com>
Closes: https://lore.kernel.org/linux-mm/02858D60-43C1-4863-A84F-3C76A8AF1F15@linux.dev/T/#
Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
Cc: cheung wall <zzqq0103.hey@gmail.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/trace/events/hugetlbfs.h