blk-mq: remove blk_mq_hw_sysfs_cpus
Subsystems (2)
PATCH 1/1 blk-mq: remove blk_mq_hw_sysfs_cpus
It is reported that sysfs buffer overflow can be triggered in case of too many CPU cores(>841 on 4K PAGE_SIZE) when showing CPUs in blk_mq_hw_sysfs_cpus_show().
This info isn't useful, given users may retrieve the CPU list from sw queue entries under same kobject dir, so far not see any active users.
So remove the entry as suggested by Greg.
--- block/blk-mq-sysfs.c | 23 ----------------------- 1 file changed, 23 deletions(-)
block/blk-mq-sysfs.c +0 -23
@@ -164,24 +164,6 @@ static ssize_t blk_mq_hw_sysfs_nr_reserved_tags_show(struct blk_mq_hw_ctx *hctx,return sprintf (page,"%u\n" , hctx->tags->nr_reserved_tags); } -static ssize_t blk_mq_hw_sysfs_cpus_show (struct blk_mq_hw_ctx *hctx,char *page) -{ -unsigned int i, first =1 ; -ssize_t ret =0 ; - -for_each_cpu (i, hctx->cpumask) { -if (first) - ret +=sprintf (ret + page,"%u" , i); -else - ret +=sprintf (ret + page,", %u" , i); - - first =0 ; - } - - ret +=sprintf (ret + page,"\n" ); -return ret; -} -static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_tags = { .attr = {.name ="nr_tags" , .mode =0444 }, .show = blk_mq_hw_sysfs_nr_tags_show,
@@ -190,15 +172,10 @@ static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_reserved_tags = { .attr = {.name = "nr_reserved_tags", .mode = 0444 }, .show = blk_mq_hw_sysfs_nr_reserved_tags_show, }; -static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_cpus = { - .attr = {.name ="cpu_list" , .mode =0444 }, - .show = blk_mq_hw_sysfs_cpus_show, -};static struct attribute *default_hw_ctx_attrs[] = { &blk_mq_hw_sysfs_nr_tags.attr, &blk_mq_hw_sysfs_nr_reserved_tags.attr, - &blk_mq_hw_sysfs_cpus.attr,NULL , };ATTRIBUTE_GROUPS (default_hw_ctx);
Signature · 1 line
2.20.1
Quoted 10 lines · Ming Lei
It is reported that sysfs buffer overflow can be triggered in case of too many CPU
cores(>841 on 4K PAGE_SIZE)when showing CPUs inblk_mq_hw_sysfs_cpus_show().This info isn't useful, given users may retrieve the CPU list from sw queue entries under same kobject dir, so far not see any active users.
So remove the entry as suggested by Greg.
Quoted 8 lines
Cc Mark Ray <[email protected]>Cc Greg KH <[email protected]>Fixes 676141e48af7("blk-mq: don't dump CPU -> hw queue map on driver load")Signed-off-by Ming Lei <[email protected]>--- block/blk-mq-sysfs.c | 23 ----------------------- 1 file changed, 23 deletions(-)
Jens Axboe
maintainerQuoted 9 lines · Ming Lei
It is reported that sysfs buffer overflow can be triggered in case of too many CPU
cores(>841 on 4K PAGE_SIZE)when showing CPUs inblk_mq_hw_sysfs_cpus_show().This info isn't useful, given users may retrieve the CPU list from sw queue entries under same kobject dir, so far not see any active users.
So remove the entry as suggested by Greg.
I think that's a bit frivolous, there could very well be scripts or apps that use it. Let's just fix the overflow.
Signature · 1 line
Jens Axboe
Greg KH
maintainerQuoted 5 lines · Jens Axboe
Quoted 4 lines · Ming Lei
It is reported that sysfs buffer overflow can be triggered in case of too many CPU
cores(>841 on 4K PAGE_SIZE)when showing CPUs inblk_mq_hw_sysfs_cpus_show().
Quoted 8 lines
Quoted 5 lines
This info isn't useful, given users may retrieve the CPU list from sw queue entries under same kobject dir, so far not see any active users.
So remove the entry as suggested by Greg.
I think that's a bit frivolous, there could very well be scripts or apps that use it. Let's just fix the overflow.
As no one really knows what the format is (and the patch to fix the overflow changes the format of the file), I would say that it needs to just be dropped as it is not an example of what you should be doing in sysfs.
thanks,
greg k-h
Jens Axboe
maintainerQuoted 12 lines · Greg KH
Quoted 11 lines · Jens Axboe
Quoted 9 lines · Ming Lei
It is reported that sysfs buffer overflow can be triggered in case of too many CPU
cores(>841 on 4K PAGE_SIZE)when showing CPUs inblk_mq_hw_sysfs_cpus_show().This info isn't useful, given users may retrieve the CPU list from sw queue entries under same kobject dir, so far not see any active users.
So remove the entry as suggested by Greg.
Quoted 7 lines
Quoted 2 lines
I think that's a bit frivolous, there could very well be scripts or apps that use it. Let's just fix the overflow.
As no one really knows what the format is (and the patch to fix the overflow changes the format of the file), I would say that it needs to just be dropped as it is not an example of what you should be doing in sysfs.
It's a list of CPUs, I think the format is quite self explanatory?
But in any case, I'm not 100% opposed to removing it, it's just not one of those things that should be done on a whim.
Signature · 1 line
Jens Axboe
Greg KH
maintainerQuoted 16 lines · Jens Axboe
Quoted 15 lines · Greg KH
Quoted 13 lines · Jens Axboe
Quoted 9 lines · Ming Lei
It is reported that sysfs buffer overflow can be triggered in case of too many CPU
cores(>841 on 4K PAGE_SIZE)when showing CPUs inblk_mq_hw_sysfs_cpus_show().This info isn't useful, given users may retrieve the CPU list from sw queue entries under same kobject dir, so far not see any active users.
So remove the entry as suggested by Greg.
I think that's a bit frivolous, there could very well be scripts or apps that use it. Let's just fix the overflow.
Quoted 6 lines
Quoted 4 lines
As no one really knows what the format is (and the patch to fix the overflow changes the format of the file), I would say that it needs to just be dropped as it is not an example of what you should be doing in sysfs.
It's a list of CPUs, I think the format is quite self explanatory?
I'm not disagreeing, but the patch to fix the length changes the formatting to be different. So if you were needing to parse that file, it now just broke the parser.
Which is why sysfs is to be one-value-per-file :)
Quoted 2 lines
But in any case, I'm not 100% opposed to removing it, it's just not one of those things that should be done on a whim.
If the format of the file is going to change, I would argue that the filename should change as well, so that it's obvious what is happening here. This is how we got in trouble with /proc files so many times...
thanks,
greg k-h
Quoted 5 lines · Jens Axboe
Quoted 4 lines · Ming Lei
It is reported that sysfs buffer overflow can be triggered in case of too many CPU
cores(>841 on 4K PAGE_SIZE)when showing CPUs inblk_mq_hw_sysfs_cpus_show().
Quoted 8 lines
Quoted 5 lines
This info isn't useful, given users may retrieve the CPU list from sw queue entries under same kobject dir, so far not see any active users.
So remove the entry as suggested by Greg.
I think that's a bit frivolous, there could very well be scripts or apps that use it. Let's just fix the overflow.
I am fine with either way.
There are two fixes:
1) without format change:
https://lore.kernel.org/linux-block/[email protected]/T/#t
2) format change:
https://lore.kernel.org/linux-block/[email protected]/T/#t
If either one isn't fine, please let me know, and I will cook new one for you.
Thanks,
Ming