exec: move ->recursion_depth out of critical sections
diff mbox series

Message ID 20190417213150.GA26474@avx2
State Accepted
Commit d53ddd0181d1c284c28c0d70a3d7039db41c6f7e
Headers show
Series
  • exec: move ->recursion_depth out of critical sections
Related show

Commit Message

Alexey Dobriyan April 17, 2019, 9:31 p.m. UTC
->recursion_depth is changed only by current, therefore decrementing can be
done without taking any locks.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 fs/exec.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch
diff mbox series

--- a/fs/exec.c
+++ b/fs/exec.c
@@ -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);