script: Avoid a use-after-free when redefining a function during execution
Defining a new function with the same name as a previously defined function causes the grub_script and associated resources for the previous function to be freed. If the previous function is currently executing when a function with the same name is defined, this results in use-after-frees when processing subsequent commands in the original function. Instead, reject a new function definition if it has the same name as a previously defined function, and that function is currently being executed. Although a behavioural change, this should be backwards compatible with existing configurations because they can't be dependent on the current behaviour without being broken. Fixes: CVE-2020-15706 Signed-off-by: Chris Coulson <chris.coulson@canonical.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
1a8d9c9b4a
commit
426f57383d
4 changed files with 19 additions and 4 deletions
|
@ -838,7 +838,9 @@ grub_script_function_call (grub_script_function_t func, int argc, char **args)
|
|||
old_scope = scope;
|
||||
scope = &new_scope;
|
||||
|
||||
func->executing++;
|
||||
ret = grub_script_execute (func->func);
|
||||
func->executing--;
|
||||
|
||||
function_return = 0;
|
||||
active_loops = loops;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue