lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4Bza6-Unvr7QmcbvVtNDPc4BNzf8zMaU4XardNqB_GnGDHw@mail.gmail.com>
Date:   Wed, 21 Apr 2021 20:32:12 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Rasmus Villemoes <linux@...musvillemoes.dk>
Cc:     Daniel Borkmann <daniel@...earbox.net>,
        Alan Maguire <alan.maguire@...cle.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        bpf <bpf@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] bpf: remove pointless code from bpf_do_trace_printk()

On Wed, Apr 21, 2021 at 6:19 PM Rasmus Villemoes
<linux@...musvillemoes.dk> wrote:
>
> The comment is wrong. snprintf(buf, 16, "") and snprintf(buf, 16,
> "%s", "") etc. will certainly put '\0' in buf[0]. The only case where
> snprintf() does not guarantee a nul-terminated string is when it is
> given a buffer size of 0 (which of course prevents it from writing
> anything at all to the buffer).
>
> Remove it before it gets cargo-culted elsewhere.
>
> Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
> ---
>  kernel/trace/bpf_trace.c | 3 ---
>  1 file changed, 3 deletions(-)
>

The change looks good to me, but please rebase it on top of the
bpf-next tree. This is not a bug, so it doesn't have to go into the
bpf tree. As it is right now, it doesn't apply cleanly onto bpf-next.


> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index b0c45d923f0f..4ee55df84cd3 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -412,9 +412,6 @@ static __printf(1, 0) int bpf_do_trace_printk(const char *fmt, ...)
>         va_start(ap, fmt);
>         ret = vsnprintf(buf, sizeof(buf), fmt, ap);
>         va_end(ap);
> -       /* vsnprintf() will not append null for zero-length strings */
> -       if (ret == 0)
> -               buf[0] = '\0';
>         trace_bpf_trace_printk(buf);
>         raw_spin_unlock_irqrestore(&trace_printk_lock, flags);
>
> --
> 2.29.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ