Linux Hardening
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: Kees Cook <kees@kernel.org>
Cc: Jan Hubicka <hubicka@ucw.cz>,
	gcc-patches@gcc.gnu.org, linux-hardening@vger.kernel.org,
	Richard Biener <rguenther@suse.de>
Subject: Re: [PATCH] ipa-icf: Step to the next caller past a thunk in redirect_all_callers
Date: Tue, 20 Oct 2026 17:14:25 +0200	[thread overview]
Message-ID: <ri68q3sl7zi.fsf@virgil.suse.cz> (raw)
In-Reply-To: <pr158sq2-203s-20n3-q44q-o599q271r309@fhfr.qr>

Hi,

On Mon, Oct 19 2026, Richard Biener wrote:
> On Thu, 15 Oct 2026, Kees Cook wrote:
>
>> redirect_all_callers walks the callers of N, but steps past a thunk
>> caller with next_callee, the next call the thunk makes.  A thunk makes
>> only that one call, so the walk ends there, and so the callers after
>> the thunk in the list would not be redirected.  This came with the thunk
>> check in commit 17d1bf760f8 ("re PR target/65263").
>
> Huh.  This looks obvious to me, thus OK unless Jan or Martin object
> soon.

This is fairly obviously OK.

Thanks for catching this!

Martin


>
> Thanks,
> Richard.
>
>> gcc/ChangeLog:
>> 
>> 	* ipa-icf.cc (redirect_all_callers): Step to the next caller, not
>> 	the next callee, past a thunk.
>> 
>> Signed-off-by: Kees Cook <kees@kernel.org>
>> ---
>> I found this while looking through ICF code and Richard's recently
>> proposed changes with inlining, so it's technically unrelated, but it
>> looked wrong.  But I haven't found a way to reach it: on targets with
>> symbol aliases a thunk calls a local alias of its function (.LTHUNKn),
>> whose other callers come from redirections and so are ahead of the thunk
>> in the list, and on targets without them, such as Darwin, thunks are
>> expanded to GIMPLE before ICF.  So I have not been able to build a test
>> case for this, and I suspect it may just be accidentally/effectively
>> dead code?  But the intent of the function didn't seem to match the
>> result of the "else"'s list-walk.
>> ---
>>  gcc/ipa-icf.cc | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/gcc/ipa-icf.cc b/gcc/ipa-icf.cc
>> index 64cc722bd7aa..7b524bdf16b1 100644
>> --- a/gcc/ipa-icf.cc
>> +++ b/gcc/ipa-icf.cc
>> @@ -995,7 +995,7 @@ redirect_all_callers (cgraph_node *n, cgraph_node *to)
>>            nredirected++;
>>  	}
>>        else
>> -	e = e->next_callee;
>> +	e = e->next_caller;
>>      }
>>    for (unsigned i = 0; n->iterate_direct_aliases (i, ref);)
>>      {
>> 
>
> -- 
> Richard Biener <rguenther@suse.de>
> SUSE Software Solutions Germany GmbH,
> Frankenstrasse 146, 90461 Nuernberg, Germany;
> GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg)

  reply	other threads:[~2026-10-20 15:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 19:45 [PATCH] ipa-icf: Step to the next caller past a thunk in redirect_all_callers Kees Cook
2026-10-19 11:39 ` Richard Biener
2026-10-20 15:14   ` Martin Jambor [this message]
2026-10-22 19:24     ` Kees Cook
2026-10-23 12:10       ` Richard Biener

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=ri68q3sl7zi.fsf@virgil.suse.cz \
    --to=mjambor@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=rguenther@suse.de \
    /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