From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+33f4297b5f927648741a@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [bpf?] UBSAN: array-index-out-of-bounds in check_stack_range_initialized
Date: Fri, 22 Mar 2024 08:11:05 +0800 [thread overview]
Message-ID: <tencent_57A1EED82EC60C94E7EDC6DA12C306474906@qq.com> (raw)
In-Reply-To: <0000000000003dc8e00614076ab6@google.com>
please test oob in check_stack_range_initialized
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git master
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 1dd3b99d1bb9..80b9ae2b90bb 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7177,6 +7177,11 @@ static int check_stack_range_initialized(
return 0;
}
+ if (INT_MIN - access_size > max_off) {
+ verbose(env, "invalid access size\n");
+ return -EACCES;
+ }
+
for (i = min_off; i < max_off + access_size; i++) {
u8 *stype;
@@ -8589,6 +8594,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg,
return 0;
}
+ printk("1meta:%p, maptr:%p, ks:%d, kv:%d,%s\n",
+ meta, meta->map_ptr, meta->map_ptr->key_size, meta->map_ptr->value_size, __func__);
if (type_is_pkt_pointer(type) &&
!may_access_direct_pkt_data(env, meta, BPF_READ)) {
verbose(env, "helper access to the packet is not allowed\n");
@@ -8704,6 +8711,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg,
verbose(env, "invalid map_ptr to access map->key\n");
return -EACCES;
}
+ printk("meta:%p, maptr:%p, ks:%d, reg->map_ptr:%p, %s\n",
+ meta, meta->map_ptr, meta->map_ptr->key_size, reg->map_ptr, __func__);
err = check_helper_mem_access(env, regno,
meta->map_ptr->key_size, false,
NULL);
@@ -8721,6 +8730,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg,
return -EACCES;
}
meta->raw_mode = arg_type & MEM_UNINIT;
+ printk("meta:%p, maptr:%p, vs:%d, reg->map_ptr:%p, %s\n",
+ meta, meta->map_ptr, meta->map_ptr->value_size, reg->map_ptr, __func__);
err = check_helper_mem_access(env, regno,
meta->map_ptr->value_size, false,
meta);
@@ -10248,6 +10259,8 @@ static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn
meta.func_id = func_id;
/* check args */
+ printk("meta:%p, maptr:%p, %s\n",
+ &meta, meta.map_ptr, __func__);
for (i = 0; i < MAX_BPF_FUNC_REG_ARGS; i++) {
err = check_func_arg(env, i, &meta, fn, insn_idx);
if (err)
next prev parent reply other threads:[~2024-03-22 0:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-19 18:12 syzbot
2024-03-20 0:33 ` Edward Adam Davis
2024-03-20 8:02 ` syzbot
2024-03-20 9:40 ` Edward Adam Davis
2024-03-20 10:09 ` syzbot
2024-03-20 11:17 ` Edward Adam Davis
2024-03-20 19:53 ` syzbot
2024-03-20 23:52 ` Edward Adam Davis
2024-03-21 14:39 ` syzbot
2024-03-21 7:33 ` stack access issue. " Alexei Starovoitov
2024-03-21 14:07 ` Andrei Matei
2024-03-24 0:50 ` Andrei Matei
2024-03-24 0:52 ` Alexei Starovoitov
2024-03-24 2:12 ` Andrei Matei
2024-03-24 2:55 ` Alexei Starovoitov
2024-03-26 2:48 ` Andrei Matei
2024-03-22 0:11 ` Edward Adam Davis [this message]
2024-03-22 10:42 ` syzbot
2024-03-23 4:42 ` Edward Adam Davis
2024-03-23 9:08 ` syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_57A1EED82EC60C94E7EDC6DA12C306474906@qq.com \
--to=eadavis@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+33f4297b5f927648741a@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®