From: Alan Maguire <almagui@kernel.org>
To: havard.f.aasen@pfft.no
Cc: dwarves@vger.kernel.org
Subject: Re: [PATCH 1/1] prefcnt: guard against NULL function parameters
Date: Fri, 16 Oct 2026 17:46:02 +0100 [thread overview]
Message-ID: <7c184732-82fb-4ea0-982d-79bb40cd27c6@kernel.org> (raw)
In-Reply-To: <20260928182217.301003-2-havard.f.aasen@pfft.no>
> When prefcnt is started without an input file, it loads the running
> kernel's debugging information through the existing vmlinux/BTF/ELF
> loading path. While walking the functions in the resulting
> compilation units, some function parameter entries can be represented
> by a NULL pointer.
>
> refcnt_function() passes each entry from function->proto.parms to
> refcnt_parameter(). refcnt_parameter() dereferences the entry when it
> checks parameter->tag.type, causing prefcnt to terminate with a
> segmentation fault if the entry is NULL.
I still see a segmentation fault when running prefcnt on /sys/kernel/btf/vmlinux
with this change; I think the right answer here is to fix the caller by
using function__for_each_parameter() which will correctly use the ftype
to get parameters for BTF, i.e.
diff --git a/prefcnt.c b/prefcnt.c
index 37ca18f..86fceba 100644
--- a/prefcnt.c
+++ b/prefcnt.c
@@ -106,7 +106,7 @@ static void refcnt_function(struct function *function, const struct cu *cu)
refcnt_tag(type, cu);
}
- list_for_each_entry(parameter, &function->proto.parms, tag.node)
+ function__for_each_parameter(function, cu, parameter)
refcnt_parameter(parameter, cu);
refcnt_lexblock(&function->lexblock, cu);
Can you send a v2? Thanks!
prev parent reply other threads:[~2026-10-16 16:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 18:21 [PATCH 0/1] prefcnt: guard against NULL function parameters Håvard F. Aasen
2026-09-28 18:21 ` [PATCH 1/1] " Håvard F. Aasen
2026-10-16 16:46 ` Alan Maguire [this message]
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=7c184732-82fb-4ea0-982d-79bb40cd27c6@kernel.org \
--to=almagui@kernel.org \
--cc=dwarves@vger.kernel.org \
--cc=havard.f.aasen@pfft.no \
/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