diff options
author | Patryk Duda <pdk@semihalf.com> | 2021-09-01 11:38:53 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-07 19:40:53 +0000 |
commit | 968b86d63a578e72c2c9de8e6f5d2acb27cce9fa (patch) | |
tree | ae1249a707a23e5fc79daf6c99d455d251058cbe /common | |
parent | bdb805bc222ae41a762bc5dbf6ac281fd0a00047 (diff) | |
download | chrome-ec-968b86d63a578e72c2c9de8e6f5d2acb27cce9fa.tar.gz |
fpsensor: Propagate no match auth code when finger outside range
When fp_finger_match() function returns code which indicates that
match failed it also sets number of matched template to -1.
Until now, in fp_process_match() we set internal error code when
finger number was invalid (fgr variable was set to -1). This resulted
in overwriting MATCH_NO, MATCH_LOW_QUALITY, MATCH_LOW_COVERAGE with
MATCH_NO_INTERNAL error code when match failed. As a result, biod was
receiving only internal errors always when match failed.
Now we overwrite error code with internal error only when
fp_finger_match() returns negative value or when it returns success,
but finger template number is outside range. In other cases we pass
unchanged error code to biod.
BUG=b:184843581
BRANCH=none
TEST=Flash FPMCU firmware on Chromebook. Reboot Chromebook, make sure
your firmware is running. Cover up part of sensor with paper and
try to unlock device. Compare biod and cros_fp logs, make sure
that biod reports the same reason on failed attempts.
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: I64e6cb2850c0bf4700482c35899f23b8102a480b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3135425
Tested-by: Patryk Duda <patrykd@google.com>
Commit-Queue: Patryk Duda <patrykd@google.com>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/fpsensor/fpsensor.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/common/fpsensor/fpsensor.c b/common/fpsensor/fpsensor.c index 08a456dc0e..25010c7db8 100644 --- a/common/fpsensor/fpsensor.c +++ b/common/fpsensor/fpsensor.c @@ -132,6 +132,17 @@ static uint32_t fp_process_enroll(void) | (percent << EC_MKBP_FP_ENROLL_PROGRESS_OFFSET); } +static bool fp_match_success(int match_result) +{ + if (match_result == EC_MKBP_FP_ERR_MATCH_YES || + match_result == EC_MKBP_FP_ERR_MATCH_YES_UPDATED || + match_result == EC_MKBP_FP_ERR_MATCH_YES_UPDATE_FAILED) { + return true; + } + + return false; +} + static uint32_t fp_process_match(void) { timestamp_t t0 = get_time(); @@ -146,20 +157,39 @@ static uint32_t fp_process_match(void) res = fp_finger_match(fp_template[0], templ_valid, fp_buffer, &fgr, &updated); CPRINTS("Match =>%d (finger %d)", res, fgr); - if (res < 0 || fgr < 0 || fgr >= FP_MAX_FINGER_COUNT) { + + if (fp_match_success(res)) { + /* + * Match succeded! Let's check if template number + * is valid. If it is not valid, overwrite result + * with EC_MKBP_FP_ERR_MATCH_NO_INTERNAL. + */ + if (fgr >= 0 && fgr < FP_MAX_FINGER_COUNT) { + fp_enable_positive_match_secret(fgr, + &positive_match_secret_state); + } else { + res = EC_MKBP_FP_ERR_MATCH_NO_INTERNAL; + } + } else if (res < 0) { + /* + * Negative result means that there is a problem with + * code responsible for matching. Overwrite it with + * MATCH_NO_INTERNAL to let upper layers know what + * happened. + */ res = EC_MKBP_FP_ERR_MATCH_NO_INTERNAL; - timestamps_invalid |= FPSTATS_MATCHING_INV; - } else { - fp_enable_positive_match_secret(fgr, - &positive_match_secret_state); } + if (res == EC_MKBP_FP_ERR_MATCH_YES_UPDATED) templ_dirty |= updated; } else { CPRINTS("No enrolled templates"); res = EC_MKBP_FP_ERR_MATCH_NO_TEMPLATES; - timestamps_invalid |= FPSTATS_MATCHING_INV; } + + if (!fp_match_success(res)) + timestamps_invalid |= FPSTATS_MATCHING_INV; + matching_time_us = time_since32(t0); return EC_MKBP_FP_MATCH | EC_MKBP_FP_ERRCODE(res) | ((fgr << EC_MKBP_FP_MATCH_IDX_OFFSET) & EC_MKBP_FP_MATCH_IDX_MASK); |