From: "Rui Qi" <qirui.001@bytedance.com>
To: "Catalin Marinas" <catalin.marinas@arm.com>, <will@kernel.org>
Cc: <mark.rutland@arm.com>, <dylanbhatch@google.com>,
<song@kernel.org>, <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>,
<ardb@kernel.org>
Subject: Re: [PATCH v3] arm64: module: Use text-poke for late PLT/veneer emission
Date: Thu, 26 Nov 2026 20:26:15 +0800 [thread overview]
Message-ID: <6b3b684d-9f6c-4490-8c8d-aedffe35cc49@bytedance.com> (raw)
In-Reply-To: <179560945711.1480244.17746046705685189549.b4-ty@b4>
On 11/25/26 8:24 PM, Catalin Marinas wrote:
> On Tue, 17 Nov 2026 19:35:35 +0800, Rui Qi wrote:
>> module_emit_plt_entry() and module_emit_veneer_for_adrp() write PLT
>> entries into the .plt section by direct assignment. Once a module is
>> fully formed its .plt is read-only/executable, so a late (livepatch)
>> relocation that falls back to PLT emission -- an out-of-range
>> R_AARCH64_CALL26/JUMP26, or an ADRP under CONFIG_ARM64_ERRATUM_843419
>> -- triggers a synchronous Data Abort and panics.
>>
>> [...]
>
> Applied to arm64 (for-next/fixes), thanks!
>
> [1/1] arm64: module: Use text-poke for late PLT/veneer emission
> https://git.kernel.org/arm64/c/a7e632493acf
>
> I folded in a small fix which addresses Sashiko's comment: the bounds
> check before the write must allow i == plt_max_entries since .plt has
> plt_max_entries + 1 slots (the last one is where a duplicate of the
> final entry is built before being discarded). I restored the
> plt_num_entries check after the duplicate test as well.
>
> I moved the module_write_place() prototype to asm/module.h, next
> to the other PLT emitters. I concluded it's a better fit than
> text-patching.h. My concern on v2 was the macro but now it's an
> out-of-line function. I also dropped the const from the val argument,
> which removes the (void *) cast when calling aarch64_insn_copy(). All
> callers pass non-const locals anyway. It would be a good cleanup in the
> future but that should also add const to aarch64_insn_copy().
>
> Please check that I got these right.
Thanks for applying the patch and for the adjustments.
I've checked the resulting patch, and the folded-in changes look correct
to me. Allowing i == plt_max_entries preserves the spare slot used to
build a candidate for the duplicate check, while the restored
post-duplicate check prevents a non-duplicate entry from exceeding the
reserved capacity.
Moving the declaration to asm/module.h makes sense now that the helper
is an out-of-line function. Dropping const also matches the current
aarch64_insn_copy() interface and avoids the cast.
>
> Sashiko had some comments on v2 which we concluded are existing
> problems, just exposed because we no longer take a fault. If you have
> time for a livepatch reload follow-up (probably not cc stable), there
> are two separate problems when the target module is unloaded and loaded
> again:
>
> - The livepatch module's .plt slots are reserved once but used again on
> every klp_module_coming(), so a reload eventually hits the WARN and
> the target module is rejected. This is safe but we need some slot
> rewinding or a clear_relocate_add().
>
> - With the A53 erratum 843419 workaround, if the first application
> replaced an ADRP with a B to a veneer, reloc_insn_adrp() reads the
> B back on reload as if it were an ADRP. It either encodes the ADR
> immediate into the B or decodes Rd from the branch offset. This
> corrupts the livepatch code silently on the first reload (unrelated to
> how many slots are left). Not sure yet how to fix this, maybe the
> original instruction needs restoring on unload (or saving).
>
> Thanks.
>
Thanks for detailing the reload issues. I agree that they need separate
handling: reclaiming PLT slots alone would not address the ADRP-to-B
case, since reapplying the relocation also needs the original
instruction, including its destination register. I'll look into the slot
lifecycle and instruction restoration for a separate follow-up,
initially without Cc'ing stable.
Thanks,
Rui
prev parent reply other threads:[~2026-11-26 12:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 11:35 Rui Qi
2026-11-25 12:24 ` Catalin Marinas
2026-11-26 12:26 ` Rui Qi [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=6b3b684d-9f6c-4490-8c8d-aedffe35cc49@bytedance.com \
--to=qirui.001@bytedance.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=dylanbhatch@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--cc=will@kernel.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
all inboxes | Powered by JetHome®