Skip to content

Commit

Permalink
fs/exec.c: move ->recursion_depth out of critical sections
Browse files Browse the repository at this point in the history
->recursion_depth is changed only by current, therefore decrementing can
be done without taking any locks.

Link: http://lkml.kernel.org/r/20190417213150.GA26474@avx2
Signed-off-by: Alexey Dobriyan <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alexey Dobriyan authored and torvalds committed May 15, 2019
1 parent b028fb6 commit d53ddd0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1652,11 +1652,13 @@ int search_binary_handler(struct linux_binprm *bprm)
if (!try_module_get(fmt->module))
continue;
read_unlock(&binfmt_lock);

bprm->recursion_depth++;
retval = fmt->load_binary(bprm);
bprm->recursion_depth--;

read_lock(&binfmt_lock);
put_binfmt(fmt);
bprm->recursion_depth--;
if (retval < 0 && !bprm->mm) {
/* we got to flush_old_exec() and failed after it */
read_unlock(&binfmt_lock);
Expand Down

0 comments on commit d53ddd0

Please sign in to comment.