[WARNING] livepatch/x86: Invalid return address when checking a stack of the schedule stuff

From: Petr Mladek
Date: Mon May 22 2017 - 07:50:45 EST


Hi,

I have just tried to apply the livepatch-sample module using
the consistency model in current Linus' tree (4.12-rc2) and
got the following warning from the stack checker code:

[ 28.580616] livepatch_sample: tainting kernel with TAINT_LIVEPATCH
[ 28.581572] livepatch_sample: module verification failed: signature and/or required key missing - tainting kernel
[ 28.589943] livepatch: enabling patch 'livepatch_sample'
[ 28.592146] livepatch: 'livepatch_sample': patching...
[ 28.592643] ------------[ cut here ]------------
[ 28.593069] WARNING: CPU: 1 PID: 3699 at arch/x86/kernel/stacktrace.c:132 save_stack_trace_tsk_reliable+0x133/0x1a0
[ 28.594006] Modules linked in: livepatch_sample(EK+)
[ 28.594452] CPU: 1 PID: 3699 Comm: modprobe Tainted: G E K 4.12.0-rc2-52.49-default #3975
[ 28.595267] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[ 28.595786] task: ffff8801378ad080 task.stack: ffffc90000c7c000
[ 28.596009] RIP: 0010:save_stack_trace_tsk_reliable+0x133/0x1a0
[ 28.596009] RSP: 0018:ffffc90000c7faf0 EFLAGS: 00010046
[ 28.596009] RAX: 0000000000000000 RBX: ffffc90000c7fb90 RCX: 000000000000014f
[ 28.596009] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
[ 28.596009] RBP: ffffc90000c7fb60 R08: ffffc90000633f40 R09: 0000000000000000
[ 28.596009] R10: 0000000000000005 R11: 0000000000000001 R12: ffff880138b9c080
[ 28.596009] R13: ffff880138b9c080 R14: ffff88013dd9a700 R15: ffff880138b9c7d8
[ 28.596009] FS: 00007fa9ae9b6700(0000) GS:ffff88013dc80000(0000) knlGS:0000000000000000
[ 28.596009] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 28.596009] CR2: 000000000064a008 CR3: 0000000137cff000 CR4: 00000000000006e0
[ 28.596009] Call Trace:
[ 28.596009] klp_try_switch_task+0x10b/0x2c0
[ 28.596009] ? set_kernel_text_ro+0x3c/0x40
[ 28.596009] ? vprintk_default+0x29/0x50
[ 28.596009] ? vprintk_func+0x20/0x50
[ 28.596009] ? printk+0x48/0x4a
[ 28.596009] klp_try_complete_transition+0x88/0x1c0
[ 28.596009] __klp_enable_patch+0xbb/0xf0
[ 28.596009] klp_enable_patch+0x53/0x80
[ 28.596009] livepatch_init+0x31/0x60 [livepatch_sample]
[ 28.596009] ? livepatch_cmdline_proc_show+0x30/0x30 [livepatch_sample]
[ 28.596009] do_one_initcall+0x42/0x180
[ 28.596009] ? __vunmap+0x85/0xc0
[ 28.596009] ? do_init_module+0x27/0x202
[ 28.596009] do_init_module+0x60/0x202
[ 28.596009] load_module+0x13a3/0x1ac0
[ 28.596009] ? m_show+0x190/0x190
[ 28.596009] SYSC_finit_module+0xa0/0xb0
[ 28.596009] SyS_finit_module+0xe/0x10
[ 28.596009] entry_SYSCALL_64_fastpath+0x1a/0xa5
[ 28.596009] RIP: 0033:0x7fa9ae4e6789
[ 28.596009] RSP: 002b:00007fff9a96bbd8 EFLAGS: 00000206 ORIG_RAX: 0000000000000139
[ 28.596009] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fa9ae4e6789
[ 28.596009] RDX: 0000000000000000 RSI: 00000000004195f6 RDI: 0000000000000003
[ 28.596009] RBP: 00007fff9a96aab0 R08: 0000000000000000 R09: 0000000000000000
[ 28.596009] R10: 0000000000000003 R11: 0000000000000206 R12: 0000000000000000
[ 28.596009] R13: 0000000000000026 R14: 0000000000000000 R15: 0000000000000000
[ 28.596009] Code: c6 05 3e a2 c1 00 01 0f ff 31 f6 4c 89 e7 41 bd ea ff ff ff e8 8f 45 ff ff eb c0 80 3d 24 a2 c1 00 00 75 b1 c6 05 1b a2 c1 00 01 <0f> ff 4c 89 e7 e8 73 45 ff ff eb 9e 8b 03 45 31 ed 3b 43 04 73
[ 28.596009] ---[ end trace e67087ea4a13b96c ]---
[ 28.596009] Call Trace:
[ 28.596009] __schedule+0x273/0x820
[ 28.596009] schedule+0x36/0x80
[ 28.596009] kthreadd+0x305/0x310
[ 28.596009] ? kthread_create_on_cpu+0x80/0x80
[ 28.596009] ? icmp_echo.part.32+0x50/0x50
[ 28.596009] ret_from_fork+0x2c/0x40


The test done on in qemu on x86_64. The problem is 100% reproducible.
Does it ring any bell, please?

Best Regards,
Petr