summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxypron.glpk@gmx.de <xypron.glpk@gmx.de>2017-07-11 22:06:15 +0200
committerAlexander Graf <agraf@suse.de>2017-07-19 14:14:38 +0200
commit69baec67816bd2b3d491134f4509707e89054d48 (patch)
treecc9bfa7ecc968182198f7be8dbdb99e38118db29
parentb5349f742a7684aabd3fb8f0e20c67ba033deec7 (diff)
efi_loader: efi_open_protocol: parameter checks
Add all parameter checks for function efi_open_protocol that do not depend on a locking table. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r--lib/efi_loader/efi_boottime.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 5c72f92474..22e9e6001d 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -718,15 +718,35 @@ static efi_status_t EFIAPI efi_open_protocol(
{
struct list_head *lhandle;
int i;
- efi_status_t r = EFI_UNSUPPORTED;
+ efi_status_t r = EFI_INVALID_PARAMETER;
EFI_ENTRY("%p, %p, %p, %p, %p, 0x%x", handle, protocol,
protocol_interface, agent_handle, controller_handle,
attributes);
- if (!protocol_interface && attributes !=
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
- r = EFI_INVALID_PARAMETER;
+ if (!handle || !protocol ||
+ (!protocol_interface && attributes !=
+ EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) {
+ goto out;
+ }
+
+ switch (attributes) {
+ case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL:
+ case EFI_OPEN_PROTOCOL_GET_PROTOCOL:
+ case EFI_OPEN_PROTOCOL_TEST_PROTOCOL:
+ break;
+ case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER:
+ if (controller_handle == handle)
+ goto out;
+ case EFI_OPEN_PROTOCOL_BY_DRIVER:
+ case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE:
+ if (controller_handle == NULL)
+ goto out;
+ case EFI_OPEN_PROTOCOL_EXCLUSIVE:
+ if (agent_handle == NULL)
+ goto out;
+ break;
+ default:
goto out;
}
@@ -752,8 +772,11 @@ static efi_status_t EFIAPI efi_open_protocol(
goto out;
}
}
+ goto unsupported;
}
+unsupported:
+ r = EFI_UNSUPPORTED;
out:
return EFI_EXIT(r);
}