Skip to content

Commit

Permalink
db-ctl-base: Fix uninitialized datum fields while checking conditions.
Browse files Browse the repository at this point in the history
Statically allocated datum objects should be properly initialized with
a special function instead of doing that manually.

 WARNING: MemorySanitizer: use-of-uninitialized-value
  0 0x58789c in ovsdb_datum_compare_3way lib/ovsdb-data.c:1846:19
  1 0x52bbab in evaluate_relop lib/db-ctl-base.c:731:16
  2 0x52b042 in check_condition lib/db-ctl-base.c:844:22
  3 0x522fea in cmd_wait_until lib/db-ctl-base.c:1935:22
  4 0x4c704b in do_vsctl utilities/ovs-vsctl.c:3001:13
  5 0x4c4429 in main utilities/ovs-vsctl.c:204:17
  6 0x7f5ad5 in __libc_start_call_main
  7 0x7f5ad5 in __libc_start_main@GLIBC_2.2.5
  8 0x432b04 in _start (utilities/ovs-vsctl+0x432b04)

In this case the reference counter ended up not initialized.

While at it, also updating the list_record() function to use a proper
initialization, even if it doesn't cause any issues for now.

Fixes: 485ac63 ("ovsdb: Add lazy-copy support for ovsdb_datum objects.")
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 9cc0ce7 commit cc45504
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/db-ctl-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,14 +831,10 @@ check_condition(const struct ovsdb_idl_table_class *table,
} else {
struct ovsdb_datum a;

ovsdb_datum_init_empty(&a);
if (found) {
a.n = 1;
a.keys = &have_datum->values[idx];
a.values = NULL;
} else {
a.n = 0;
a.keys = NULL;
a.values = NULL;
}

retval = evaluate_relop(&a, &b, &type, operator);
Expand Down Expand Up @@ -1160,8 +1156,8 @@ list_record(const struct ovsdb_idl_row *row,

atom.uuid = row->uuid;

ovsdb_datum_init_empty(&datum);
datum.keys = &atom;
datum.values = NULL;
datum.n = 1;

cell->json = ovsdb_datum_to_json(&datum, &ovsdb_type_uuid);
Expand Down

0 comments on commit cc45504

Please sign in to comment.