Skip to content

Commit 3aa1dc3

Browse files
keesVudentz
authored andcommitted
Bluetooth: btintel: Check dsbr size from EFI variable
Since the size of struct btintel_dsbr is already known, we can just start there instead of querying the EFI variable size. If the final result doesn't match what we expect also fail. This fixes a stack buffer overflow when the EFI variable is larger than struct btintel_dsbr. Reported-by: zepta <z3ptaa@gmail.com> Closes: https://lore.kernel.org/all/CAPBS6KoaWV9=dtjTESZiU6KK__OZX0KpDk-=JEH8jCHFLUYv3Q@mail.gmail.com Fixes: eb9e749 ("Bluetooth: btintel: Allow configuring drive strength of BRI") Signed-off-by: Kees Cook <kees@kernel.org> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 3bb8852 commit 3aa1dc3

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

drivers/bluetooth/btintel.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,7 +2719,7 @@ static int btintel_uefi_get_dsbr(u32 *dsbr_var)
27192719
} __packed data;
27202720

27212721
efi_status_t status;
2722-
unsigned long data_size = 0;
2722+
unsigned long data_size = sizeof(data);
27232723
efi_guid_t guid = EFI_GUID(0xe65d8884, 0xd4af, 0x4b20, 0x8d, 0x03,
27242724
0x77, 0x2e, 0xcc, 0x3d, 0xa5, 0x31);
27252725

@@ -2729,16 +2729,10 @@ static int btintel_uefi_get_dsbr(u32 *dsbr_var)
27292729
if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE))
27302730
return -EOPNOTSUPP;
27312731

2732-
status = efi.get_variable(BTINTEL_EFI_DSBR, &guid, NULL, &data_size,
2733-
NULL);
2734-
2735-
if (status != EFI_BUFFER_TOO_SMALL || !data_size)
2736-
return -EIO;
2737-
27382732
status = efi.get_variable(BTINTEL_EFI_DSBR, &guid, NULL, &data_size,
27392733
&data);
27402734

2741-
if (status != EFI_SUCCESS)
2735+
if (status != EFI_SUCCESS || data_size != sizeof(data))
27422736
return -ENXIO;
27432737

27442738
*dsbr_var = data.dsbr;

0 commit comments

Comments
 (0)