Skip to content

Commit

Permalink
ovsdb-idl: Fix use of uninitialized datum for graph consistency check.
Browse files Browse the repository at this point in the history
Columns in 'new_datum' may not be initialized if they were not written,
i.e., when the column in not in the 'written' bitmap.  In this case the
actual content should be read from the 'old_datum' instead.  If the old
one is also not available, then the default should be used.

 WARNING: MemorySanitizer: use-of-uninitialized-value
  0 0x78d27f in ovsdb_idl_check_consistency lib/ovsdb-idl.c:732:21
  1 0x4ee12a in idl_set tests/test-ovsdb.c:2586:9
  2 0x4d7c4b in do_idl tests/test-ovsdb.c:2868:18
  3 0x6c5704 in ovs_cmdl_run_command__ lib/command-line.c:247:17
  4 0x6c4d28 in ovs_cmdl_run_command lib/command-line.c:278:5
  5 0x4c39bf in main tests/test-ovsdb.c:80:5
  6 0x7f912a02958f in __libc_start_call_main
  7 0x7f912a02963f in __libc_start_main@GLIBC_2.2.5
  8 0x432b54 in _start (tests/test-ovsdb+0x432b54)

Use the ovsdb_idl_read() helper to read the actual correct data
during the consistency check.

Alternative might be to iterate over the 'written' bitmap and only
check those columns, but it seems like that will reduce the intended
scope of the check, since 'new_datum' may exist while the 'written'
bitmap doesn't, e.g., when 'new_datum == old_datum'.

Fixes: 11990a5 ("ovsdb-idl: Check internal graph in OVSDB tests.")
Acked-by: Dumitru Ceara <[email protected]>
Acked-by: Eelco Chaudron <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Nov 29, 2024
1 parent bfbe73d commit 465907d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ovsdb-idl.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,9 @@ ovsdb_idl_check_consistency(const struct ovsdb_idl *idl)
size_t n_columns = shash_count(&row->table->columns);
for (size_t j = 0; j < n_columns; j++) {
const struct ovsdb_type *type = &class->columns[j].type;
const struct ovsdb_datum *datum = &row->new_datum[j];
const struct ovsdb_datum *datum;

datum = ovsdb_idl_read(row, &class->columns[j]);
add_row_references(&type->key,
datum->keys, datum->n, &row->uuid,
&dsts, &n_dsts, &allocated_dsts);
Expand Down

0 comments on commit 465907d

Please sign in to comment.