From: syzbot <syzbot+1971e47e5210c718db3c@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] Re: [syzbot] [bpf?] KMSAN: uninit-value in htab_lru_percpu_map_lookup_percpu_elem
Date: Thu, 13 Jun 2024 06:59:46 -0700 [thread overview]
Message-ID: <0000000000005cba90061ac5e91a@google.com> (raw)
In-Reply-To: <0000000000008312ad06163b7225@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: Re: [syzbot] [bpf?] KMSAN: uninit-value in htab_lru_percpu_map_lookup_percpu_elem
Author: wojciech.gladysz@infogain.com
#syz test: https://linux.googlesource.com/linux/kernel/git/torvalds/linux e478cf26c556e4ab572ab0ab2306c986901dcd61
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -139,7 +139,7 @@ const struct bpf_func_proto bpf_map_lookup_percpu_elem_proto = {
.pkt_access = true,
.ret_type = RET_PTR_TO_MAP_VALUE_OR_NULL,
.arg1_type = ARG_CONST_MAP_PTR,
- .arg2_type = ARG_PTR_TO_MAP_KEY,
+ .arg2_type = ARG_PTR_TO_MAP_KEY | MEM_RDONLY,
.arg3_type = ARG_ANYTHING,
};
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7146,8 +7146,8 @@ static int check_stack_range_initialized(
* reads. However, if raw_mode is not set, we'll do extra
* checks below.
*/
- bounds_check_type = BPF_WRITE;
- clobber = true;
+ clobber = !meta || meta->raw_mode;
+ bounds_check_type = clobber ? BPF_WRITE : BPF_READ;
} else {
bounds_check_type = BPF_READ;
}
@@ -7230,8 +7230,7 @@ static int check_stack_range_initialized(
stype = &state->stack[spi].slot_type[slot % BPF_REG_SIZE];
if (*stype == STACK_MISC)
goto mark;
- if ((*stype == STACK_ZERO) ||
- (*stype == STACK_INVALID && env->allow_uninit_stack)) {
+ if (*stype == STACK_ZERO) {
if (clobber) {
/* helper can write anything into the stack */
*stype = STACK_MISC;
@@ -8748,6 +8747,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg,
meta->map_uid = reg->map_uid;
break;
case ARG_PTR_TO_MAP_KEY:
+ meta->raw_mode = !(arg_type & MEM_RDONLY); // read only fo const* pointer
/* bpf_map_xxx(..., map_ptr, ..., key) call:
* check that [key, key + map->key_size) are within
* stack limits and initialized
@@ -8763,7 +8763,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg,
}
err = check_helper_mem_access(env, regno,
meta->map_ptr->key_size, false,
- NULL);
+ meta);
break;
case ARG_PTR_TO_MAP_VALUE:
if (type_may_be_null(arg_type) && register_is_null(reg))
--
2.35.3
The information in this email is confidential and may be legally privileged. It is intended solely for the addressee and access to it by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken based on it, is strictly prohibited and may be unlawful.
next prev parent reply other threads:[~2024-06-13 13:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 19:07 [syzbot] [bpf?] KMSAN: uninit-value in htab_lru_percpu_map_lookup_percpu_elem syzbot
2024-06-11 9:50 ` [syzbot] " syzbot
2024-06-11 11:17 ` [syzbot] " syzbot
2024-06-13 11:12 ` syzbot
2024-06-13 13:51 ` syzbot
2024-06-13 13:59 ` syzbot [this message]
2024-06-14 7:55 ` syzbot
2024-06-18 13:05 ` [PATCH] kernel/bpf: enable BPF bytecode call parsing for uninit value Wojciech Gładysz
2024-06-21 3:54 ` Alexei Starovoitov
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=0000000000005cba90061ac5e91a@google.com \
--to=syzbot+1971e47e5210c718db3c@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--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