]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Apr 2022 07:06:38 +0000 (09:06 +0200)
commit0e0d0dc27dad0036874d18f712b76ff05a3b89f9
tree3b571a199291beb4614238d0fb18c754f29bb8da
parent6f7fad6056af08a202cd34e499f214668dae157e
loop: use sysfs_emit() in the sysfs xxx show()

[ Upstream commit b27824d31f09ea7b4a6ba2c1b18bd328df3e8bed ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/block/loop.c