[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQ+SkF2jL6NZLTF7ZKwNOfOtpMqr0ubjXpF1K0+EkHdJHw@mail.gmail.com>
Date: Wed, 24 Sep 2025 09:32:25 +0200
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Brahmajit Das <listout@...tout.xyz>
Cc: syzbot+d36d5ae81e1b0a53ef58@...kaller.appspotmail.com,
Andrii Nakryiko <andrii@...nel.org>, Alexei Starovoitov <ast@...nel.org>, bpf <bpf@...r.kernel.org>,
Daniel Borkmann <daniel@...earbox.net>, Eduard <eddyz87@...il.com>, Hao Luo <haoluo@...gle.com>,
John Fastabend <john.fastabend@...il.com>, Jiri Olsa <jolsa@...nel.org>,
KP Singh <kpsingh@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, Stanislav Fomichev <sdf@...ichev.me>, Song Liu <song@...nel.org>,
syzkaller-bugs <syzkaller-bugs@...glegroups.com>, Yonghong Song <yonghong.song@...ux.dev>
Subject: Re: [PATCH v2] bpf: fix NULL pointer dereference in print_reg_state()
On Wed, Sep 24, 2025 at 1:43 AM Brahmajit Das <listout@...tout.xyz> wrote:
>
> Syzkaller reported a general protection fault due to a NULL pointer
> dereference in print_reg_state() when accessing reg->map_ptr without
> checking if it is NULL.
>
> The existing code assumes reg->map_ptr is always valid before
> dereferencing reg->map_ptr->name, reg->map_ptr->key_size, and
> reg->map_ptr->value_size.
>
> Fix this by adding explicit NULL checks before accessing reg->map_ptr
> and its members. This prevents crashes when reg->map_ptr is NULL,
> improving the robustness of the BPF verifier's verbose logging.
>
> Reported-by: syzbot+d36d5ae81e1b0a53ef58@...kaller.appspotmail.com
> Signed-off-by: Brahmajit Das <listout@...tout.xyz>
> ---
> kernel/bpf/log.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/log.c b/kernel/bpf/log.c
> index f50533169cc3..5ffb8d778b92 100644
> --- a/kernel/bpf/log.c
> +++ b/kernel/bpf/log.c
> @@ -704,7 +704,7 @@ static void print_reg_state(struct bpf_verifier_env *env,
> verbose_a("ref_obj_id=%d", reg->ref_obj_id);
> if (type_is_non_owning_ref(reg->type))
> verbose_a("%s", "non_own_ref");
> - if (type_is_map_ptr(t)) {
> + if (type_is_map_ptr(t) && reg->map_ptr) {
You ignored earlier feedback.
Fix the root cause, not the symptom.
pw-bot: cr
Powered by blists - more mailing lists