Patch "loop: use sysfs_emit() in the sysfs xxx show()" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    loop: use sysfs_emit() in the sysfs xxx show()

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     loop-use-sysfs_emit-in-the-sysfs-xxx-show.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 6b3d3e2472fd4340e04a09e98babd26adb1d8fd3
Author: Chaitanya Kulkarni <kch@xxxxxxxxxx>
Date:   Tue Feb 15 13:33:07 2022 -0800

    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@xxxxxxxxxx>
    Reviewed-by: Himanshu Madhani <himanshu.madhani@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220215213310.7264-2-kch@xxxxxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 92f9d32bfae5..8cba10aafadb 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -844,33 +844,33 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf)
 
 static ssize_t loop_attr_offset_show(struct loop_device *lo, char *buf)
 {
-	return sprintf(buf, "%llu\n", (unsigned long long)lo->lo_offset);
+	return sysfs_emit(buf, "%llu\n", (unsigned long long)lo->lo_offset);
 }
 
 static ssize_t loop_attr_sizelimit_show(struct loop_device *lo, char *buf)
 {
-	return sprintf(buf, "%llu\n", (unsigned long long)lo->lo_sizelimit);
+	return sysfs_emit(buf, "%llu\n", (unsigned long long)lo->lo_sizelimit);
 }
 
 static ssize_t loop_attr_autoclear_show(struct loop_device *lo, char *buf)
 {
 	int autoclear = (lo->lo_flags & LO_FLAGS_AUTOCLEAR);
 
-	return sprintf(buf, "%s\n", autoclear ? "1" : "0");
+	return sysfs_emit(buf, "%s\n", autoclear ? "1" : "0");
 }
 
 static ssize_t loop_attr_partscan_show(struct loop_device *lo, char *buf)
 {
 	int partscan = (lo->lo_flags & LO_FLAGS_PARTSCAN);
 
-	return sprintf(buf, "%s\n", partscan ? "1" : "0");
+	return sysfs_emit(buf, "%s\n", partscan ? "1" : "0");
 }
 
 static ssize_t loop_attr_dio_show(struct loop_device *lo, char *buf)
 {
 	int dio = (lo->lo_flags & LO_FLAGS_DIRECT_IO);
 
-	return sprintf(buf, "%s\n", dio ? "1" : "0");
+	return sysfs_emit(buf, "%s\n", dio ? "1" : "0");
 }
 
 LOOP_ATTR_RO(backing_file);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux