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>] [day] [month] [year] [list]
Message-Id: <20250416222740.work.569-kees@kernel.org>
Date: Wed, 16 Apr 2025 15:27:41 -0700
From: Kees Cook <kees@...nel.org>
To: Sebastian Reichel <sre@...nel.org>
Cc: Kees Cook <kees@...nel.org>,
	linux-pm@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	linux-hardening@...r.kernel.org
Subject: [PATCH] power: supply: sysfs: Remove duplicate NUL termination

GCC 15's new -Wunterminated-string-initialization notices that one of
the sysfs attr strings would lack the implicit trailing NUL byte during
initialization:

drivers/power/supply/power_supply_sysfs.c:183:57: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (32 chars into 31 available) [-Wunterminated-string-initialization]
  183 |         POWER_SUPPLY_ATTR(CHARGE_CONTROL_START_THRESHOLD),
      |                                                         ^
drivers/power/supply/power_supply_sysfs.c:36:23: note: in definition of macro '_POWER_SUPPLY_ATTR'
   36 |         .attr_name = #_name "\0",               \
      |                       ^~~~~
drivers/power/supply/power_supply_sysfs.c:183:9: note: in expansion of macro 'POWER_SUPPLY_ATTR'
  183 |         POWER_SUPPLY_ATTR(CHARGE_CONTROL_START_THRESHOLD),
      |         ^~~~~~~~~~~~~~~~~

However, the macro used was explicitly adding a trailing NUL byte (which
is not needed). Remove this to avoid the GCC warning. No binary
differences are seen after this change (there was always run for a NUL
byte, it's just that the _second_ NUL byte was getting truncated).

Signed-off-by: Kees Cook <kees@...nel.org>
---
Cc: Sebastian Reichel <sre@...nel.org>
Cc: <linux-pm@...r.kernel.org>
---
 drivers/power/supply/power_supply_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index edb058c19c9c..439dd0bf8644 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -33,7 +33,7 @@ struct power_supply_attr {
 [POWER_SUPPLY_PROP_ ## _name] =			\
 {						\
 	.prop_name = #_name,			\
-	.attr_name = #_name "\0",		\
+	.attr_name = #_name,			\
 	.text_values = _text,			\
 	.text_values_len = _len,		\
 }
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ