Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

printk_ringbuffer: Add sanity check for 0-size data

get_data() has a sanity check for regular data blocks to ensure at
least space for the ID exists. But a regular block should also have
at least 1 byte of data (otherwise it would be data-less instead of
regular).

Expand the get_data() block size sanity check to additionally expect
at least 1 byte of data.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Tested-by: Petr Mladek <pmladek@suse.com>
Link: https://patch.msgid.link/20260326133809.8045-2-john.ogness@linutronix.de
Signed-off-by: Petr Mladek <pmladek@suse.com>

authored by

John Ogness and committed by
Petr Mladek
407f666d 8e81ecbf

+5 -2
+5 -2
kernel/printk/printk_ringbuffer.c
··· 1308 1308 return NULL; 1309 1309 } 1310 1310 1311 - /* A valid data block will always have at least an ID. */ 1312 - if (WARN_ON_ONCE(*data_size < sizeof(db->id))) 1311 + /* 1312 + * A regular data block will always have an ID and at least 1313 + * 1 byte of data. Data-less blocks were handled earlier. 1314 + */ 1315 + if (WARN_ON_ONCE(*data_size <= sizeof(db->id))) 1313 1316 return NULL; 1314 1317 1315 1318 /* Subtract block ID space from size to reflect data size. */