From ff380936e098eecd03a8066722527989dcb5e27f Mon Sep 17 00:00:00 2001 From: Xindong Xu Date: Thu, 14 Oct 2021 10:12:40 +0800 Subject: fastboot: add secure & lock check for fastboot cmd [1/1] BUG:202994010 Problem: fastboot unlock & oem cmd maybe unsafe Solution: 1. check lock state before fastboot cmds such as oem; Verify: adt3 Change-Id: Iefd67d45ba826ab4f9704643ca3afc2ba71ebc8a Signed-off-by: Xindong Xu --- drivers/usb/gadget/f_fastboot.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 4664911878..ae881deff8 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -1086,6 +1086,12 @@ static void cb_download(struct usb_ep *ep, struct usb_request *req) printf("cmd cb_download is %s\n", cmd); + if (check_lock()) { + error("device is locked, can not run this cmd.Please flashing unlock & flashing unlock_critical\n"); + fastboot_tx_write_str("FAILlocked device"); + return; + } + strsep(&cmd, ":"); download_size = simple_strtoul(cmd, NULL, 16); download_bytes = 0; @@ -1154,6 +1160,11 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req) static void cb_boot(struct usb_ep *ep, struct usb_request *req) { + if (check_lock()) { + error("device is locked, can not run this cmd.Please flashing unlock & flashing unlock_critical\n"); + fastboot_tx_write_str("FAILlocked device"); + return; + } fastboot_func->in_req->complete = do_bootm_on_complete; fastboot_tx_write_str("OKAY"); } @@ -1553,6 +1564,12 @@ static void cb_oem_cmd(struct usb_ep *ep, struct usb_request *req) char cmd_str[RESPONSE_LEN]; printf("oem cmd[%s]\n", cmd); + if (check_lock()) { + error("device is locked, can not run this cmd.Please flashing unlock & flashing unlock_critical\n"); + fastboot_tx_write_str("FAILlocked device"); + return; + } + strsep(&cmd, " "); printf("To run cmd[%s]\n", cmd); -- cgit v1.2.3