* [PATCH] bpf: fix missing checks of the return value of check_reg_arg
@ 2018-12-25 7:17 Kangjie Lu
2018-12-25 7:25 ` Alexei Starovoitov
0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2018-12-25 7:17 UTC (permalink / raw)
To: kjlu; +Cc: pakki001, Alexei Starovoitov, Daniel Borkmann, netdev, linux-kernel
check_reg_arg() may fail. This fix inserts checks for its return value.
If check_reg_arg() fails, issues an error message.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
kernel/bpf/verifier.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 51ba84d4d34a..fde91a5c0b5a 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2619,7 +2619,10 @@ static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
/* after the call registers r0 - r5 were scratched */
for (i = 0; i < CALLER_SAVED_REGS; i++) {
mark_reg_not_init(env, caller->regs, caller_saved[i]);
- check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+ err = check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+ if (err)
+ verbose(env,
+ "check_reg_arg() fails in setting caller saved regs\n");
}
/* only increment it after check_reg_arg() finished */
@@ -2842,7 +2845,10 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn
/* reset caller saved regs */
for (i = 0; i < CALLER_SAVED_REGS; i++) {
mark_reg_not_init(env, regs, caller_saved[i]);
- check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+ err = check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+ if (err)
+ verbose(env,
+ "check_reg_arg() fails in resetting caller saved regs\n");
}
/* update return register (already marked as written above) */
@@ -4435,7 +4441,10 @@ static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)
/* reset caller saved regs to unreadable */
for (i = 0; i < CALLER_SAVED_REGS; i++) {
mark_reg_not_init(env, regs, caller_saved[i]);
- check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+ err = check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
+ if (err)
+ verbose(env,
+ "check_reg_arg() fails in resetting caller saved regs to unreadable\n");
}
/* mark destination R0 register as readable, since it contains
--
2.17.2 (Apple Git-113)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bpf: fix missing checks of the return value of check_reg_arg
2018-12-25 7:17 [PATCH] bpf: fix missing checks of the return value of check_reg_arg Kangjie Lu
@ 2018-12-25 7:25 ` Alexei Starovoitov
0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2018-12-25 7:25 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, Alexei Starovoitov, Daniel Borkmann, netdev, linux-kernel
On Tue, Dec 25, 2018 at 01:17:10AM -0600, Kangjie Lu wrote:
> check_reg_arg() may fail. This fix inserts checks for its return value.
> If check_reg_arg() fails, issues an error message.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> kernel/bpf/verifier.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 51ba84d4d34a..fde91a5c0b5a 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -2619,7 +2619,10 @@ static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
> /* after the call registers r0 - r5 were scratched */
> for (i = 0; i < CALLER_SAVED_REGS; i++) {
> mark_reg_not_init(env, caller->regs, caller_saved[i]);
> - check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
> + err = check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK);
> + if (err)
> + verbose(env,
> + "check_reg_arg() fails in setting caller saved regs\n");
Such patch was already posted.
These calls cannot fail.
I prefer to leave them as-is.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-25 7:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-25 7:17 [PATCH] bpf: fix missing checks of the return value of check_reg_arg Kangjie Lu
2018-12-25 7:25 ` Alexei Starovoitov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).