[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAADnVQJrrWL-YvUqsfJJHzrTYUpnm9HTSJQp8g3Dyor6=doEKQ@mail.gmail.com>
Date: Thu, 8 Jan 2026 13:43:23 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Edward Adam Davis <eadavis@...com>
Cc: 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>, Network Development <netdev@...r.kernel.org>,
Stanislav Fomichev <sdf@...ichev.me>, Song Liu <song@...nel.org>,
syzbot+2c29addf92581b410079@...kaller.appspotmail.com,
syzkaller-bugs <syzkaller-bugs@...glegroups.com>, Yonghong Song <yonghong.song@...ux.dev>
Subject: Re: [PATCH] bpf: Format string can't be empty
On Wed, Jan 7, 2026 at 7:52 PM Edward Adam Davis <eadavis@...com> wrote:
>
> On Wed, 7 Jan 2026 19:02:37 -0800, Alexei Starovoitov <alexei.starovoitov@...il.com> wrote:
> > > diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> > > index db72b96f9c8c..88da2d0e634c 100644
> > > --- a/kernel/bpf/helpers.c
> > > +++ b/kernel/bpf/helpers.c
> > > @@ -827,7 +827,7 @@ int bpf_bprintf_prepare(const char *fmt, u32 fmt_size, const u64 *raw_args,
> > > char fmt_ptype, cur_ip[16], ip_spec[] = "%pXX";
> > >
> > > fmt_end = strnchr(fmt, fmt_size, 0);
> > > - if (!fmt_end)
> > > + if (!fmt_end || fmt_end == fmt)
> > > return -EINVAL;
> >
> > I don't think you root caused it correctly.
> > The better fix and analysis:
> I am keeping my analysis and patch.
> The root cause of the problem is that the format string does not contain
> a null terminator ('\0').
> Filtering out map type 0x22 to solve the problem is too hasty, as it
> would prevent all instructions from calling functions with constant
> string arguments.
If you think it's still possible to construct a program that
passes empty const string into this helper then please craft
a selftest that demonstrates that.
Powered by blists - more mailing lists