public inbox for dwarves@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
	Clark Williams <williams@redhat.com>,
	Kate Carcia <kcarcia@redhat.com>,
	dwarves@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Matthias Schwarzott <zzam@gentoo.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>
Subject: [PATCH 5/5] core, libctf: Check if constructor arguments are NULL before using them
Date: Tue, 19 Nov 2024 10:40:32 -0300	[thread overview]
Message-ID: <20241119134032.783215-6-acme@kernel.org> (raw)
In-Reply-To: <20241119134032.783215-1-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

  # pahole
  Segmentation fault (core dumped)
  #

Now we have:

  # ls -la bla
  ls: cannot access 'bla': No such file or directory
  # export PAHOLE_VMLINUX_BTF_FILENAME=bla
  # pahole
  pahole: couldn't find any debug information on this system.
  # pahole list_head
  pahole: couldn't find any debug information on this system.
  # pahole -F btf list_head
  pahole: couldn't find any btf debug information on this system.
  # pahole -F dwarf list_head
  pahole: couldn't find any dwarf debug information on this system.
  # tests/default_vmlinux_btf.sh
  Default BTF on a system without BTF: Ok
  #

Reported-by: Matthias Schwarzott <zzam@gentoo.org>
Cc: Alan Maguire <alan.maguire@oracle.com>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Song Liu <song@kernel.org>
Cc: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 dwarves.c | 3 +++
 libctf.c  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/dwarves.c b/dwarves.c
index 459311e64c8b45b2..ae512b9f46ddcc0a 100644
--- a/dwarves.c
+++ b/dwarves.c
@@ -777,6 +777,9 @@ struct cu *cu__new(const char *name, uint8_t addr_size,
 		if (cu->use_obstack)
 			obstack_init(&cu->obstack);
 
+		if (name == NULL || filename == NULL)
+			goto out_free;
+
 		cu->name = strdup(name);
 		if (cu->name == NULL)
 			goto out_free;
diff --git a/libctf.c b/libctf.c
index edb34dbf10de09e7..0641b10586527a6e 100644
--- a/libctf.c
+++ b/libctf.c
@@ -179,6 +179,9 @@ struct ctf *ctf__new(const char *filename, Elf *elf)
 	struct ctf *ctf = zalloc(sizeof(*ctf));
 
 	if (ctf != NULL) {
+		if (filename == NULL)
+			goto out_delete;
+
 		ctf->filename = strdup(filename);
 		if (ctf->filename == NULL)
 			goto out_delete;
-- 
2.47.0


  parent reply	other threads:[~2024-11-19 13:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-19 13:40 [PATCH 0/5] Fix segfaults related to missing BTF support Arnaldo Carvalho de Melo
2024-11-19 13:40 ` [PATCH 1/5] core: Add method to get the vmlinux BTF filename, allow overriding it via env var Arnaldo Carvalho de Melo
2024-11-19 13:40 ` [PATCH 2/5] tests default_vmlinux_btf: Introduce test for using BTF by default Arnaldo Carvalho de Melo
2024-11-19 13:40 ` [PATCH 3/5] pahole: Honour exclusive BTF loading Arnaldo Carvalho de Melo
2024-11-19 17:47   ` Alan Maguire
2024-11-19 20:18     ` Arnaldo Carvalho de Melo
2024-11-19 20:19     ` Arnaldo Carvalho de Melo
2024-11-19 22:04   ` Eduard Zingerman
2024-11-19 22:28     ` Alan Maguire
2024-11-19 22:33       ` Eduard Zingerman
2024-11-19 13:40 ` [PATCH 4/5] tests default_vmlinux_btf: Cover the no args segfault too Arnaldo Carvalho de Melo
2024-11-19 13:40 ` Arnaldo Carvalho de Melo [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-11-18 20:41 [PATCH 0/5] Fix segfaults related to missing BTF support Arnaldo Carvalho de Melo
     [not found] ` <20241118204146.772762-6-acme@kernel.org>
     [not found]   ` <4b465bfc-8214-41ab-8b6d-bbdf7421e19b@oracle.com>
2024-11-19 18:29     ` [PATCH 5/5] core, libctf: Check if constructor arguments are NULL before using them 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=20241119134032.783215-6-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kcarcia@redhat.com \
    --cc=song@kernel.org \
    --cc=williams@redhat.com \
    --cc=yonghong.song@linux.dev \
    --cc=zzam@gentoo.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox