]> xenbits.xensource.com Git - xen.git/commitdiff
tools/xenstore: fix deleting node in transaction
authorJuergen Gross <jgross@suse.com>
Tue, 13 Sep 2022 05:35:13 +0000 (07:35 +0200)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 1 Nov 2022 15:03:25 +0000 (15:03 +0000)
In case a node has been created in a transaction and it is later
deleted in the same transaction, the transaction will be terminated
with an error.

As this error is encountered only when handling the deleted node at
transaction finalization, the transaction will have been performed
partially and without updating the accounting information. This will
enable a malicious guest to create arbitrary number of nodes.

This is part of XSA-421 / CVE-2022-42325.

Signed-off-by: Juergen Gross <jgross@suse.com>
Tested-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
(cherry picked from commit 13ac37f1416cae88d97f7baf6cf2a827edb9a187)

tools/xenstore/xenstored_transaction.c

index 3e3eb47326cce50d63a32c6010cc6ebcad93dea9..7ffe21bb52857c4169fa7f6c580cd0d49a050f90 100644 (file)
@@ -418,7 +418,13 @@ static int finalize_transaction(struct connection *conn,
                                                   true);
                                talloc_free(data.dptr);
                        } else {
-                               ret = do_tdb_delete(conn, &key, NULL);
+                               /*
+                                * A node having been created and later deleted
+                                * in this transaction will have no generation
+                                * information stored.
+                                */
+                               ret = (i->generation == NO_GENERATION)
+                                     ? 0 : do_tdb_delete(conn, &key, NULL);
                        }
                        if (ret)
                                goto err;