[PATCH v2 06/10] s390/stackprotector: Serialize text patching with text_mutex

From: Heiko Carstens

Date: Tue Oct 27 2026 - 10:35:00 EST


Acquire text_mutex inside __stack_protector_apply() to serialize text
patching.

Serialization is not required for __stack_protector_apply(), however this
is part of larger series where at the end s390_kernel_write() requires
that callers hold text_mutex.

Signed-off-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
---
arch/s390/kernel/stackprotector.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/s390/kernel/stackprotector.c b/arch/s390/kernel/stackprotector.c
index 8bd3ecf9200a..d72aef57a40a 100644
--- a/arch/s390/kernel/stackprotector.c
+++ b/arch/s390/kernel/stackprotector.c
@@ -6,6 +6,7 @@

#include <linux/export.h>
#include <linux/hex.h>
+#include <linux/memory.h>
#include <linux/uaccess.h>
#include <linux/printk.h>
#include <asm/abs_lowcore.h>
@@ -120,6 +121,9 @@ int __stack_protector_apply(unsigned long *start, unsigned long *end, unsigned l
struct insn_ril *insn, new;
int rc;

+#ifndef __DECOMPRESSOR
+ guard(mutex)(&text_mutex);
+#endif
/*
* Convert LARL/LGRL instructions to LLILF so register R1 contains the
* address of the per-cpu / per-process stack canary:
--
2.53.0