Skip to content

blktrace: always record ftrace events as blk_io_trace2 - #166

Open
blktests-ci-block-trial[bot] wants to merge 1 commit into
master_basefrom
series/792=>master
Open

blktrace: always record ftrace events as blk_io_trace2#166
blktests-ci-block-trial[bot] wants to merge 1 commit into
master_basefrom
series/792=>master

Conversation

@blktests-ci-block-trial

Copy link
Copy Markdown

Pull request for series with
subject: blktrace: always record ftrace events as blk_io_trace2
version: 1
url: http://redsun45:8000/project/linux-block/list/?series=792

@blktests-ci-block-trial

Copy link
Copy Markdown
Author

Upstream branch: 841e384
series: http://redsun45:8000/project/linux-block/list/?series=792
version: 1

@blktests-ci-block-trial

Copy link
Copy Markdown
Author

Upstream branch: a500db7
series: http://redsun45:8000/project/linux-block/list/?series=792
version: 1

The ftrace ring buffer always uses the v2 (blk_io_trace2) format, but
__blk_add_trace() switched the reserve size and record format on
bt->version. That field only describes the relay/classic blktrace record
format and must not change what goes into the ftrace buffer: the ftrace
readers (print_one_line() and friends) unconditionally parse blk_io_trace2.

The BLKTRACESETUP ioctl sets bt->version to 1. With the blk tracer also
enabled, __blk_add_trace() recorded a 48-byte v1 event into the ftrace
ring buffer, but the reader parses the 64-byte v2 layout, so pdu_start()
points 16 bytes past the PDU and blk_log_remap() reads out of bounds - a
use-after-free when the ring buffer page is resized concurrently.

Always use the v2 format in the blk_tracer path, and initialize
bt->version to 2 in blk_trace_setup_queue() so the sysfs-enabled path no
longer leaves it uninitialized.

Fixes: e48886b ("blktrace: for ftrace use correct trace format ver")
Reported-by: syzbot+4dfd96209d744263a972@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=4dfd96209d744263a972
Tested-by: syzbot+4dfd96209d744263a972@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Adriano Cordova <adrianox@gmail.com>
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