From abef8dd8f43989cdf73bfc20d9cb3f8f839c9a82 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Thu, 2 Feb 2017 20:08:50 -0800 Subject: g: allow idle console command in read-only mode in prod images Being able to determine what sleep state the system is in is very handy, and reading the state is pretty safe. Let's declare the idle console command safe and disallow its parameters when console is locked. BRANCH=none BUG=none TEST=verified that it is possible to read the idle state when console is locked, but not possible to set it. Change-Id: I97f680bf033290220a4fa7fd5a7af170736443d8 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/436905 Reviewed-by: Mary Ruthven --- chip/g/idle.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'chip') diff --git a/chip/g/idle.c b/chip/g/idle.c index 0d4656a8c6..1d365dd06c 100644 --- a/chip/g/idle.c +++ b/chip/g/idle.c @@ -44,6 +44,10 @@ static int command_idle(int argc, char **argv) int c, i; if (argc > 1) { + if (console_is_restricted()) { + ccprintf("Console is locked, no parameters allowed\n"); + return EC_ERROR_INVAL; + } c = tolower(argv[1][0]); for (i = 1; i < ARRAY_SIZE(idle_name); i++) if (idle_name[i][0] == c) { @@ -56,9 +60,9 @@ static int command_idle(int argc, char **argv) return EC_SUCCESS; } -DECLARE_CONSOLE_COMMAND(idle, command_idle, - "[w|s|d]", - "Set or show the idle action: wfi, sleep, deep sleep"); +DECLARE_SAFE_CONSOLE_COMMAND(idle, command_idle, + "[w|s|d]", + "Set or show the idle action: wfi, sleep, deep sleep"); static int utmi_wakeup_is_enabled(void) { -- cgit v1.2.1