Re: [PATCH 4.14 204/267] blk-mq: avoid sysfs buffer overflow with too many CPU cores
From: Greg Kroah-Hartman
Date: Tue Dec 17 2019 - 02:49:09 EST
On Tue, Dec 17, 2019 at 01:28:29PM +0900, Nobuhiro Iwamatsu wrote:
> On Mon, Dec 16, 2019 at 06:48:50PM +0100, Greg Kroah-Hartman wrote:
> > From: Ming Lei <ming.lei@xxxxxxxxxx>
> >
> > 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@xxxxxxxxxxxxxxx
> > Fixes: 676141e48af7("blk-mq: don't dump CPU -> hw queue map on driver load")
> > Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
> > Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> >
>
> This commit also required following commit:
>
> commit d2c9be89f8ebe7ebcc97676ac40f8dec1cf9b43a
> Author: Ming Lei <ming.lei@xxxxxxxxxx>
> Date: Mon Nov 4 16:26:53 2019 +0800
>
> blk-mq: make sure that line break can be printed
>
> 8962842ca5ab ("blk-mq: avoid sysfs buffer overflow with too many CPU cores")
> avoids sysfs buffer overflow, and reserves one character for line break.
> However, the last snprintf() doesn't get correct 'size' parameter passed
> in, so fixed it.
>
> Fixes: 8962842ca5ab ("blk-mq: avoid sysfs buffer overflow with too many CPU cores")
> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
> Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
>
>
> And this is also required for 4.4, 4.9 and 4.19.
> Please apply.
Thank you for catching this, now queued up.
greg k-h