From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org
Subject: [PULL 6/6] block: Fix crash after setting latency historygram with single bin
Date: Tue, 31 Mar 2026 17:03:52 +0200 [thread overview]
Message-ID: <20260331150352.256332-7-kwolf@redhat.com> (raw)
In-Reply-To: <20260331150352.256332-1-kwolf@redhat.com>
Passing an empty list of boundaries to block-latency-histogram-set sets
up a state that leads to a NULL pointer dereference when the next
request should be accounted for. This is not a useful configuration, so
just error out if the user tries to set it.
The crash can easily be reproduced with the following script:
qmp() {
cat <<EOF
{'execute':'qmp_capabilities'}
{'execute':'block-latency-histogram-set',
'arguments': {'id':'ide0','boundaries':[]}}
{'execute':'cont'}
EOF
}
qmp | ./qemu-system-x86_64 -S -qmp stdio \
-drive if=none,format=raw,file=null-co:// \
-device ide-hd,drive=none0,id=ide0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20260331102608.60882-1-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/accounting.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/block/accounting.c b/block/accounting.c
index 5cf51f029b1..f00fe997403 100644
--- a/block/accounting.c
+++ b/block/accounting.c
@@ -185,6 +185,15 @@ int block_latency_histogram_set(BlockAcctStats *stats, enum BlockAcctType type,
prev = entry->value;
}
+ /*
+ * block_latency_histogram_account() assumes that it can always access
+ * hist->boundaries[0], so require at least one boundary. A histogram with
+ * a single bin is useless anyway.
+ */
+ if (new_nbins <= 1) {
+ return -EINVAL;
+ }
+
hist->nbins = new_nbins;
g_free(hist->boundaries);
hist->boundaries = g_new(uint64_t, hist->nbins - 1);
--
2.53.0
next prev parent reply other threads:[~2026-03-31 15:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 15:03 [PULL 0/6] Block layer patches Kevin Wolf
2026-03-31 15:03 ` [PULL 1/6] ide: Fix potential assertion failure on VM stop for PIO read error Kevin Wolf
2026-03-31 15:03 ` [PULL 2/6] scsi: Don't consider LOGICAL UNIT NOT SUPPORTED guest recoverable Kevin Wolf
2026-03-31 15:03 ` [PULL 3/6] block: Fix references in bdrv_bsc_*() function comments Kevin Wolf
2026-03-31 15:03 ` [PULL 4/6] monitor: Fix deadlock in monitor_cleanup Kevin Wolf
2026-04-04 6:02 ` Michael Tokarev
2026-04-04 6:08 ` Michael Tokarev
2026-04-07 12:04 ` Kevin Wolf
2026-04-07 13:30 ` Michael Tokarev
2026-04-07 16:46 ` Kevin Wolf
2026-04-07 17:12 ` Michael Tokarev
2026-04-08 9:05 ` Kevin Wolf
2026-04-07 16:57 ` Michael Tokarev
2026-03-31 15:03 ` [PULL 5/6] vhost-user-blk-server: fix opt_io_size=1 causing severe Windows I/O degradation Kevin Wolf
2026-03-31 15:03 ` Kevin Wolf [this message]
2026-03-31 18:04 ` [PULL 0/6] Block layer patches Peter Maydell
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=20260331150352.256332-7-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.