Bug 281978 - g_io_request panic on md(4) with odd size
Summary: g_io_request panic on md(4) with odd size
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: arm64 Any
: --- Affects Only Me
Assignee: Konstantin Belousov
URL:
Keywords: crash
Depends on:
Blocks:
 
Reported: 2024-10-09 20:27 UTC by Bjoern A. Zeeb
Modified: 2024-10-20 15:22 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bjoern A. Zeeb freebsd_committer freebsd_triage 2024-10-09 20:27:45 UTC
I have in the past done this but after a recent update it panics on boot with a DEBUG kernel:

I am pre-loading an md(4)image file from loader which has an odd size (md0 is a root image which seems fine if I disable the md1):

md1: Preloaded image </bazrandom> 61281 bytes at 0xffff000005f95eb0

This leads to a panic when geom tries to taste but doesn't find a file system or disk-sized image:

panic: wrong offset 60769 for sectorsize 512
cpuid = 0
time = 1
KDB: stack backtrace:
db_trace_self() at db_trace_self
db_trace_self_wrapper() at db_trace_self_wrapper+0x58
vpanic() at vpanic+0x220
panic() at panic+0x48
g_io_request() at g_io_request+0x5e4
g_read_data() at g_read_data+0xc8
g_label_generic_taste() at g_label_generic_taste+0x90
g_label_taste() at g_label_taste+0x268
g_load_class() at g_load_class+0x23c
g_run_events() at g_run_events+0x13c
fork_exit() at fork_exit+0x98
fork_trampoline() at fork_trampoline+0x18
KDB: enter: panic
[ thread pid 14 tid 100075 ]
Stopped at      kdb_enter+0x78: str     xzr, [x21, #2048]
Comment 1 Bjoern A. Zeeb freebsd_committer freebsd_triage 2024-10-10 15:59:18 UTC
I went back through the archive as this was to strange;
turned out that all the "random" files were a multiple of sectorsize before so I assume this works as intended but I would want to question if this needs to be a panic rather than being handled as an error?

If the panic is reasonable someone should just close this.
Comment 2 Konstantin Belousov freebsd_committer freebsd_triage 2024-10-13 21:31:37 UTC
Could you please try https://reviews.freebsd.org/D47102
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-10-14 08:09:32 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4bf34c597c44a2393ac5ec483e9cecac128d8202

commit 4bf34c597c44a2393ac5ec483e9cecac128d8202
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-13 21:28:22 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-14 08:08:21 +0000

    md(4): always trim the last partial sector

    Do it also for the preloaded disk, in addition to the dynamically
    configured device.  This is needed to avoid geom checking alignment and
    panicing on read of the last sector, e.g. for partition schemes and
    label tasting.

    PR:     281978
    Reported by:    bz
    Reviewed by:    bz, markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D47102

 sys/dev/md/md.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-10-20 00:35:27 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=959f0d0cdb1482d754f24b7ae16bda0ac2e7b31a

commit 959f0d0cdb1482d754f24b7ae16bda0ac2e7b31a
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-13 21:28:22 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-20 00:33:04 +0000

    md(4): always trim the last partial sector

    PR:     281978

    (cherry picked from commit 4bf34c597c44a2393ac5ec483e9cecac128d8202)

 sys/dev/md/md.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)