Linux block layer
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
Cc: syzbot <syzbot+153e64c0aa875d7e4c37@syzkaller.appspotmail.com>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-trace-kernel@vger.kernel.org"
	<linux-trace-kernel@vger.kernel.org>,
	"mathieu.desnoyers@efficios.com" <mathieu.desnoyers@efficios.com>,
	"mhiramat@kernel.org" <mhiramat@kernel.org>,
	"rostedt@goodmis.org" <rostedt@goodmis.org>,
	"syzkaller-bugs@googlegroups.com"
	<syzkaller-bugs@googlegroups.com>, Jens Axboe <axboe@kernel.dk>
Subject: Re: [syzbot] [block?] [trace?] WARNING in __blk_add_trace
Date: Sun, 26 Oct 2025 05:43:41 +0000	[thread overview]
Message-ID: <d6df5ac5-6168-4c29-ba51-41c4b587bba8@nvidia.com> (raw)
In-Reply-To: <cc31bf15-5c9e-43b5-9615-2475aebd1d53@nvidia.com>

On 10/25/25 21:55, Chaitanya Kulkarni wrote:
> (what >> BLK_TC_SHIFT) & ~((u64)BLK_TC_END_V1 * 2 - 1)))

Following is the test I used :-

  tests/blktrace/001     | 97 ++++++++++++++++++++++++++++++++++++++++++
  tests/blktrace/001.out |  2 +
  tests/blktrace/rc      | 11 +++++
  3 files changed, 110 insertions(+)
  create mode 100755 tests/blktrace/001
  create mode 100644 tests/blktrace/001.out
  create mode 100644 tests/blktrace/rc

diff --git a/tests/blktrace/001 b/tests/blktrace/001
new file mode 100755
index 0000000..fa72f89
--- /dev/null
+++ b/tests/blktrace/001
@@ -0,0 +1,97 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2025 Chaitanya Kulkarni <kch@nvidia.com>
+#
+# Regression test for blktrace false positive WARNING on zone management
+# commands.
+#
+# Bug: https://syzkaller.appspot.com/bug?extid=153e64c0aa875d7e4c37
+# Location: kernel/trace/blktrace.c:367-368
+#
+# The bug triggers a WARNING when zone management commands (zone 
open/close/
+# finish/reset) are traced with blktrace on V1 version. This is a false
+# positive that should be fixed.
+
+. tests/blktrace/rc
+. common/null_blk
+
+DESCRIPTION="blktrace zone management command tracing"
+QUICK=1
+
+requires() {
+    _have_program blkzone
+    _have_null_blk
+    _have_module_param null_blk zoned
+}
+
+test() {
+    echo "Running ${TEST_NAME}"
+
+    local blktrace_pid
+    local warning_count
+    local device
+
+    # Initialize null_blk with no default devices
+    if ! _init_null_blk nr_devices=0; then
+        return 1
+    fi
+
+    # Create zoned null_blk device via configfs
+    # 8 zones, 1GB total, 128MB per zone, no conventional zones
+    if ! _configure_null_blk nullb0 \
+        memory_backed=1 \
+        zone_size=128 \
+        zone_nr_conv=0 \
+        size=1024 \
+        zoned=1 \
+        power=1; then
+        return 1
+    fi
+
+    device=/dev/nullb0
+
+    # Verify it's a zoned device
+    local zoned_mode
+    zoned_mode=$(cat /sys/block/nullb0/queue/zoned)
+    if [[ "$zoned_mode" != "host-managed" ]]; then
+        echo "Device is not zoned (mode: $zoned_mode)"
+        _exit_null_blk
+        return 1
+    fi
+
+    # Clear dmesg to isolate test output
+    dmesg -C 2>/dev/null || true
+
+    # Start blktrace
+    blktrace -d "${device}" -o trace >> "$FULL" 2>&1 &
+    blktrace_pid=$!
+    sleep 2
+
+    # Verify blktrace started
+    if ! ps -p $blktrace_pid > /dev/null 2>&1; then
+        echo "blktrace failed to start"
+        _exit_null_blk
+        return 1
+    fi
+
+    # Issue zone open command for all zones (triggers bug if present)
+    blkzone open "${device}" >> "$FULL" 2>&1
+
+    sleep 1
+
+    # Stop blktrace
+    kill $blktrace_pid 2>/dev/null
+    wait $blktrace_pid 2>/dev/null || true
+
+    # Check for WARNING (bug present if WARNING found)
+    warning_count=$(dmesg | grep -c "WARNING.*blktrace.c:367" || true)
+
+    if [[ $warning_count -gt 0 ]]; then
+        echo "WARNING: blktrace bug detected at blktrace.c:367"
+        dmesg | grep -A 10 "WARNING.*blktrace.c:367" >> "$FULL"
+    fi
+
+    _exit_null_blk
+
+    echo "Test complete"
+}
diff --git a/tests/blktrace/001.out b/tests/blktrace/001.out
new file mode 100644
index 0000000..a122a65
--- /dev/null
+++ b/tests/blktrace/001.out
@@ -0,0 +1,2 @@
+Running blktrace/001
+Test complete
diff --git a/tests/blktrace/rc b/tests/blktrace/rc
new file mode 100644
index 0000000..019ff7d
--- /dev/null
+++ b/tests/blktrace/rc
@@ -0,0 +1,11 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2025 Chaitanya Kulkarni <kch@nvidia.com>
+#
+# Tests for blktrace infrastructure
+
+. common/rc
+
+group_requires() {
+    _have_root && _have_blktrace && _have_program blkparse
+}
-- 
2.40.0


  reply	other threads:[~2025-10-26  5:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-24 23:11 [syzbot] [block?] [trace?] WARNING in __blk_add_trace syzbot
2025-10-25 12:19 ` syzbot
2025-10-25 13:35 ` Jens Axboe
2025-10-26  4:55   ` Chaitanya Kulkarni
2025-10-26  5:43     ` Chaitanya Kulkarni [this message]
2025-10-27  6:51     ` Johannes Thumshirn

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=d6df5ac5-6168-4c29-ba51-41c4b587bba8@nvidia.com \
    --to=chaitanyak@nvidia.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=syzbot+153e64c0aa875d7e4c37@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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