All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Shawn Landden <slandden@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Wang Nan <wangnan0@huawei.com>
Subject: Re: [PATCH 05/44] perf data: Fix 'strncat may truncate' build failure with recent gcc
Date: Tue, 28 May 2019 14:39:41 -0300	[thread overview]
Message-ID: <20190528173941.GC2935@redhat.com> (raw)
In-Reply-To: <CA+49okqAuPrs679GWQhxjyMn4mMhVSH_71Ww6rBbUjsrm2g-dg@mail.gmail.com>

Em Tue, May 28, 2019 at 11:59:10AM -0500, Shawn Landden escreveu:
> On Tue, May 28, 2019 at 8:04 AM Arnaldo Carvalho de Melo
> <arnaldo.melo@gmail.com> wrote:
> >
> > Em Mon, May 27, 2019 at 05:46:26PM -0500, Shawn Landden escreveu:
> > > On Mon, May 27, 2019 at 5:38 PM Arnaldo Carvalho de Melo
> > > <acme@kernel.org> wrote:
> > > >
> > > > From: Shawn Landden <shawn@git.icu>
> > > >
> > > > This strncat() is safe because the buffer was allocated with zalloc(),
> > > > however gcc doesn't know that. Since the string always has 4 non-null
> > > > bytes, just use memcpy() here.
> > > >
> > > >     CC       /home/shawn/linux/tools/perf/util/data-convert-bt.o
> > > >   In file included from /usr/include/string.h:494,
> > > >                    from /home/shawn/linux/tools/lib/traceevent/event-parse.h:27,
> > > >                    from util/data-convert-bt.c:22:
> > > >   In function ‘strncat’,
> > > >       inlined from ‘string_set_value’ at util/data-convert-bt.c:274:4:
> > > >   /usr/include/powerpc64le-linux-gnu/bits/string_fortified.h:136:10: error: ‘__builtin_strncat’ output may be truncated copying 4 bytes from a string of length 4 [-Werror=stringop-truncation]
> > > >     136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
> > > >         |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > >
> > > > Signed-off-by: Shawn Landden <shawn@git.icu>
> > > > Cc: Adrian Hunter <adrian.hunter@intel.com>
> > > > Cc: Jiri Olsa <jolsa@redhat.com>
> > > > Cc: Namhyung Kim <namhyung@kernel.org>
> > > > Cc: Wang Nan <wangnan0@huawei.com>
> > > > LPU-Reference: 20190518183238.10954-1-shawn@git.icu
> > > > Link: https://lkml.kernel.org/n/tip-289f1jice17ta7tr3tstm9jm@git.kernel.org
> > > > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> > > > ---
> > > >  tools/perf/util/data-convert-bt.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
> > > > index e0311c9750ad..9097543a818b 100644
> > > > --- a/tools/perf/util/data-convert-bt.c
> > > > +++ b/tools/perf/util/data-convert-bt.c
> > > > @@ -271,7 +271,7 @@ static int string_set_value(struct bt_ctf_field *field, const char *string)
> > > >                                 if (i > 0)
> > > >                                         strncpy(buffer, string, i);
> > > >                         }
> > > > -                       strncat(buffer + p, numstr, 4);
> > > > +                       memcpy(buffer + p, numstr, 4);
> > > I took care to have enough context in my patch that you could see what
> > > was going on. I wonder if there is a way to make that care
> > > propate when people add Signed-off-by: lines.
> >
> > I just checked and the patch is the same, the description I only changed
> > the subject line, so that when one uses:

> Functionally, yes. However look at how my version has enough context
> that you can immediately know that the patch is correct (instead of
> the default of 5 lines):

Hey, you're talking about the _patch_ context?

I haven't touched that, just applied the patch and then run 'git request-pull',
and that will not consider at all the initial, non-default context the patch
author used when sending upstream :-)

Also, with the patch applied, one can always do:

[acme@quaco perf]$ git log --oneline torvalds/master.. | grep strncat
97acec7df172 perf data: Fix 'strncat may truncate' build failure with recent gcc
[acme@quaco perf]$ git show -U10 97acec7df172
commit 97acec7df172cd1e450f81f5e293c0aa145a2797
Author: Shawn Landden <shawn@git.icu>
Date:   Sat May 18 15:32:38 2019 -0300
<SNIP>
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index e0311c9750ad..9097543a818b 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -264,21 +264,21 @@ static int string_set_value(struct bt_ctf_field *field, const char *string)
 
                        if (!buffer) {
                                buffer = zalloc(i + (len - i) * 4 + 2);
                                if (!buffer) {
                                        pr_err("failed to set unprintable string '%s'\n", string);
                                        return bt_ctf_field_string_set_value(field, "UNPRINTABLE-STRING");
                                }
                                if (i > 0)
                                        strncpy(buffer, string, i);
                        }
-                       strncat(buffer + p, numstr, 4);
+                       memcpy(buffer + p, numstr, 4);
                        p += 3;
                }
        }
 
        if (!buffer)
                return bt_ctf_field_string_set_value(field, string);
        err = bt_ctf_field_string_set_value(field, buffer);
        free(buffer);
        return err;
 }
[acme@quaco perf]$

Go bumping that -U10 value till you get the whole file 8-)

- Arnaldo


> https://www.spinics.net/lists/linux-perf-users/msg08563.html
> 
> >
> >    git log --oneline
> >
> > we can know what is the component and what kind of build failure was
> > that.
> >
> > - Arnaldo
> >
> > > >                         p += 3;
> > > >                 }
> > > >         }
> > > > --
> > > > 2.20.1
> > > >
> >
> > --
> >
> > - Arnaldo

  reply	other threads:[~2019-05-28 17:39 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-27 22:36 [GIT PULL] perf/urgent improvements and fixes Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 01/44] perf-with-kcore.sh: Always allow fix_buildid_cache_permissions Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 02/44] perf intel-pt: Fix itrace defaults for perf script Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 03/44] perf auxtrace: " Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 04/44] perf intel-pt: Fix itrace defaults for perf script intel-pt documentation Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 05/44] perf data: Fix 'strncat may truncate' build failure with recent gcc Arnaldo Carvalho de Melo
2019-05-27 22:46   ` Shawn Landden
2019-05-28 13:04     ` Arnaldo Carvalho de Melo
2019-05-28 16:59       ` Shawn Landden
2019-05-28 17:39         ` Arnaldo Carvalho de Melo [this message]
2019-05-27 22:36 ` [PATCH 06/44] perf arm64: Fix mksyscalltbl when system kernel headers are ahead of the kernel Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 07/44] tools include UAPI: Update copy of files related to new fspick, fsmount, fsconfig, fsopen, move_mount and open_tree syscalls Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 08/44] perf augmented_raw_syscalls: Fix up comment Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 09/44] perf beauty: Add generator for 'move_mount' flags argument Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 10/44] perf trace: Beautify 'move_mount' arguments Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 11/44] perf beauty: Add generator for fspick's 'flags' arg values Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 12/44] perf trace: Beautify 'fspick' arguments Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 13/44] perf beauty: Add generator for fsconfig's 'cmd' arg values Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 14/44] perf trace: Beautify 'fsconfig' arguments Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 15/44] perf beauty: Add generator for fsmount's 'attr_flags' arg values Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 16/44] perf trace: Introduce syscall_arg__scnprintf_strarray_flags Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 17/44] perf trace: Beautify 'fsmount' arguments Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 18/44] tools arch x86: Sync asm/cpufeatures.h with the with the kernel Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 19/44] tools headers UAPI: Sync linux/sched.h " Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 20/44] perf trace beauty clone: Handle CLONE_PIDFD Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 21/44] tools headers UAPI: Sync linux/fs.h with the kernel Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 22/44] perf beauty: Add generator for sync_file_range's 'flags' arg values Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 23/44] perf trace: Beautify 'sync_file_range' arguments Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 24/44] tools headers UAPI: Sync drm/i915_drm.h with the kernel Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 25/44] tools headers UAPI: Sync drm/drm.h " Arnaldo Carvalho de Melo
2019-05-28  3:17   ` Zhou, David(ChunMing)
2019-05-28  8:07   ` Lionel Landwerlin
2019-05-28 12:53     ` Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 26/44] perf namespace: Protect reading thread's namespace Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 27/44] perf session: Add missing swap ops for namespace events Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 28/44] perf top: Add --namespaces option Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 29/44] perf tools: Remove const from thread read accessors Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 30/44] perf dso: Separate generic code in dso__data_file_size() Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 31/44] perf dso: Separate generic code in dso_cache__read Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 32/44] perf dso: Simplify dso_cache__read function Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 33/44] perf dso: Add BPF DSO read and size hooks Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 34/44] perf test vmlinux-kallsyms: Ignore aliases to _etext when searching on kallsyms Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 35/44] perf machine: Read also the end of the kernel Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 36/44] perf machine: Keep zero in pgoff BPF map Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 37/44] perf tools: Preserve eBPF maps when loading kcore Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 38/44] perf script: Pad DSO name for --call-trace Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 39/44] perf tests: Add map_groups__merge_in test Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 40/44] perf script: Add --show-bpf-events to show eBPF related events Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 41/44] perf script: Remove superfluous BPF event titles Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 42/44] perf version: Append 12 git SHA chars to the version string Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 43/44] perf record: Fix s390 missing module symbol and warning for non-root users Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 44/44] tools headers UAPI: Sync kvm.h headers with the kernel sources Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190528173941.GC2935@redhat.com \
    --to=arnaldo.melo@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=slandden@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.com \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.