Commit 59f8bcc
printk: avoid and/or handle record truncation
If a reader provides a buffer that is smaller than the message text,
the @text_len field of @info will have a value larger than the buffer
size. If readers blindly read @text_len bytes of data without
checking the size, they will read beyond their buffer.
Add this check to record_print_text() to properly recognize when such
truncation has occurred.
Add a maximum size argument to the ringbuffer function to extend
records so that records can not be created that are larger than the
buffer size of readers.
When extending records (LOG_CONT), do not extend records beyond
LOG_LINE_MAX since that is the maximum size available in the buffers
used by consoles and syslog.
Fixes: f5f022e ("printk: reimplement log_cont using record extension")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20200930090134.8723-2-john.ogness@linutronix.de1 parent f35efc7 commit 59f8bcc
3 files changed
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1349 | 1349 | | |
1350 | 1350 | | |
1351 | 1351 | | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
1352 | 1359 | | |
1353 | 1360 | | |
1354 | 1361 | | |
| |||
1903 | 1910 | | |
1904 | 1911 | | |
1905 | 1912 | | |
1906 | | - | |
| 1913 | + | |
1907 | 1914 | | |
1908 | 1915 | | |
1909 | 1916 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
| 205 | + | |
| 206 | + | |
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
| |||
1309 | 1310 | | |
1310 | 1311 | | |
1311 | 1312 | | |
| 1313 | + | |
1312 | 1314 | | |
1313 | 1315 | | |
1314 | 1316 | | |
| |||
1343 | 1345 | | |
1344 | 1346 | | |
1345 | 1347 | | |
1346 | | - | |
| 1348 | + | |
1347 | 1349 | | |
1348 | 1350 | | |
1349 | 1351 | | |
| |||
1389 | 1391 | | |
1390 | 1392 | | |
1391 | 1393 | | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
1392 | 1397 | | |
1393 | 1398 | | |
1394 | 1399 | | |
| |||
1410 | 1415 | | |
1411 | 1416 | | |
1412 | 1417 | | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
1413 | 1421 | | |
1414 | 1422 | | |
1415 | 1423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
| 306 | + | |
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
| |||
0 commit comments