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  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]
Date:   Thu, 13 Aug 2020 08:56:06 +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>,
        "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Len Brown <lenb@...nel.org>, linux-acpi@...r.kernel.org
Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings

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

drivers/acpi/dock.c:563:8-16: WARNING: use scnprintf or sprintf
drivers/acpi/dock.c:544:8-16: WARNING: use scnprintf or sprintf
drivers/acpi/dock.c:495:8-16: WARNING: use scnprintf or sprintf
drivers/acpi/dock.c:506: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!

 dock.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -492,7 +492,7 @@ static ssize_t show_docked(struct device
 	struct acpi_device *adev = NULL;
 
 	acpi_bus_get_device(dock_station->handle, &adev);
-	return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
+	return scnprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
 }
 static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
 
@@ -503,7 +503,7 @@ static ssize_t show_flags(struct device
 			  struct device_attribute *attr, char *buf)
 {
 	struct dock_station *dock_station = dev->platform_data;
-	return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
 
 }
 static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
@@ -541,7 +541,7 @@ static ssize_t show_dock_uid(struct devi
 	if (ACPI_FAILURE(status))
 	    return 0;
 
-	return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
+	return scnprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
 }
 static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
 
@@ -560,7 +560,7 @@ static ssize_t show_dock_type(struct dev
 	else
 		type = "unknown";
 
-	return snprintf(buf, PAGE_SIZE, "%s\n", type);
+	return scnprintf(buf, PAGE_SIZE, "%s\n", type);
 }
 static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
 

Powered by blists - more mailing lists