efi_loader: check CreateEvent() parameters
authorJonathan Gray <jsg@jsg.id.au>
Sun, 12 Mar 2017 08:26:07 +0000 (19:26 +1100)
committerAlexander Graf <agraf@suse.de>
Mon, 3 Jul 2017 11:54:48 +0000 (13:54 +0200)
Add some of the invalid parameter checks described in the UEFI
specification for CreateEvent().  This does not include checking
the validity of the type and tpl parameters.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Acked-By: Heinrich Schuchardt <xypron.glpk@gmx.de>
[agraf: fix checkpatch.pl indent warning]
Signed-off-by: Alexander Graf <agraf@suse.de>
lib/efi_loader/efi_boottime.c

index eb5946a95946f6f86cfcec90c30cbd0762b02a18..44bcbb1455920d4a937b99b7b3189a46ed95e485 100644 (file)
@@ -189,6 +189,16 @@ static efi_status_t EFIAPI efi_create_event(
                return EFI_EXIT(EFI_OUT_OF_RESOURCES);
        }
 
+       if (event == NULL)
+               return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+       if ((type & EVT_NOTIFY_SIGNAL) && (type & EVT_NOTIFY_WAIT))
+               return EFI_EXIT(EFI_INVALID_PARAMETER);
+
+       if ((type & (EVT_NOTIFY_SIGNAL|EVT_NOTIFY_WAIT)) &&
+           notify_function == NULL)
+               return EFI_EXIT(EFI_INVALID_PARAMETER);
+
        efi_event.type = type;
        efi_event.notify_tpl = notify_tpl;
        efi_event.notify_function = notify_function;