From e6844c64600385278a65969990cd8ac3451324f0 Mon Sep 17 00:00:00 2001 From: Ilya Maximets Date: Thu, 28 Nov 2024 22:11:25 +0100 Subject: [PATCH] ovsdb-idl: Fix use of uninitialized datum for graph consistency check. 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: 11990a5274f7 ("ovsdb-idl: Check internal graph in OVSDB tests.") Acked-by: Dumitru Ceara Acked-by: Eelco Chaudron Signed-off-by: Ilya Maximets --- lib/ovsdb-idl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index d92df28d191..4c2a3e3aa90 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -728,7 +728,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);