]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
blk-mq: avoid sysfs buffer overflow with too many CPU cores
authorMing Lei <ming.lei@redhat.com>
Sat, 2 Nov 2019 08:02:15 +0000 (16:02 +0800)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:22:41 +0000 (14:22 -0300)
commitd00dc13c23fa6417a877f8dec3ca6a0a9b873aed
tree788797c4a07e202ada27472a4b26e781e18a8c11
parent0c0b28cf6b9f24187b0d4778306053a4e78fa458
blk-mq: avoid sysfs buffer overflow with too many CPU cores

BugLink: https://bugs.launchpad.net/bugs/1857158
commit 8962842ca5abdcf98e22ab3b2b45a103f0408b95 upstream.

It is reported that sysfs buffer overflow can be triggered if the system
has too many CPU cores(>841 on 4K PAGE_SIZE) when showing CPUs of
hctx via /sys/block/$DEV/mq/$N/cpu_list.

Use snprintf to avoid the potential buffer overflow.

This version doesn't change the attribute format, and simply stops
showing CPU numbers if the buffer is going to overflow.

Cc: stable@vger.kernel.org
Fixes: 676141e48af7("blk-mq: don't dump CPU -> hw queue map on driver load")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
block/blk-mq-sysfs.c