loop: use sysfs_emit() in the sysfs xxx show()
authorChaitanya Kulkarni <kch@nvidia.com>
Tue, 15 Feb 2022 21:33:07 +0000 (13:33 -0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 15 Feb 2022 21:42:00 +0000 (14:42 -0700)
commitd6fcd8b8eadc20f1425630e5aed0d98d41d172d6
tree4cacc8499570808392ed646d64aaeaf57636aa0a
parent090b71c8ebbe8764dcbb81b90bd8733b3119ab7b
loop: use sysfs_emit() in the sysfs xxx show()

sprintf does not know the PAGE_SIZE maximum of the temporary buffer
used for outputting sysfs content and it's possible to overrun the
PAGE_SIZE buffer length.

Use a generic sysfs_emit function that knows the size of the
temporary buffer and ensures that no overrun is done for offset
attribute in
loop_attr_[offset|sizelimit|autoclear|partscan|dio]_show() callbacks.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Link: https://lore.kernel.org/r/20220215213310.7264-2-kch@nvidia.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/loop.c