Skip to content

blktrace: build the synthesized v1 record from the entry's own layout - #1301

Open
blktests-ci-kpd[bot] wants to merge 1 commit into
linus-master_basefrom
series/1163668=>linus-master
Open

blktests-ci-kpd[bot] wants to merge 1 commit into
linus-master_basefrom
series/1163668=>linus-master

Conversation

@blktests-ci-kpd

Copy link
Copy Markdown

Pull request for series with
subject: blktrace: build the synthesized v1 record from the entry's own layout
version: 1
url: https://patchwork.kernel.org/series/1163668/

@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 5225b8e
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 2f0c1cf
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 2f0c1cf
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 6f5497b to 76a4234 Compare September 13, 2026 22:59
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 5878583
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 76a4234 to 7956c0e Compare September 15, 2026 09:33
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 4982d35
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 7956c0e to ebcfd76 Compare September 17, 2026 19:31
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 5dd1818
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from ebcfd76 to 987743e Compare September 18, 2026 13:26
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 6a5719c
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 987743e to 22dce9c Compare September 20, 2026 20:48
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: f010036
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 22dce9c to c995118 Compare September 22, 2026 14:37
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 72d3fcf
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 75fc35d to 4a62fec Compare September 28, 2026 15:18
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 551c722
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 4a62fec to 8557bf4 Compare October 1, 2026 16:09
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: ce1e022
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 8557bf4 to 5443f36 Compare October 1, 2026 23:48
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: e767a4e
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 5443f36 to 50be900 Compare October 3, 2026 10:12
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: a74306e
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 50be900 to 01a0b4f Compare October 3, 2026 22:21
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: None
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 01a0b4f to 83d4f06 Compare October 5, 2026 02:28
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 22430ae
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 83d4f06 to 08998dd Compare October 6, 2026 13:12
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 69f80fe
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 08998dd to 410956c Compare October 6, 2026 17:26
blk_trace_synthesize_old_trace() emits a classic blk_io_trace for the
binary trace_pipe output by copying 32 bytes from the ring buffer entry's
sector onward into a struct blk_io_trace. It reads them at blk_io_trace2
offsets, and the two layouts diverge after bytes: v2 has a 32-bit pid at
28 and a 64-bit action at 32, where v1 has a 32-bit action at 28 and pid
at 32. On a v2 entry every field from action on lands one slot off, so a
consumer reads the pid as the action, the device as the cpu, and the cpu
as error and pdu_len.

The PDU comes from the wrong offset as well. The copy ends at v2 offset
48 + pdu_len while the PDU starts at 64, and the emitted pdu_len is taken
from the v2 cpu, so it reads 0 while extra bytes were appended and the
consumer resynchronizes on the wrong boundary.

The entry is not always a v2 record. __blk_add_trace() reserves
sizeof(struct blk_io_trace) when the trace was set up by BLKTRACESETUP,
and on such an entry the 32-byte copy is correct. pdu_len is still read
at v2 offset 50 though, past the end of a 48-byte entry, and drives an
unbounded copy that desynchronizes the stream. That is what syzbot hit.

Take the layout from iter->ent_size, which is the only discriminator the
entry carries -- magic and sequence are the ftrace header, not a version
stamp. Assign the v1 fields from their counterparts in that layout and
append the PDU from the end of it, bounded by the entry size.

  BUG: KASAN: slab-out-of-bounds in seq_buf_putmem+0x124/0x180
  Read of size 1352 at addr ffff8880295bdb98 by task syz.2.2551/19243
   seq_buf_putmem+0x124/0x180 lib/seq_buf.c:241
   blk_trace_synthesize_old_trace kernel/trace/blktrace.c:1780 [inline]
   blk_trace_event_print_binary+0x130/0x1b0 kernel/trace/blktrace.c:1788
   tracing_read_pipe+0x568/0xb50 kernel/trace/trace.c:5444
   vfs_read+0x213/0xa80 fs/read_write.c:572

Fixes: 4d8bc7b ("blktrace: move ftrace blk_io_tracer to blk_io_trace2")
Reported-by: syzbot+f179b16e13624138b0f1@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f179b16e13624138b0f1
Cc: stable@vger.kernel.org
Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Assisted-by: Claude:claude-fable-5
@blktests-ci-kpd

Copy link
Copy Markdown
Author

Upstream branch: 7b63ef2
series: https://patchwork.kernel.org/series/1163668/
version: 1

@blktests-ci-kpd
blktests-ci-kpd Bot force-pushed the series/1163668=>linus-master branch from 410956c to f9a7538 Compare October 7, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant