* [PATCH] perf: buildid-cache zero out buffer of filenames when adding/remoing buildid
@ 2011-07-18 3:13 Han Pingtian
2011-07-18 10:34 ` Jiri Olsa
2011-08-05 10:06 ` [tip:perf/urgent] perf buildid-cache: Zero out buffer of filenames when adding/removing buildid tip-bot for Han Pingtian
0 siblings, 2 replies; 3+ messages in thread
From: Han Pingtian @ 2011-07-18 3:13 UTC (permalink / raw)
To: linux-kernel, Arnaldo Carvalho de Melo, jolsa
readlink() doesn't append a null byte to buf. So we should zero out buf
with zalloc(). Or we'll see sometimes error like this:
[root@intel-s3e36-01]~# /usr/bin/perf buildid-cache -a /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko -v
Adding f64ba8efd5f53c7ad332fc17db1d21de309038e1 /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko: Ok
[root@intel-s3e36-01]~# /usr/bin/perf buildid-cache -r /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko -v
Removing f64ba8efd5f53c7ad332fc17db1d21de309038e1 /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko: FAIL
/lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko wasn't in the cache
The change in build_id_cache__add_s() is a defense.
Signed-off-by: Han Pingtian <phan@redhat.com>
---
| 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index afb0849..36d723d 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -189,8 +189,8 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
const char *name, bool is_kallsyms)
{
const size_t size = PATH_MAX;
- char *realname, *filename = malloc(size),
- *linkname = malloc(size), *targetname;
+ char *realname, *filename = zalloc(size),
+ *linkname = zalloc(size), *targetname;
int len, err = -1;
if (is_kallsyms) {
@@ -254,8 +254,8 @@ static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size,
int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir)
{
const size_t size = PATH_MAX;
- char *filename = malloc(size),
- *linkname = malloc(size);
+ char *filename = zalloc(size),
+ *linkname = zalloc(size);
int err = -1;
if (filename == NULL || linkname == NULL)
--
1.7.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] perf: buildid-cache zero out buffer of filenames when adding/remoing buildid
2011-07-18 3:13 [PATCH] perf: buildid-cache zero out buffer of filenames when adding/remoing buildid Han Pingtian
@ 2011-07-18 10:34 ` Jiri Olsa
2011-08-05 10:06 ` [tip:perf/urgent] perf buildid-cache: Zero out buffer of filenames when adding/removing buildid tip-bot for Han Pingtian
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Olsa @ 2011-07-18 10:34 UTC (permalink / raw)
To: linux-kernel, Arnaldo Carvalho de Melo
On Mon, Jul 18, 2011 at 11:13:14AM +0800, Han Pingtian wrote:
> readlink() doesn't append a null byte to buf. So we should zero out buf
> with zalloc(). Or we'll see sometimes error like this:
>
> [root@intel-s3e36-01]~# /usr/bin/perf buildid-cache -a /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko -v
> Adding f64ba8efd5f53c7ad332fc17db1d21de309038e1 /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko: Ok
> [root@intel-s3e36-01]~# /usr/bin/perf buildid-cache -r /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko -v
> Removing f64ba8efd5f53c7ad332fc17db1d21de309038e1 /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko: FAIL
> /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko wasn't in the cache
>
> The change in build_id_cache__add_s() is a defense.
>
> Signed-off-by: Han Pingtian <phan@redhat.com>
works for me
Tested-by: Jiri Olsa <jolsa@redhat.com>
> ---
> tools/perf/util/header.c | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index afb0849..36d723d 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -189,8 +189,8 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
> const char *name, bool is_kallsyms)
> {
> const size_t size = PATH_MAX;
> - char *realname, *filename = malloc(size),
> - *linkname = malloc(size), *targetname;
> + char *realname, *filename = zalloc(size),
> + *linkname = zalloc(size), *targetname;
> int len, err = -1;
>
> if (is_kallsyms) {
> @@ -254,8 +254,8 @@ static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size,
> int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir)
> {
> const size_t size = PATH_MAX;
> - char *filename = malloc(size),
> - *linkname = malloc(size);
> + char *filename = zalloc(size),
> + *linkname = zalloc(size);
> int err = -1;
>
> if (filename == NULL || linkname == NULL)
> --
> 1.7.1
^ permalink raw reply [flat|nested] 3+ messages in thread* [tip:perf/urgent] perf buildid-cache: Zero out buffer of filenames when adding/removing buildid
2011-07-18 3:13 [PATCH] perf: buildid-cache zero out buffer of filenames when adding/remoing buildid Han Pingtian
2011-07-18 10:34 ` Jiri Olsa
@ 2011-08-05 10:06 ` tip-bot for Han Pingtian
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Han Pingtian @ 2011-08-05 10:06 UTC (permalink / raw)
To: linux-tip-commits; +Cc: acme, linux-kernel, hpa, mingo, phan, tglx, jolsa
Commit-ID: 4f9bae351d299149a84f76cd34bf0150614e8c8e
Gitweb: http://git.kernel.org/tip/4f9bae351d299149a84f76cd34bf0150614e8c8e
Author: Han Pingtian <phan@redhat.com>
AuthorDate: Mon, 18 Jul 2011 11:13:14 +0800
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 22 Jul 2011 08:59:26 -0300
perf buildid-cache: Zero out buffer of filenames when adding/removing buildid
The readlink() function doesn't append a null byte to buf. So we should
zero out buf with zalloc(). Or we'll see sometimes error like this:
[root@intel-s3e36-01]~# /usr/bin/perf buildid-cache -a /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko -v
Adding f64ba8efd5f53c7ad332fc17db1d21de309038e1 /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko: Ok
[root@intel-s3e36-01]~# /usr/bin/perf buildid-cache -r /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko -v
Removing f64ba8efd5f53c7ad332fc17db1d21de309038e1 /lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko: FAIL
/lib/modules/2.6.32-130.el6.x86_64/kernel/crypto/twofish_common.ko wasn't in the cache
The change in build_id_cache__add_s() is a defense.
Tested-by: Jiri Olsa <jolsa@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20110718031314.GA5802@hpt.nay.redhat.com
Signed-off-by: Han Pingtian <phan@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
| 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index cb2959a..d4f3101 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -189,8 +189,8 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
const char *name, bool is_kallsyms)
{
const size_t size = PATH_MAX;
- char *realname, *filename = malloc(size),
- *linkname = malloc(size), *targetname;
+ char *realname, *filename = zalloc(size),
+ *linkname = zalloc(size), *targetname;
int len, err = -1;
if (is_kallsyms) {
@@ -254,8 +254,8 @@ static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size,
int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir)
{
const size_t size = PATH_MAX;
- char *filename = malloc(size),
- *linkname = malloc(size);
+ char *filename = zalloc(size),
+ *linkname = zalloc(size);
int err = -1;
if (filename == NULL || linkname == NULL)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-05 10:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-18 3:13 [PATCH] perf: buildid-cache zero out buffer of filenames when adding/remoing buildid Han Pingtian
2011-07-18 10:34 ` Jiri Olsa
2011-08-05 10:06 ` [tip:perf/urgent] perf buildid-cache: Zero out buffer of filenames when adding/removing buildid tip-bot for Han Pingtian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome