linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: zhuxiaohui <zhuxiaohui400@gmail.com>
To: muchun.song@linux.dev, rostedt@goodmis.org, mhiramat@kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org
Cc: lihongbo22@huawei.com, Xiaohui Zhu <zhuxiaohui.400@bytedance.com>
Subject: [PATCH] hugetlbfs: check dir in trace_hugetlbfs_alloc_inode
Date: Mon, 13 Jan 2025 11:07:02 +0800	[thread overview]
Message-ID: <20250113030702.58502-1-zhuxiaohui.400@bytedance.com> (raw)

From: Xiaohui Zhu <zhuxiaohui.400@bytedance.com>

Anonymous huge page has no corresponding directory inode,
which cause a null pointer crash when access dir with the stack

  trace_hugetlbfs_alloc_inode
  hugetlbfs_get_inode
  hugetlb_file_setup
  ksys_mmap_pgoff

Signed-off-by: Xiaohui Zhu <zhuxiaohui.400@bytedance.com>
---
 include/trace/events/hugetlbfs.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/trace/events/hugetlbfs.h b/include/trace/events/hugetlbfs.h
index 8331c904a9ba..5daa52053edc 100644
--- a/include/trace/events/hugetlbfs.h
+++ b/include/trace/events/hugetlbfs.h
@@ -23,7 +23,9 @@ TRACE_EVENT(hugetlbfs_alloc_inode,
 	TP_fast_assign(
 		__entry->dev		= inode->i_sb->s_dev;
 		__entry->ino		= inode->i_ino;
-		__entry->dir		= dir->i_ino;
+		__entry->dir		= 0;
+		if (dir)
+			__entry->dir	= dir->i_ino;
 		__entry->mode		= mode;
 	),
 
-- 
2.41.0



             reply	other threads:[~2025-01-13  3:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13  3:07 zhuxiaohui [this message]
2025-01-13  3:29 ` Hongbo Li
2025-01-13  3:30   ` [External] " 朱晓辉

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250113030702.58502-1-zhuxiaohui.400@bytedance.com \
    --to=zhuxiaohui400@gmail.com \
    --cc=lihongbo22@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=zhuxiaohui.400@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox