Re: [PATCH printk v4 5/6] printk: ringbuffer: add finalization/extension support

From: Dan Carpenter
Date: Wed Sep 09 2020 - 06:42:07 EST


Hi John,

url: https://github.com/0day-ci/linux/commits/John-Ogness/printk-reimplement-LOG_CONT-handling/20200909-115852
base: dff9f829e5b0181d4ed9d35aa62d695292399b54
config: x86_64-randconfig-m001-20200909 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

smatch warnings:
kernel/printk/printk_ringbuffer.c:1385 prb_reserve_in_last() error: uninitialized symbol 'data_size'.

# https://github.com/0day-ci/linux/commit/4b08e95d4858fb7e2fe1732aa7f4f6f6881eac91
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review John-Ogness/printk-reimplement-LOG_CONT-handling/20200909-115852
git checkout 4b08e95d4858fb7e2fe1732aa7f4f6f6881eac91
vim +/data_size +1385 kernel/printk/printk_ringbuffer.c

4b08e95d4858fb John Ogness 2020-09-08 1346 bool prb_reserve_in_last(struct prb_reserved_entry *e, struct printk_ringbuffer *rb,
4b08e95d4858fb John Ogness 2020-09-08 1347 struct printk_record *r, u32 caller_id)
4b08e95d4858fb John Ogness 2020-09-08 1348 {
4b08e95d4858fb John Ogness 2020-09-08 1349 unsigned int data_size;
4b08e95d4858fb John Ogness 2020-09-08 1350 struct prb_desc *d;
4b08e95d4858fb John Ogness 2020-09-08 1351 unsigned long id;
4b08e95d4858fb John Ogness 2020-09-08 1352
4b08e95d4858fb John Ogness 2020-09-08 1353 local_irq_save(e->irqflags);
4b08e95d4858fb John Ogness 2020-09-08 1354
4b08e95d4858fb John Ogness 2020-09-08 1355 /* Transition the newest descriptor back to the reserved state. */
4b08e95d4858fb John Ogness 2020-09-08 1356 d = desc_reopen_last(&rb->desc_ring, caller_id, &id);
4b08e95d4858fb John Ogness 2020-09-08 1357 if (!d) {
4b08e95d4858fb John Ogness 2020-09-08 1358 local_irq_restore(e->irqflags);
4b08e95d4858fb John Ogness 2020-09-08 1359 goto fail_reopen;
4b08e95d4858fb John Ogness 2020-09-08 1360 }
4b08e95d4858fb John Ogness 2020-09-08 1361
4b08e95d4858fb John Ogness 2020-09-08 1362 /* Now the writer has exclusive access: LMM(prb_reserve_in_last:A) */
4b08e95d4858fb John Ogness 2020-09-08 1363
4b08e95d4858fb John Ogness 2020-09-08 1364 /*
4b08e95d4858fb John Ogness 2020-09-08 1365 * Set the @e fields here so that prb_commit() can be used if
4b08e95d4858fb John Ogness 2020-09-08 1366 * anything fails from now on.
4b08e95d4858fb John Ogness 2020-09-08 1367 */
4b08e95d4858fb John Ogness 2020-09-08 1368 e->rb = rb;
4b08e95d4858fb John Ogness 2020-09-08 1369 e->id = id;
4b08e95d4858fb John Ogness 2020-09-08 1370
4b08e95d4858fb John Ogness 2020-09-08 1371 /*
4b08e95d4858fb John Ogness 2020-09-08 1372 * desc_reopen_last() checked the caller_id, but there was no
4b08e95d4858fb John Ogness 2020-09-08 1373 * exclusive access at that point. The descriptor may have
4b08e95d4858fb John Ogness 2020-09-08 1374 * changed since then.
4b08e95d4858fb John Ogness 2020-09-08 1375 */
4b08e95d4858fb John Ogness 2020-09-08 1376 if (caller_id != d->info.caller_id)
4b08e95d4858fb John Ogness 2020-09-08 1377 goto fail;
4b08e95d4858fb John Ogness 2020-09-08 1378
4b08e95d4858fb John Ogness 2020-09-08 1379 if (BLK_DATALESS(&d->text_blk_lpos)) {
4b08e95d4858fb John Ogness 2020-09-08 1380 r->text_buf = data_alloc(rb, &rb->text_data_ring, r->text_buf_size,
4b08e95d4858fb John Ogness 2020-09-08 1381 &d->text_blk_lpos, id);
4b08e95d4858fb John Ogness 2020-09-08 1382 if (WARN_ON_ONCE(d->info.text_len != 0)) {
4b08e95d4858fb John Ogness 2020-09-08 1383 pr_warn_once("wrong text_len value (%u, expecting 0)\n",
4b08e95d4858fb John Ogness 2020-09-08 1384 d->info.text_len);
4b08e95d4858fb John Ogness 2020-09-08 @1385 d->info.text_len = data_size;
^^^^^^^^^
Not initialized yet.

4b08e95d4858fb John Ogness 2020-09-08 1386 }
4b08e95d4858fb John Ogness 2020-09-08 1387 } else {
4b08e95d4858fb John Ogness 2020-09-08 1388 if (!get_data(&rb->text_data_ring, &d->text_blk_lpos, &data_size))
^^^^^^^^^^

4b08e95d4858fb John Ogness 2020-09-08 1389 goto fail;
4b08e95d4858fb John Ogness 2020-09-08 1390
4b08e95d4858fb John Ogness 2020-09-08 1391 /*
4b08e95d4858fb John Ogness 2020-09-08 1392 * Increase the buffer size to include the original size. If
4b08e95d4858fb John Ogness 2020-09-08 1393 * the meta data (@text_len) is not sane, use the full data
4b08e95d4858fb John Ogness 2020-09-08 1394 * block size.
4b08e95d4858fb John Ogness 2020-09-08 1395 */
4b08e95d4858fb John Ogness 2020-09-08 1396 if (WARN_ON_ONCE(d->info.text_len > data_size)) {
4b08e95d4858fb John Ogness 2020-09-08 1397 pr_warn_once("wrong text_len value (%u, expecting <=%hu)\n",
4b08e95d4858fb John Ogness 2020-09-08 1398 d->info.text_len, data_size);
4b08e95d4858fb John Ogness 2020-09-08 1399 d->info.text_len = data_size;
4b08e95d4858fb John Ogness 2020-09-08 1400 }
4b08e95d4858fb John Ogness 2020-09-08 1401 r->text_buf_size += d->info.text_len;
4b08e95d4858fb John Ogness 2020-09-08 1402
4b08e95d4858fb John Ogness 2020-09-08 1403 if (!data_check_size(&rb->text_data_ring, r->text_buf_size))
4b08e95d4858fb John Ogness 2020-09-08 1404 goto fail;
4b08e95d4858fb John Ogness 2020-09-08 1405
4b08e95d4858fb John Ogness 2020-09-08 1406 r->text_buf = data_realloc(rb, &rb->text_data_ring, r->text_buf_size,
4b08e95d4858fb John Ogness 2020-09-08 1407 &d->text_blk_lpos, id);
4b08e95d4858fb John Ogness 2020-09-08 1408 }
4b08e95d4858fb John Ogness 2020-09-08 1409 if (r->text_buf_size && !r->text_buf)
4b08e95d4858fb John Ogness 2020-09-08 1410 goto fail;
4b08e95d4858fb John Ogness 2020-09-08 1411
4b08e95d4858fb John Ogness 2020-09-08 1412 /* Although dictionary data may be in use, it cannot be extended. */
4b08e95d4858fb John Ogness 2020-09-08 1413 r->dict_buf = NULL;
4b08e95d4858fb John Ogness 2020-09-08 1414 r->dict_buf_size = 0;
4b08e95d4858fb John Ogness 2020-09-08 1415
4b08e95d4858fb John Ogness 2020-09-08 1416 r->info = &d->info;
4b08e95d4858fb John Ogness 2020-09-08 1417
4b08e95d4858fb John Ogness 2020-09-08 1418 e->text_space = space_used(&rb->text_data_ring, &d->text_blk_lpos);
4b08e95d4858fb John Ogness 2020-09-08 1419
4b08e95d4858fb John Ogness 2020-09-08 1420 return true;
4b08e95d4858fb John Ogness 2020-09-08 1421 fail:
4b08e95d4858fb John Ogness 2020-09-08 1422 prb_commit(e);
4b08e95d4858fb John Ogness 2020-09-08 1423 /* prb_commit() re-enabled interrupts. */
4b08e95d4858fb John Ogness 2020-09-08 1424 fail_reopen:
4b08e95d4858fb John Ogness 2020-09-08 1425 /* Make it clear to the caller that the re-reserve failed. */
4b08e95d4858fb John Ogness 2020-09-08 1426 memset(r, 0, sizeof(*r));
4b08e95d4858fb John Ogness 2020-09-08 1427 return false;
4b08e95d4858fb John Ogness 2020-09-08 1428 }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip