1
0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2026-01-12 01:20:14 +00:00
Kees Cook 655862865c mod_devicetable: Enlarge the maximum platform_device_id name length
The 20 byte length of struct platform_device_id::name is not long enough
for many devices (especially regulators), where the string initialization
is getting truncated and missing the trailing NUL byte. This is seen
with GCC 15's -Wunterminated-string-initialization option:

drivers/regulator/hi6421v530-regulator.c:189:19: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (21 chars into 20 available) [-Wunterminated-string-initialization]
  189 |         { .name = "hi6421v530-regulator" },
      |                   ^~~~~~~~~~~~~~~~~~~~~~
drivers/regulator/hi6421v600-regulator.c:278:19: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (21 chars into 20 available) [-Wunterminated-string-initialization]
  278 |         { .name = "hi6421v600-regulator" },
      |                   ^~~~~~~~~~~~~~~~~~~~~~
drivers/regulator/lp87565-regulator.c:233:11: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (21 chars into 20 available) [-Wunterminated-string-initialization]
  233 |         { "lp87565-q1-regulator", },
      |           ^~~~~~~~~~~~~~~~~~~~~~
sound/soc/fsl/imx-pcm-rpmsg.c:818:19: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (21 chars into 20 available) [-Wunterminated-string-initialization]
  818 |         { .name = "rpmsg-micfil-channel" },
      |                   ^~~~~~~~~~~~~~~~~~~~~~
drivers/iio/light/hid-sensor-als.c:457:25: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (21 chars into 20 available) [-Wunterminated-string-initialization]
  457 |                 .name = "HID-SENSOR-LISS-0041",
      |                         ^~~~~~~~~~~~~~~~~~~~~~
drivers/iio/light/hid-sensor-prox.c:366:25: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (21 chars into 20 available) [-Wunterminated-string-initialization]
  366 |                 .name = "HID-SENSOR-LISS-0226",
      |                         ^~~~~~~~~~~~~~~~~~~~~~

Increase the length to 24, slightly more than is currently being used by
the affected drivers. The string is used in '%s' format strings and via
the module code, which appears to do its own length encoding. This size
was chosen because there was already a 4 byte hole in the structure:

struct platform_device_id {
        char                       name[20];             /*     0    20 */

        /* XXX 4 bytes hole, try to pack */

        kernel_ulong_t             driver_data;          /*    24     8 */

        /* size: 32, cachelines: 1, members: 2 */
        /* sum members: 28, holes: 1, sum holes: 4 */
        /* last cacheline: 32 bytes */
};

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20250415231420.work.066-kees@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
2025-04-28 10:32:43 -07:00
..
2025-04-03 21:35:32 +02:00
2025-04-01 11:02:03 -07:00
2025-03-21 09:46:08 +01:00
2025-04-03 15:31:14 -07:00
2025-03-29 11:12:28 -07:00
2025-03-21 20:57:55 -03:00
2025-03-25 14:22:07 -07:00
2025-03-13 14:15:54 +00:00
2025-04-02 18:23:31 -07:00
2025-04-02 20:04:43 -07:00
2025-03-26 18:08:55 -07:00
2025-04-25 11:34:39 -07:00
2025-03-30 13:45:28 -07:00
2025-04-02 07:06:59 -06:00
2025-03-08 14:37:39 +01:00
2025-03-20 17:33:31 -04:00
2025-03-17 22:06:41 -07:00
2025-04-01 11:02:03 -07:00
2025-03-30 12:43:03 -07:00
2025-03-27 13:27:08 -07:00
2025-03-24 09:34:10 -07:00
2025-03-25 12:35:59 +01:00
2025-04-01 18:03:46 -07:00
2025-03-27 09:46:53 -07:00
2025-04-01 18:03:46 -07:00
2025-03-10 13:13:04 -07:00
2025-03-22 15:36:49 +02:00
2025-03-08 12:13:25 +01:00
2025-03-19 07:31:43 -07:00
2025-03-28 12:37:13 -07:00
2025-03-30 12:43:03 -07:00
2025-03-31 13:37:22 -07:00
2025-04-15 11:32:34 +02:00
2025-03-17 13:54:50 +00:00
2025-04-02 17:06:31 -07:00
2025-03-26 18:08:55 -07:00
2025-03-29 11:23:16 -07:00
2025-03-06 15:13:13 -04:00
2025-03-28 19:36:53 -07:00
2025-03-27 13:14:46 -05:00
2025-03-08 15:08:45 -06:00
2025-03-10 08:53:40 +01:00
2025-03-12 20:41:14 +01:00
2025-03-16 17:40:22 -07:00
2025-03-24 19:41:37 -07:00
2025-03-17 11:52:25 +01:00
2025-03-30 12:43:03 -07:00
2025-03-24 09:34:10 -07:00
2025-03-25 13:16:16 -07:00
2025-03-20 08:00:50 -07:00
2025-03-25 09:15:07 -07:00
2025-04-18 10:05:49 -04:00
2025-03-26 18:08:55 -07:00
2025-03-13 13:25:58 -07:00
2025-03-13 13:25:58 -07:00
2025-03-13 13:25:58 -07:00