[PATCH 0/2] arm64: modules: Reject loading of malformed modules

Adrian Barnaś posted 2 patches 1 week, 5 days ago
There is a newer version of this series
arch/arm64/include/asm/alternative.h |  4 ++--
arch/arm64/include/asm/scs.h         |  2 +-
arch/arm64/kernel/alternative.c      | 15 ++++++++++-----
arch/arm64/kernel/module.c           | 14 ++++++++++----
arch/arm64/kernel/pi/map_kernel.c    |  2 +-
arch/arm64/kernel/pi/patch-scs.c     | 15 +++++++++++----
arch/arm64/kernel/pi/pi.h            |  2 +-
7 files changed, 36 insertions(+), 18 deletions(-)
[PATCH 0/2] arm64: modules: Reject loading of malformed modules
Posted by Adrian Barnaś 1 week, 5 days ago
Hi,

Here are a couple of patches to reject the loading of malformed modules
on arm64 when the SCS patching is only partially applied or we detect
an alternative callback function used in the module text.

The SCS issue is largely theoretical. The code currently performs
a "dry-run" (which we remove), and leave module code as-is if failed.
However the latter issue was reported to crash the kernel at [1].

Patches based on v6.17-rc1.

Thanks,
Adrian

[1] https://lore.kernel.org/all/20250807072700.348514-1-fanqincui@163.com/

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Dylan Hatch <dylanbhatch@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>

Adrian Barnaś (2):
  arch: arm64: Fail module loading if dynamic SCS patching fails
  arch: arm64: Reject modules with internal alternative callbacks

 arch/arm64/include/asm/alternative.h |  4 ++--
 arch/arm64/include/asm/scs.h         |  2 +-
 arch/arm64/kernel/alternative.c      | 15 ++++++++++-----
 arch/arm64/kernel/module.c           | 14 ++++++++++----
 arch/arm64/kernel/pi/map_kernel.c    |  2 +-
 arch/arm64/kernel/pi/patch-scs.c     | 15 +++++++++++----
 arch/arm64/kernel/pi/pi.h            |  2 +-
 7 files changed, 36 insertions(+), 18 deletions(-)

-- 
2.51.0.534.gc79095c0ca-goog
Re: [PATCH 0/2] arm64: modules: Reject loading of malformed modules
Posted by Ard Biesheuvel 1 week, 5 days ago
Hello Adrian,

On Fri, 19 Sept 2025 at 14:23, Adrian Barnaś <abarnas@google.com> wrote:
>
> Hi,
>
> Here are a couple of patches to reject the loading of malformed modules
> on arm64 when the SCS patching is only partially applied or we detect
> an alternative callback function used in the module text.
>
> The SCS issue is largely theoretical. The code currently performs
> a "dry-run" (which we remove), and leave module code as-is if failed.
> However the latter issue was reported to crash the kernel at [1].
>

Why are you fixing this largely theoretical issue along with the
callback alternatives patching? The referenced thread only talks about
the latter, right?
Re: [PATCH 0/2] arm64: modules: Reject loading of malformed modules
Posted by Adrian Barnaś 1 week, 5 days ago
On Fri, Sep 19, 2025 at 03:17:29PM +0200, Ard Biesheuvel wrote:
>Hello Adrian,
>
>On Fri, 19 Sept 2025 at 14:23, Adrian Barnaś <abarnas@google.com> wrote:
>>
>> Hi,
>>
>> Here are a couple of patches to reject the loading of malformed modules
>> on arm64 when the SCS patching is only partially applied or we detect
>> an alternative callback function used in the module text.
>>
>> The SCS issue is largely theoretical. The code currently performs
>> a "dry-run" (which we remove), and leave module code as-is if failed.
>> However the latter issue was reported to crash the kernel at [1].
>>
>
>Why are you fixing this largely theoretical issue along with the
>callback alternatives patching? The referenced thread only talks about
>the latter, right?

Hello Ard,

You are right that the reference thread is only about the alternative
callback issue in modules. We found the potential SCS issue while fixing 
this. Proposed resolutions are symmetrical. That's why it is in a single
patch set.

If you find it incorrect I can split it into two separate patches.

Thanks,
Adrian