Commit ad6bcdad authored by Babis Chalios's avatar Babis Chalios Committed by Greg Kroah-Hartman

vmgenid: emit uevent when VMGENID updates

We receive an ACPI notification every time the VM Generation ID changes
and use the new ID as fresh randomness added to the entropy pool. This
commits emits a uevent every time we receive the ACPI notification, as a
means to notify the user space that it now is in a new VM.
Signed-off-by: default avatarBabis Chalios <bchalios@amazon.es>
Reviewed-by: default avatarAlexander Graf <graf@amazon.com>
Reviewed-by: default avatarLennart Poettering <mzxreary@0pointer.de>
Link: https://lore.kernel.org/r/20230531095119.11202-2-bchalios@amazon.esSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b9873755
...@@ -68,6 +68,7 @@ static int vmgenid_add(struct acpi_device *device) ...@@ -68,6 +68,7 @@ static int vmgenid_add(struct acpi_device *device)
static void vmgenid_notify(struct acpi_device *device, u32 event) static void vmgenid_notify(struct acpi_device *device, u32 event)
{ {
struct vmgenid_state *state = acpi_driver_data(device); struct vmgenid_state *state = acpi_driver_data(device);
char *envp[] = { "NEW_VMGENID=1", NULL };
u8 old_id[VMGENID_SIZE]; u8 old_id[VMGENID_SIZE];
memcpy(old_id, state->this_id, sizeof(old_id)); memcpy(old_id, state->this_id, sizeof(old_id));
...@@ -75,6 +76,7 @@ static void vmgenid_notify(struct acpi_device *device, u32 event) ...@@ -75,6 +76,7 @@ static void vmgenid_notify(struct acpi_device *device, u32 event)
if (!memcmp(old_id, state->this_id, sizeof(old_id))) if (!memcmp(old_id, state->this_id, sizeof(old_id)))
return; return;
add_vmfork_randomness(state->this_id, sizeof(state->this_id)); add_vmfork_randomness(state->this_id, sizeof(state->this_id));
kobject_uevent_env(&device->dev.kobj, KOBJ_CHANGE, envp);
} }
static const struct acpi_device_id vmgenid_ids[] = { static const struct acpi_device_id vmgenid_ids[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment