From: Steven Rostedt <rostedt@goodmis.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux Trace Devel <linux-trace-devel@vger.kernel.org>,
Christian Brauner <brauner@kernel.org>,
Ajay Kaher <ajay.kaher@broadcom.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH] eventfs: Have inodes have unique inode numbers
Date: Sun, 28 Jan 2024 22:40:54 -0500 [thread overview]
Message-ID: <20240128224054.0df489b8@rorschach.local.home> (raw)
In-Reply-To: <20240128213249.605a7ade@rorschach.local.home>
On Sun, 28 Jan 2024 21:32:49 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> # echo 'p:sched schedule' >> kprobe_events
> # ls events/kprobes
> enable filter sched timer
>
> # ls events/kprobes/sched/
> ls: reading directory 'events/kprobes/sched/': Invalid argument
>
> I have no access to the directory that was deleted and recreated.
Ah, this was because the final iput() does dentry->d_fsdata = NULL, and
in the lookup code I have:
mutex_lock(&eventfs_mutex);
ei = READ_ONCE(ti->private);
if (ei && ei->is_freed)
ei = NULL;
mutex_unlock(&eventfs_mutex);
if (!ei) {
printk("HELLO no ei\n");
goto out;
}
Where that printk() was triggering.
So at least it's not calling back into the tracing code ;-)
Interesting that it still did the lookup, even though it was already
referenced.
I'm still learning the internals of VFS.
Anyway, after keeping the d_fsdata untouched (not going to NULL), just
to see what would happen, I ran it again with KASAN and did trigger:
[ 106.255468] ==================================================================
[ 106.258400] BUG: KASAN: slab-use-after-free in tracing_open_file_tr+0x3a/0x120
[ 106.261228] Read of size 8 at addr ffff8881136f27b8 by task cat/868
[ 106.264506] CPU: 2 PID: 868 Comm: cat Not tainted 6.8.0-rc1-test-00008-gbee668990ac4-dirty #454
[ 106.267810] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 106.271337] Call Trace:
[ 106.272406] <TASK>
[ 106.273317] dump_stack_lvl+0x5c/0xc0
[ 106.274750] print_report+0xcf/0x670
[ 106.276173] ? __virt_addr_valid+0x15a/0x330
[ 106.278807] kasan_report+0xd8/0x110
[ 106.280172] ? tracing_open_file_tr+0x3a/0x120
[ 106.281745] ? tracing_open_file_tr+0x3a/0x120
[ 106.283343] tracing_open_file_tr+0x3a/0x120
[ 106.284887] do_dentry_open+0x3b7/0x950
[ 106.286284] ? __pfx_tracing_open_file_tr+0x10/0x10
[ 106.287992] path_openat+0xea8/0x11d0
That was with just these commands:
cd /sys/kernel/tracing/
echo 'p:sched schedule' >> /sys/kernel/tracing/kprobe_events
echo 'p:timer read_current_timer' >> kprobe_events
ls events/kprobes/
cat events/kprobes/sched/enable
ls events/kprobes/sched
echo '-:sched schedule' >> /sys/kernel/tracing/kprobe_events
ls events/kprobes/sched/enable
cat events/kprobes/sched/enable
BTW, the ls after the deletion returned:
# ls events/kprobes/sched/enable
events/kprobes/sched/enable
In a normal file system that would be equivalent to:
# mkdir events/kprobes/sched
# touch events/kprobes/sched/enable
# rm -rf events/kprobes/sched
# ls events/kprobes/sched/enable
events/kprobes/sched/enable
-- Steve
next prev parent reply other threads:[~2024-01-29 3:40 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-26 20:02 [PATCH] eventfs: Have inodes have unique inode numbers Steven Rostedt
2024-01-26 20:25 ` Linus Torvalds
2024-01-26 21:26 ` Steven Rostedt
2024-01-26 21:31 ` Linus Torvalds
2024-01-26 21:43 ` Steven Rostedt
2024-01-26 21:36 ` Linus Torvalds
2024-01-26 21:42 ` Steven Rostedt
2024-01-26 21:49 ` Linus Torvalds
2024-01-26 22:08 ` Steven Rostedt
2024-01-26 22:26 ` Linus Torvalds
2024-01-27 14:47 ` Steven Rostedt
2024-01-28 14:42 ` Steven Rostedt
2024-01-26 22:14 ` Mathieu Desnoyers
2024-01-26 22:29 ` Linus Torvalds
2024-01-26 22:41 ` Mathieu Desnoyers
2024-01-26 22:49 ` Linus Torvalds
2024-01-29 16:00 ` Mathieu Desnoyers
2024-01-29 18:58 ` Linus Torvalds
2024-01-26 22:34 ` Matthew Wilcox
2024-01-26 22:40 ` Mathieu Desnoyers
2024-01-26 22:48 ` Linus Torvalds
2024-01-26 23:04 ` Matthew Wilcox
2024-01-26 23:11 ` Linus Torvalds
2024-01-26 23:17 ` Linus Torvalds
2024-01-27 9:36 ` Andreas Schwab
2024-01-27 21:47 ` Linus Torvalds
2024-01-28 20:15 ` Steven Rostedt
2024-01-28 20:53 ` Linus Torvalds
2024-01-28 21:08 ` Linus Torvalds
2024-01-28 22:01 ` Steven Rostedt
2024-01-28 22:17 ` Linus Torvalds
2024-01-28 22:26 ` Steven Rostedt
2024-01-28 21:11 ` Steven Rostedt
2024-01-28 21:19 ` Steven Rostedt
2024-01-28 21:43 ` Linus Torvalds
2024-01-28 22:07 ` Linus Torvalds
2024-01-28 22:17 ` Steven Rostedt
2024-01-28 22:25 ` Linus Torvalds
2024-01-28 22:51 ` Steven Rostedt
2024-01-28 23:24 ` Linus Torvalds
2024-01-28 23:59 ` Steven Rostedt
2024-01-29 0:21 ` Steven Rostedt
2024-01-29 1:00 ` Linus Torvalds
2024-01-29 1:42 ` Linus Torvalds
2024-01-29 2:32 ` Steven Rostedt
2024-01-29 3:40 ` Steven Rostedt [this message]
2024-01-29 4:01 ` Linus Torvalds
2024-01-29 2:09 ` Steven Rostedt
2024-01-29 6:44 ` Amir Goldstein
2024-01-29 9:32 ` Steven Rostedt
2024-01-27 15:26 ` David Laight
2024-01-27 20:01 ` Linus Torvalds
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=20240128224054.0df489b8@rorschach.local.home \
--to=rostedt@goodmis.org \
--cc=ajay.kaher@broadcom.com \
--cc=brauner@kernel.org \
--cc=geert@linux-m68k.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).