bpf: Comment on check_mem_size_reg
authorAndrei Matei <andreimatei1@gmail.com>
Sun, 10 Dec 2023 22:51:50 +0000 (17:51 -0500)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 12 Dec 2023 23:35:32 +0000 (15:35 -0800)
This patch adds a comment to check_mem_size_reg -- a function whose
meaning is not very transparent. The function implicitly deals with two
registers connected by convention, which is not obvious.

Signed-off-by: Andrei Matei <andreimatei1@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20231210225149.67639-1-andreimatei1@gmail.com
kernel/bpf/verifier.c

index ef27820a24e36ec2a259f27339c21d4bec8a89e4..1863826a4ac38951751d1a0d0b24707ab709b85a 100644 (file)
@@ -7256,6 +7256,12 @@ static int check_helper_mem_access(struct bpf_verifier_env *env, int regno,
        }
 }
 
+/* verify arguments to helpers or kfuncs consisting of a pointer and an access
+ * size.
+ *
+ * @regno is the register containing the access size. regno-1 is the register
+ * containing the pointer.
+ */
 static int check_mem_size_reg(struct bpf_verifier_env *env,
                              struct bpf_reg_state *reg, u32 regno,
                              bool zero_size_allowed,