lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200813005610.GA85132@8851f5375e5a>
Date:   Thu, 13 Aug 2020 08:56:10 +0800
From:   kernel test robot <lkp@...el.com>
To:     Denis Efremov <efremov@...ux.com>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        Julia Lawall <Julia.Lawall@...6.fr>,
        Stefan Achatz <erazor_de@...rs.sourceforge.net>,
        Jiri Kosina <jikos@...nel.org>,
        Benjamin Tissoires <benjamin.tissoires@...hat.com>,
        linux-input@...r.kernel.org
Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings

From: kernel test robot <lkp@...el.com>

drivers/hid/hid-roccat-kone.c:406:8-16: WARNING: use scnprintf or sprintf
drivers/hid/hid-roccat-kone.c:397:8-16: WARNING: use scnprintf or sprintf
drivers/hid/hid-roccat-kone.c:438:8-16: WARNING: use scnprintf or sprintf
drivers/hid/hid-roccat-kone.c:550:8-16: WARNING: use scnprintf or sprintf
drivers/hid/hid-roccat-kone.c:448:8-16: WARNING: use scnprintf or sprintf
drivers/hid/hid-roccat-kone.c:429:8-16: WARNING: use scnprintf or sprintf


 From Documentation/filesystems/sysfs.txt:
  show() must not use snprintf() when formatting the value to be
  returned to user space. If you can guarantee that an overflow
  will never happen you can use sprintf() otherwise you must use
  scnprintf().

Generated by: scripts/coccinelle/api/device_attr_show.cocci

Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script")
CC: Denis Efremov <efremov@...ux.com>
Signed-off-by: kernel test robot <lkp@...el.com>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   7c2a69f610e64c8dec6a06a66e721f4ce1dd783a
commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script

Please take the patch only if it's a positive warning. Thanks!

 hid-roccat-kone.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

--- a/drivers/hid/hid-roccat-kone.c
+++ b/drivers/hid/hid-roccat-kone.c
@@ -394,7 +394,7 @@ static ssize_t kone_sysfs_show_actual_pr
 {
 	struct kone_device *kone =
 			hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
-	return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile);
 }
 static DEVICE_ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL);
 
@@ -403,7 +403,7 @@ static ssize_t kone_sysfs_show_actual_dp
 {
 	struct kone_device *kone =
 			hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
-	return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi);
 }
 static DEVICE_ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL);
 
@@ -426,7 +426,7 @@ static ssize_t kone_sysfs_show_weight(st
 
 	if (retval)
 		return retval;
-	return snprintf(buf, PAGE_SIZE, "%d\n", weight);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", weight);
 }
 static DEVICE_ATTR(weight, 0440, kone_sysfs_show_weight, NULL);
 
@@ -435,7 +435,7 @@ static ssize_t kone_sysfs_show_firmware_
 {
 	struct kone_device *kone =
 			hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
-	return snprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version);
 }
 static DEVICE_ATTR(firmware_version, 0440, kone_sysfs_show_firmware_version,
 		   NULL);
@@ -445,7 +445,7 @@ static ssize_t kone_sysfs_show_tcu(struc
 {
 	struct kone_device *kone =
 			hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
-	return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu);
 }
 
 static int kone_tcu_command(struct usb_device *usb_dev, int number)
@@ -547,7 +547,7 @@ static ssize_t kone_sysfs_show_startup_p
 {
 	struct kone_device *kone =
 			hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
-	return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile);
 }
 
 static ssize_t kone_sysfs_set_startup_profile(struct device *dev,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ