Commit ede85e90 authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'efi-urgent' of...

Merge tag 'efi-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi into efi/urgent

Pull EFI fix from Matt Fleming:

 * Avoid out-of-bounds access in the efivars code when performing
   string matching on converted EFI variable names (Laszlo Ersek)
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 02da2d72 630ba0cc
...@@ -202,29 +202,44 @@ static const struct variable_validate variable_validate[] = { ...@@ -202,29 +202,44 @@ static const struct variable_validate variable_validate[] = {
{ NULL_GUID, "", NULL }, { NULL_GUID, "", NULL },
}; };
/*
* Check if @var_name matches the pattern given in @match_name.
*
* @var_name: an array of @len non-NUL characters.
* @match_name: a NUL-terminated pattern string, optionally ending in "*". A
* final "*" character matches any trailing characters @var_name,
* including the case when there are none left in @var_name.
* @match: on output, the number of non-wildcard characters in @match_name
* that @var_name matches, regardless of the return value.
* @return: whether @var_name fully matches @match_name.
*/
static bool static bool
variable_matches(const char *var_name, size_t len, const char *match_name, variable_matches(const char *var_name, size_t len, const char *match_name,
int *match) int *match)
{ {
for (*match = 0; ; (*match)++) { for (*match = 0; ; (*match)++) {
char c = match_name[*match]; char c = match_name[*match];
char u = var_name[*match];
/* Wildcard in the matching name means we've matched */ switch (c) {
if (c == '*') case '*':
/* Wildcard in @match_name means we've matched. */
return true; return true;
/* Case sensitive match */ case '\0':
if (!c && *match == len) /* @match_name has ended. Has @var_name too? */
return true; return (*match == len);
if (c != u) default:
/*
* We've reached a non-wildcard char in @match_name.
* Continue only if there's an identical character in
* @var_name.
*/
if (*match < len && c == var_name[*match])
continue;
return false; return false;
}
if (!c)
return true;
} }
return true;
} }
bool bool
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment