mbox series

[iproute2,0/2] Fix segfault in lib/bpf.c

Message ID cover.1590508215.git.aclaudi@redhat.com
Headers show
Series Fix segfault in lib/bpf.c | expand

Message

Andrea Claudi May 26, 2020, 4:04 p.m. UTC
Jamal reported a segfault in bpf_make_custom_path() when custom pinning is
used. This is caused by commit c0325b06382cb ("bpf: replace snprintf with
asprintf when dealing with long buffers").

As the only goal of that commit is to get rid of a truncation warning when
compiling lib/bpf.c, revert it and fix the warning checking for snprintf
return value

Andrea Claudi (2):
  Revert "bpf: replace snprintf with asprintf when dealing with long
    buffers"
  bpf: Fixes a snprintf truncation warning

 lib/bpf.c | 155 +++++++++++++++---------------------------------------
 1 file changed, 41 insertions(+), 114 deletions(-)

Comments

Daniel Borkmann May 26, 2020, 9:27 p.m. UTC | #1
On 5/26/20 6:04 PM, Andrea Claudi wrote:
> Jamal reported a segfault in bpf_make_custom_path() when custom pinning is
> used. This is caused by commit c0325b06382cb ("bpf: replace snprintf with
> asprintf when dealing with long buffers").
> 
> As the only goal of that commit is to get rid of a truncation warning when
> compiling lib/bpf.c, revert it and fix the warning checking for snprintf
> return value
> 
> Andrea Claudi (2):
>    Revert "bpf: replace snprintf with asprintf when dealing with long
>      buffers"
>    bpf: Fixes a snprintf truncation warning
> 
>   lib/bpf.c | 155 +++++++++++++++---------------------------------------
>   1 file changed, 41 insertions(+), 114 deletions(-)
> 

Thanks for following up, Andrea! For the two:

Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Stephen Hemminger May 27, 2020, 10:13 p.m. UTC | #2
On Tue, 26 May 2020 18:04:09 +0200
Andrea Claudi <aclaudi@redhat.com> wrote:

> Jamal reported a segfault in bpf_make_custom_path() when custom pinning is
> used. This is caused by commit c0325b06382cb ("bpf: replace snprintf with
> asprintf when dealing with long buffers").
> 
> As the only goal of that commit is to get rid of a truncation warning when
> compiling lib/bpf.c, revert it and fix the warning checking for snprintf
> return value
> 
> Andrea Claudi (2):
>   Revert "bpf: replace snprintf with asprintf when dealing with long
>     buffers"
>   bpf: Fixes a snprintf truncation warning
> 
>  lib/bpf.c | 155 +++++++++++++++---------------------------------------
>  1 file changed, 41 insertions(+), 114 deletions(-)
> 

ok merged
Jamal Hadi Salim May 28, 2020, 11:14 a.m. UTC | #3
On 2020-05-27 6:13 p.m., Stephen Hemminger wrote:
> On Tue, 26 May 2020 18:04:09 +0200
> Andrea Claudi <aclaudi@redhat.com> wrote:
> 
>> Jamal reported a segfault in bpf_make_custom_path() when custom pinning is
>> used. This is caused by commit c0325b06382cb ("bpf: replace snprintf with
>> asprintf when dealing with long buffers").
>>
>> As the only goal of that commit is to get rid of a truncation warning when
>> compiling lib/bpf.c, revert it and fix the warning checking for snprintf
>> return value
>>
>> Andrea Claudi (2):
>>    Revert "bpf: replace snprintf with asprintf when dealing with long
>>      buffers"
>>    bpf: Fixes a snprintf truncation warning
>>
>>   lib/bpf.c | 155 +++++++++++++++---------------------------------------
>>   1 file changed, 41 insertions(+), 114 deletions(-)
>>
> 
> ok merged
> 

FWIW, it may be useful to grep the tree and check for
s[n]printf() return code.
It seems like modern compilers are good enough at catching
overruns but maybe useful to enforce a coding style consistency
given that most people doit the LinuxWay (cutnpaste existing
code to fix a bug or add a feature).

cheers,
jamal