<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/blktrace.c, branch v6.14</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.14</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.14'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2024-12-23T15:17:23Z</updated>
<entry>
<title>blktrace: remove redundant return at end of function</title>
<updated>2024-12-23T15:17:23Z</updated>
<author>
<name>Colin Ian King</name>
<email>colin.i.king@gmail.com</email>
</author>
<published>2024-12-04T15:04:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ccb9868ab7f4b253440b8723a3487b8b9a16d371'/>
<id>urn:sha1:ccb9868ab7f4b253440b8723a3487b8b9a16d371</id>
<content type='text'>
A recent change added return 0 before an existing return statement
at the end of function blk_trace_setup. The final return is now
redundant, so remove it.

Fixes: 64d124798244 ("blktrace: move copy_[to|from]_user() out of -&gt;debugfs_lock")
Signed-off-by: Colin Ian King &lt;colin.i.king@gmail.com&gt;
Link: https://lore.kernel.org/r/20241204150450.399005-1-colin.i.king@gmail.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>blktrace: move copy_[to|from]_user() out of -&gt;debugfs_lock</title>
<updated>2024-12-23T15:17:22Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@redhat.com</email>
</author>
<published>2024-11-28T12:50:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b769a2f409e7a356db852a1bb62a32f7809b3a3c'/>
<id>urn:sha1:b769a2f409e7a356db852a1bb62a32f7809b3a3c</id>
<content type='text'>
Move copy_[to|from]_user() out of -&gt;debugfs_lock and cut the dependency
between mm-&gt;mmap_lock and q-&gt;debugfs_lock, then we avoids lots of
lockdep false positive warning. Obviously -&gt;debug_lock isn't needed
for copy_[to|from]_user().

The only behavior change is to call blk_trace_remove() in case of setup
failure handling by re-grabbing -&gt;debugfs_lock, and this way is just
fine since we do cover concurrent setup() &amp; remove().

Reported-by: syzbot+91585b36b538053343e4@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-block/67450fd4.050a0220.1286eb.0007.GAE@google.com/
Closes: https://lore.kernel.org/linux-block/6742e584.050a0220.1cc393.0038.GAE@google.com/
Closes: https://lore.kernel.org/linux-block/6742a600.050a0220.1cc393.002e.GAE@google.com/
Closes: https://lore.kernel.org/linux-block/67420102.050a0220.1cc393.0019.GAE@google.com/
Signed-off-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Link: https://lore.kernel.org/r/20241128125029.4152292-3-ming.lei@redhat.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>blktrace: don't centralize grabbing q-&gt;debugfs_mutex in blk_trace_ioctl</title>
<updated>2024-12-23T15:17:22Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@redhat.com</email>
</author>
<published>2024-11-28T12:50:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fd9b0244f5c5f63461ca9752eebd2423ae02bb59'/>
<id>urn:sha1:fd9b0244f5c5f63461ca9752eebd2423ae02bb59</id>
<content type='text'>
Call each handler directly and the handler do grab q-&gt;debugfs_mutex,
prepare for killing dependency between -&gt;debug_mutex and -&gt;mmap_lock.

Signed-off-by: Ming Lei &lt;ming.lei@redhat.com&gt;
Link: https://lore.kernel.org/r/20241128125029.4152292-2-ming.lei@redhat.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>blktrace: convert strncpy() to strscpy_pad()</title>
<updated>2024-04-26T04:07:08Z</updated>
<author>
<name>Arnd Bergmann</name>
<email>arnd@arndb.de</email>
</author>
<published>2024-04-09T14:00:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=051e7503070179f2278c0d4fa7dee441adb558ca'/>
<id>urn:sha1:051e7503070179f2278c0d4fa7dee441adb558ca</id>
<content type='text'>
gcc-9 warns about a possibly non-terminated string copy:

kernel/trace/blktrace.c: In function 'do_blk_trace_setup':
kernel/trace/blktrace.c:527:2: error: 'strncpy' specified bound 32 equals destination size [-Werror=stringop-truncation]

Newer versions are fine here because they see the following explicit
nul-termination. Using strscpy_pad() avoids the warning and
simplifies the code a little. The padding helps  give a clean
buffer to userspace.

Link: https://lkml.kernel.org/r/20240409140059.3806717-5-arnd@kernel.org
Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Acked-by: Justin Stitt &lt;justinstitt@google.com&gt;
Cc: Alexey Starikovskiy &lt;astarikovskiy@suse.de&gt;
Cc: Bob Moore &lt;robert.moore@intel.com&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: Len Brown &lt;lenb@kernel.org&gt;
Cc: Lin Ming &lt;ming.m.lin@intel.com&gt;
Cc: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Cc: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Cc: Nathan Chancellor &lt;nathan@kernel.org&gt;
Cc: Nicolas Schier &lt;nicolas@fjasle.eu&gt;
Cc: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Cc: "Richard Russon (FlatCap)" &lt;ldm@flatcap.org&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>block: remove more NULL checks after bdev_get_queue()</title>
<updated>2023-02-21T16:23:22Z</updated>
<author>
<name>Juhyung Park</name>
<email>qkrwngud825@gmail.com</email>
</author>
<published>2023-02-03T02:40:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9e0c7efa5ea231d85c0d41693a5115b3b971717c'/>
<id>urn:sha1:9e0c7efa5ea231d85c0d41693a5115b3b971717c</id>
<content type='text'>
bdev_get_queue() never returns NULL. Several commits [1][2] have been made
before to remove such superfluous checks, but some still remained.

For places where bdev_get_queue() is called solely for NULL checks, it is
removed entirely.

[1] commit ec9fd2a13d74 ("blk-lib: don't check bdev_get_queue() NULL check")
[2] commit fea127b36c93 ("block: remove superfluous check for request queue in bdev_is_zoned()")

Signed-off-by: Juhyung Park &lt;qkrwngud825@gmail.com&gt;
Reviewed-by: Pankaj Raghav &lt;p.raghav@samsung.com&gt;
Link: https://lore.kernel.org/r/20230203024029.48260-1-qkrwngud825@gmail.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>trace/blktrace: fix memory leak with using debugfs_lookup()</title>
<updated>2023-02-06T16:29:30Z</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2023-02-02T14:19:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=83e8864fee26f63a7435e941b7c36a20fd6fe93e'/>
<id>urn:sha1:83e8864fee26f63a7435e941b7c36a20fd6fe93e</id>
<content type='text'>
When calling debugfs_lookup() the result must have dput() called on it,
otherwise the memory will leak over time.  To make things simpler, just
call debugfs_lookup_and_remove() instead which handles all of the logic
at once.

Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Cc: linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-trace-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Reviewed-by: Bart Van Assche &lt;bvanassche@acm.org&gt;
Link: https://lore.kernel.org/r/20230202141956.2299521-1-gregkh@linuxfoundation.org
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>blktrace: Fix output non-blktrace event when blk_classic option enabled</title>
<updated>2022-12-08T16:26:11Z</updated>
<author>
<name>Yang Jihong</name>
<email>yangjihong1@huawei.com</email>
</author>
<published>2022-11-22T04:04:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f596da3efaf4130ff61cd029558845808df9bf99'/>
<id>urn:sha1:f596da3efaf4130ff61cd029558845808df9bf99</id>
<content type='text'>
When the blk_classic option is enabled, non-blktrace events must be
filtered out. Otherwise, events of other types are output in the blktrace
classic format, which is unexpected.

The problem can be triggered in the following ways:

  # echo 1 &gt; /sys/kernel/debug/tracing/options/blk_classic
  # echo 1 &gt; /sys/kernel/debug/tracing/events/enable
  # echo blk &gt; /sys/kernel/debug/tracing/current_tracer
  # cat /sys/kernel/debug/tracing/trace_pipe

Fixes: c71a89615411 ("blktrace: add ftrace plugin")
Signed-off-by: Yang Jihong &lt;yangjihong1@huawei.com&gt;
Link: https://lore.kernel.org/r/20221122040410.85113-1-yangjihong1@huawei.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>block: bdev &amp; blktrace: use consistent function doc. notation</title>
<updated>2022-12-01T16:16:46Z</updated>
<author>
<name>Randy Dunlap</name>
<email>rdunlap@infradead.org</email>
</author>
<published>2022-12-01T07:03:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2e833c8c8c42a3b6e22d6b3a9d2d18e425551261'/>
<id>urn:sha1:2e833c8c8c42a3b6e22d6b3a9d2d18e425551261</id>
<content type='text'>
Use only one hyphen in kernel-doc notation between the function name
and its short description.

The is the documented kerenl-doc format. It also fixes the HTML
presentation to be consistent with other functions.

Signed-off-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: linux-block@vger.kernel.org
Link: https://lore.kernel.org/r/20221201070331.25685-1-rdunlap@infradead.org
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>blktrace: remove unnessary stop block trace in 'blk_trace_shutdown'</title>
<updated>2022-10-20T13:02:52Z</updated>
<author>
<name>Ye Bin</name>
<email>yebin10@huawei.com</email>
</author>
<published>2022-10-19T03:36:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2db96217e7e515071726ca4ec791742c4202a1b2'/>
<id>urn:sha1:2db96217e7e515071726ca4ec791742c4202a1b2</id>
<content type='text'>
As previous commit, 'blk_trace_cleanup' will stop block trace if
block trace's state is 'Blktrace_running'.
So remove unnessary stop block trace in 'blk_trace_shutdown'.

Signed-off-by: Ye Bin &lt;yebin10@huawei.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Link: https://lore.kernel.org/r/20221019033602.752383-4-yebin@huaweicloud.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>blktrace: fix possible memleak in '__blk_trace_remove'</title>
<updated>2022-10-20T13:02:52Z</updated>
<author>
<name>Ye Bin</name>
<email>yebin10@huawei.com</email>
</author>
<published>2022-10-19T03:36:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=dcd1a59c62dc49da75539213611156d6db50ab5d'/>
<id>urn:sha1:dcd1a59c62dc49da75539213611156d6db50ab5d</id>
<content type='text'>
When test as follows:
step1: ioctl(sda, BLKTRACESETUP, &amp;arg)
step2: ioctl(sda, BLKTRACESTART, NULL)
step3: ioctl(sda, BLKTRACETEARDOWN, NULL)
step4: ioctl(sda, BLKTRACESETUP, &amp;arg)
Got issue as follows:
debugfs: File 'dropped' in directory 'sda' already present!
debugfs: File 'msg' in directory 'sda' already present!
debugfs: File 'trace0' in directory 'sda' already present!

And also find syzkaller report issue like "KASAN: use-after-free Read in relay_switch_subbuf"
"https://syzkaller.appspot.com/bug?id=13849f0d9b1b818b087341691be6cc3ac6a6bfb7"

If remove block trace without stop(BLKTRACESTOP) block trace, '__blk_trace_remove'
will just set 'q-&gt;blk_trace' with NULL. However, debugfs file isn't removed, so
will report file already present when call BLKTRACESETUP.
static int __blk_trace_remove(struct request_queue *q)
{
        struct blk_trace *bt;

        bt = rcu_replace_pointer(q-&gt;blk_trace, NULL,
                                 lockdep_is_held(&amp;q-&gt;debugfs_mutex));
        if (!bt)
                return -EINVAL;

	if (bt-&gt;trace_state != Blktrace_running)
        	blk_trace_cleanup(q, bt);

        return 0;
}

If do test as follows:
step1: ioctl(sda, BLKTRACESETUP, &amp;arg)
step2: ioctl(sda, BLKTRACESTART, NULL)
step3: ioctl(sda, BLKTRACETEARDOWN, NULL)
step4: remove sda

There will remove debugfs directory which will remove recursively all file
under directory.
&gt;&gt; blk_release_queue
&gt;&gt;	debugfs_remove_recursive(q-&gt;debugfs_dir)
So all files which created in 'do_blk_trace_setup' are removed, and
'dentry-&gt;d_inode' is NULL. But 'q-&gt;blk_trace' is still in 'running_trace_lock',
'trace_note_tsk' will traverse 'running_trace_lock' all nodes.
&gt;&gt;trace_note_tsk
&gt;&gt;  trace_note
&gt;&gt;    relay_reserve
&gt;&gt;       relay_switch_subbuf
&gt;&gt;        d_inode(buf-&gt;dentry)-&gt;i_size

To solve above issues, reference commit '5afedf670caf', call 'blk_trace_cleanup'
unconditionally in '__blk_trace_remove' and first stop block trace in
'blk_trace_cleanup'.

Signed-off-by: Ye Bin &lt;yebin10@huawei.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Link: https://lore.kernel.org/r/20221019033602.752383-3-yebin@huaweicloud.com
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
</feed>
