OSDN Git Service

bpf: verifier: reorder stack size check with dead code sanitization
authorJakub Kicinski <jakub.kicinski@netronome.com>
Thu, 20 Dec 2018 06:13:06 +0000 (22:13 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 20 Dec 2018 16:28:28 +0000 (17:28 +0100)
Reorder the calls to check_max_stack_depth() and sanitize_dead_code()
to separate functions which can rewrite instructions from pure checks.

No functional changes.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/verifier.c

index 98ed27b..d27d5a8 100644 (file)
@@ -6983,10 +6983,11 @@ skip_full_check:
        free_states(env);
 
        if (ret == 0)
-               sanitize_dead_code(env);
+               ret = check_max_stack_depth(env);
 
+       /* instruction rewrites happen after this point */
        if (ret == 0)
-               ret = check_max_stack_depth(env);
+               sanitize_dead_code(env);
 
        if (ret == 0)
                /* program is valid, convert *(u32*)(ctx + off) accesses */