linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Are read-only static labels incompatible with kernel modules?
@ 2020-12-07 20:37 Andrey Konovalov
  2020-12-08 12:51 ` Peter Zijlstra
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Konovalov @ 2020-12-07 20:37 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Randy Dunlap, Steven Rostedt
  Cc: LKML, Dmitry Vyukov, Alexander Potapenko, Marco Elver

Hi,

I'm getting a crash when trying to load a module into a kernel that
uses __ro_after_init static labels, see the crash below. The label is
defined and initialized in the main kernel binary, and is used in the
module. Is this not supported?

Thanks!

====

[   15.088489] Unable to handle kernel write to read-only memory at
virtual address ffffc4faeaa81ac8
Mem abort info:
  ESR = 0x9600004f
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
Data abort info:
  ISV = 0, ISS = 0x0000004f
  CM = 0, WnR = 1
swapper pgtable: 4k pages, 48-bit VAs, pgdp=000000004174b000
[ffffc4faeaa81ac8] pgd=00000000bdfff003, p4d=00000000bdfff003,
pud=00000000bdffe003, pmd=00000000bdffb003, pte=0060000041681f83
Internal error: Oops: 9600004f [#1] PREEMPT SMP
Modules linked in: test_kasan_module(+)
CPU: 1 PID: 207 Comm: insmod Not tainted 5.10.0-rc4 #11
Hardware name: linux,dummy-virt (DT)
pstate: 40400005 (nZcv daif +PAN -UAO -TCO BTYPE=--)
pc : static_key_set_linked kernel/jump_label.c:368
pc : jump_label_add_module+0x1ec/0x2dc kernel/jump_label.c:658
lr : jump_label_add_module+0x1a8/0x2dc kernel/jump_label.c:653
sp : ffff800010283ba0
x29: ffff800010283ba0 x28: f8ff0000034baac0
x27: ffffc4faeaa81000 x26: ffffc4fa92d45008
x25: fdff000002c01e00 x24: f9ff000003788c80
x23: f8ff000003788e80 x22: ffffc4faeaa81ac0
x21: ffffc4fa92d45000 x20: ffffc4fa92d45020
x19: ffffc4fa92d46000 x18: dead000000000100
x17: 000000000000003f x16: ffffc4fa92d4c000
x15: 0000000000000000 x14: 0000000000000008
x13: fefefefefefefeff x12: 0000000057d3caa9
x11: 0000000000002000 x10: ff80c4fae9791a1c
x9 : ffffc4fa92d43000 x8 : f9ff000003788c82
x7 : 0000000000000000 x6 : 000000000000003f
x5 : 0000000000000040 x4 : 0000000000000001
x3 : 0000000000000dc0 x2 : 00000000000000fe
x1 : 0000000000000000 x0 : 0000000000000000
Call trace:
 static_key_set_linked kernel/jump_label.c:368
 jump_label_add_module+0x1ec/0x2dc kernel/jump_label.c:658
 jump_label_module_notify+0x40/0xa4 kernel/jump_label.c:736
 notifier_call_chain kernel/notifier.c:83
 notifier_call_chain_robust kernel/notifier.c:118
 blocking_notifier_call_chain_robust+0x5c/0xe8 kernel/notifier.c:302
 prepare_coming_module kernel/module.c:3854
 load_module+0x2170/0x2cb4 kernel/module.c:4005
 __do_sys_finit_module kernel/module.c:4128
 __se_sys_finit_module kernel/module.c:4105
 __arm64_sys_finit_module+0xb8/0xf4 kernel/module.c:4105
 __invoke_syscall arch/arm64/kernel/syscall.c:36
 invoke_syscall arch/arm64/kernel/syscall.c:48
 el0_svc_common+0xa0/0x178 arch/arm64/kernel/syscall.c:159
 do_el0_svc+0x24/0x80 arch/arm64/kernel/syscall.c:205
 el0_svc arch/arm64/kernel/entry-common.c:236
 el0_sync_handler+0x1f0/0x2ac arch/arm64/kernel/entry-common.c:254
 el0_sync+0x190/0x1c0 arch/arm64/kernel/entry.S:740
Code: f94006c8 92400108 aa180108 b27f0108 (f90006c8)
---[ end trace 6f43f632dca3b2e8 ]---

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Are read-only static labels incompatible with kernel modules?
  2020-12-07 20:37 Are read-only static labels incompatible with kernel modules? Andrey Konovalov
@ 2020-12-08 12:51 ` Peter Zijlstra
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2020-12-08 12:51 UTC (permalink / raw)
  To: Andrey Konovalov
  Cc: Ingo Molnar, Randy Dunlap, Steven Rostedt, LKML, Dmitry Vyukov,
	Alexander Potapenko, Marco Elver, keescook

On Mon, Dec 07, 2020 at 09:37:54PM +0100, Andrey Konovalov wrote:
> Hi,
> 
> I'm getting a crash when trying to load a module into a kernel that
> uses __ro_after_init static labels, see the crash below. The label is
> defined and initialized in the main kernel binary, and is used in the
> module. Is this not supported?

Clearly not, but also, the whole RO thing never went past the
maintainers (it also seems to be missing a MAINTAINERs entry).

>  static_key_set_linked kernel/jump_label.c:368
>  jump_label_add_module+0x1ec/0x2dc kernel/jump_label.c:658
>  jump_label_module_notify+0x40/0xa4 kernel/jump_label.c:736

This, it needs to modify the key, which is RO, to add a list of sites
from the module.

It could probably be fixed..

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-08 12:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 20:37 Are read-only static labels incompatible with kernel modules? Andrey Konovalov
2020-12-08 12:51 ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).