detachables: Ensure keyboard input in TO_DEV menu trusted
Add in check at TO_DEV menu screen to make sure that the navigation
keys (up/down, volup/voldown) are trusted. Beep when user tries to
use unstrusted keys (usb keyboard) in the TO_DEV menu so that the user
knows they're doing something wrong. USB keyboard return key will
still work in the TO_DEV menu.
BUG=b:65546569
BRANCH=None
TEST=test out using up/down keys in TO_DEV menu and make sure that
they are disabled and hear beeps.
Change-Id: Ifc7183c7ca35efaf079abb196a90ab7305380642
Signed-off-by: Shelley Chen <shchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/665355
Reviewed-by: Julius Werner <jwerner@chromium.org>
diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c
index 8ca7a9f..84ced16 100644
--- a/firmware/lib/vboot_ui_menu.c
+++ b/firmware/lib/vboot_ui_menu.c
@@ -1022,6 +1022,7 @@
(VbSharedDataHeader *)cparams->shared_data_blob;
uint32_t retval;
uint32_t key;
+ uint32_t key_flags;
int i;
VbError_t ret;
@@ -1104,15 +1105,27 @@
* platforms don't like to scan USB too rapidly.
*/
for (i = 0; i < REC_DISK_DELAY; i += REC_KEY_DELAY) {
- key = VbExKeyboardRead();
+ key = VbExKeyboardReadWithFlags(&key_flags);
switch (key) {
case 0:
/* nothing pressed */
break;
- case VB_BUTTON_VOL_UP:
- case VB_BUTTON_VOL_DOWN:
case VB_KEY_UP:
case VB_KEY_DOWN:
+ case VB_BUTTON_VOL_UP:
+ case VB_BUTTON_VOL_DOWN:
+ /* User cannot use keyboard to enable dev mode.
+ * They need to use the volume buttons from a
+ * trusted source to navigate to the disable os
+ * verification menu item. Beep so user knows
+ * that they're doing something wrong.
+ */
+ if (current_menu == VB_MENU_TO_DEV &&
+ !(key_flags & VB_KEY_FLAG_TRUSTED_KEYBOARD)) {
+ VbExBeep(120, 400);
+ break;
+ }
+
if (current_menu == VB_MENU_RECOVERY_INSERT) {
ret = vb2_update_menu(ctx);
vb2_set_disabled_idx_mask(shared->flags);