[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACdoK4LhwrGqYHrOV6a42wHkX1=jqMWVhFa-b3QZ8P=1kMxcSw@mail.gmail.com>
Date: Mon, 14 Nov 2022 20:53:20 +0000
From: Quentin Monnet <quentin@...valent.com>
To: sdf@...gle.com
Cc: Tiezhu Yang <yangtiezhu@...ngson.cn>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next 2/2] bpftool: Check argc first before "file" in do_batch()
On Mon, 14 Nov 2022 at 17:30, <sdf@...gle.com> wrote:
>
> On 11/14, Tiezhu Yang wrote:
> > If the parameters for batch are more than 2, check argc first can
> > return immediately, no need to use strcmp() to check "file" with
> > a little overhead and then check argc, it is better to check "file"
> > only when the parameters for batch are 2.
Thanks for the patch
> Seems fine if you respin with is_prefix instead of strcmp.
> Has the potential of breaking some buggy users which pass
> more than one file, but I don't think it's a good justification
> no to do the fix? Quentin?
I don't think it could break, the argc check is already enforced
(currently after the check on "file") and no more than one batch file
can be passed. I'm not sure it's super useful to swap the checks
either, because you can similarly argue that there's no need to check
argc is <= 2 if the first arg for "bpftool batch" is different from
"file" (or a prefix). The argc check is faster than the is_prefix()
comparison, but that's a minor optimization for one specific error
case. I don't really see the point, but I'm not opposed to the patch
either if you repost with is_prefix() as suggested by Stanislav.
Powered by blists - more mailing lists