From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D303D0BB6E for ; Thu, 24 Oct 2024 08:17:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ABD456B0085; Thu, 24 Oct 2024 04:17:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A6D9D6B0092; Thu, 24 Oct 2024 04:17:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90D1C6B0093; Thu, 24 Oct 2024 04:17:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 734076B0085 for ; Thu, 24 Oct 2024 04:17:33 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DC07BA1158 for ; Thu, 24 Oct 2024 08:16:59 +0000 (UTC) X-FDA: 82707790914.25.870307F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 005C8A0024 for ; Thu, 24 Oct 2024 08:17:12 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kUYTT8Tx; spf=pass (imf15.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729757773; a=rsa-sha256; cv=none; b=DfddFKGuwf2bbjD/yYHWNnQAFYF0iyZENg+ciy/L2+V4ho7dVvM1vqYtcOCuK8jBn43qHX iYz1ZwEO079odkgis1j5sWH6IN4SQFVIaqyC1oxO1brzkhy9jQ1Ub/XV3hrSuYHNfKNQQh /z3afVzlmACoILGZAX+bFRoLnPJ+iMI= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kUYTT8Tx; spf=pass (imf15.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729757773; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=g3K4ef/KmpkfeKFv5ppF+rs6b1B8g+A5uc3pZ2O6WU0=; b=IcOwZLdMiCiwY62QbSmBpf/5KOgHvJXq/XcYOGdAZPeB3oYdZYQ/j8cw9NqbOIAAwkK9w2 ie3783lhPQ32/lfqJvZwE/kEX6oxBVAJBYA7dj+VL90mGEMsQW4fN2oS4+tMN9LKUoYr0Q mIy4/RndnvbT3iJO1/RwNRjATCCHa8g= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5129A5C53EF; Thu, 24 Oct 2024 08:17:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 612D5C4CEC7; Thu, 24 Oct 2024 08:16:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729757849; bh=Ox/ZYsBrrmbPK3A2QSUcQ8QfXoa69FGJYXDNNRcdBnE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kUYTT8Tx/x5v0ueXFlaIbTgM/tC1LFzcQH/Bk/9E/G27ofyIbDJ7VnB94NYJst0cv rwM3dJS8U0ddWOUUXyYJ5U2DbjwqikH39DsU8Z9vNeIPIaGV5iltmAX+1Y07CtyHuu qjH8xAIYsTm3k2jYsPE3Yg78rgh4kjznfSO7VPR6GqKUwnNvv6GGqa5UsKhK6x1lWv w5QasDDvCUMmBgmW/lX8F5rn9hH0iBupLlusSquog8hp4ocLfovmnzNHmy5eiFqmmK d1E2Of3Az/DoYE4MNq3gGFDCWEofW+6fRLAOpgssfQgrtruzoRtxJno9OxgV2pJlkI Cl6tQ0r75+5yg== Date: Thu, 24 Oct 2024 11:13:11 +0300 From: Mike Rapoport To: Nathan Chancellor Cc: Andrew Morton , Luis Chamberlain , Andreas Larsson , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Brian Cain , Catalin Marinas , Christoph Hellwig , Christophe Leroy , Dave Hansen , Dinh Nguyen , Geert Uytterhoeven , Guo Ren , Helge Deller , Huacai Chen , Ingo Molnar , Johannes Berg , John Paul Adrian Glaubitz , Kent Overstreet , "Liam R. Howlett" , Mark Rutland , Masami Hiramatsu , Matt Turner , Max Filippov , Michael Ellerman , Michal Simek , Oleg Nesterov , Palmer Dabbelt , Peter Zijlstra , Richard Weinberger , Russell King , Song Liu , Stafford Horne , Steven Rostedt , Suren Baghdasaryan , Thomas Bogendoerfer , Thomas Gleixner , Uladzislau Rezki , Vineet Gupta , Will Deacon , bpf@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-trace-kernel@vger.kernel.org, linux-um@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v6 6/8] x86/module: prepare module loading for ROX allocations of text Message-ID: References: <20241016122424.1655560-1-rppt@kernel.org> <20241016122424.1655560-7-rppt@kernel.org> <20241021221519.GA3567210@thelio-3990X> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241021221519.GA3567210@thelio-3990X> X-Stat-Signature: ntfxnzjjuf6u1serrwmn1pjdswpqw3cu X-Rspamd-Queue-Id: 005C8A0024 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1729757832-513883 X-HE-Meta: U2FsdGVkX1/MuDj6qzbMRi4tRq4DlCTcJ3q2LZ5ZDZOh7Ow7O4yAj1hkldumBPQefuyqfmPdVq+eSipwzeYMQOZh4A7Jm2Ox9DoILde+A82zLmv5g3D+h21tcoYlfm/d6j3lIR3tmsYSEEzRLvKeVdJGsiHp62+h+xfvLUWsW0DQ85InhO8jo3NpaHlCo8KpbtSLVprZPedAgYbZeNrc4re8gq0dTeKjTdh2azyOTo8yG5GFmSh6ry2PnvbVH0tmGK77UX0uOqM2TIyGIL1/lHBkTQJYWT9xUmlVznJX03BVnrr1f1y8r5g/TypPqsdH8xVpO339taRuW1OpqR7ZXJ4BoioVcuIIgXlqRGo6t+Ge6AI+cUQAscsnhizhBsvqi6xvH5PdnKSb6JuvBjhAMOfNoKv2eatkwbnrvFFMBeGwK3yFZLEt5y2Qp61QD0nYZct+z4qrQXIhm8kkrtetY/ttTS96YWnfCnpADV9/v6Qq4ff9wPbaVymJYrMiShNxrJyYFn/3caQUnYLtc30RKJFl0ioag4Bi09lehRk5UGcLLQtnbvgEUwJb2xf9qA96AWSsJndfX1x+2IR7W9DtNd0oS0Og9HDXKmhAnPHJPViHaoIbnqJXyAa3ijDhqxwrzpMZbpegbinynr1TWKAVKw/URknLxES3Cis7aCJMi2eFT0cZazyOLljc+9K2fzrhEe7YLQ1UuW2e+2y6g0wyEEcnZ8Lo6wL0m79yO77d6DBfZXIdCjauYSo78gMS2zzQniQ7uZFThLdXlhAOnkwZHSQOZCZApNCWH4GuSwVZFWE7fIqnvKvomzCy6THID0UQSGQ8Ol+Jt/clYmYJyuLdZTF84nFF3QmKH6rejKRHCiYuyxFCS4QFfMPYdxmMpiNfWV7lGWODRe2n1MI9Gz4R6Dr7z1TLWFMur/NM1h+s8U21hzgUYuklgNsy/LlCe1ehdlfvsFF8YTB2V+piPBx EoOpMD4n UfC3ejRh92E9Ahk+MYAJHg69Br87y2LPoYzgtikxS/LK7wx3bAETKaSSwxqP2PukLU6MPFaae6lVnPLhOLPbLiIl0Bg3Qun7XbamQhA8gyhhXymrztsVrdAxzXl290+oyepBNqwubI65Rm5CvJt2EwQOPOAk1ZwS2NTAcwUYcI58h+o39rTvaU8VjL1S9GlZYNMC1WF1EWgiNgDB5huy5QV+cX5TR0mCddYaxJeaxpuGpZ3dutvCWEZy0Vuq2FKDxglmeHmDyJDfpo2NsRNwlfQTsFL5sQj6+/DTjDMps5Wsy67w= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi Nathan, On Mon, Oct 21, 2024 at 03:15:19PM -0700, Nathan Chancellor wrote: > Hi Mike, > > On Wed, Oct 16, 2024 at 03:24:22PM +0300, Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > When module text memory will be allocated with ROX permissions, the > > memory at the actual address where the module will live will contain > > invalid instructions and there will be a writable copy that contains the > > actual module code. > > > > Update relocations and alternatives patching to deal with it. > > > > Signed-off-by: Mike Rapoport (Microsoft) > > Sorry that you have to hear from me again :) It seems that module > loading is still broken with this version of the patch, which is > something that I missed in my earlier testing since I only test a > monolithic kernel with my regular virtual machine testing. If I build > and install the kernel and modules in the VM via a distribution package, > I get the following splat at boot: > > Starting systemd-udevd version 256.7-1-arch > [ 0.882312] SMP alternatives: Something went horribly wrong trying to rewrite the CFI implementation. > [ 0.883526] CFI failure at do_one_initcall+0x128/0x380 (target: init_module+0x0/0xff0 [crc32c_intel]; expected type: 0x0c7a3a22) > [ 0.884802] Oops: invalid opcode: 0000 [#1] PREEMPT SMP NOPTI > [ 0.885434] CPU: 3 UID: 0 PID: 157 Comm: modprobe Tainted: G W 6.12.0-rc3-debug-next-20241021-06324-g63b3ff03d91a #1 291f0fd70f293827edec681d3c5304f5807a3c7b > [ 0.887084] Tainted: [W]=WARN > [ 0.887409] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 2/2/2022 > [ 0.888241] RIP: 0010:do_one_initcall+0x128/0x380 > [ 0.888720] Code: f3 0f 1e fa 41 be ff ff ff ff e9 0f 01 00 00 0f 1f 44 00 00 41 81 e7 ff ff ff 7f 49 89 db 41 ba de c5 85 f3 45 03 53 f1 74 02 <0f> 0b 41 ff d3 0f 1f 00 41 89 c6 0f 1f 44 00 00 c6 04 24 00 65 8b > [ 0.890598] RSP: 0018:ff3f93e5c052f970 EFLAGS: 00010217 > [ 0.891129] RAX: ffffffffb4c105b8 RBX: ffffffffc0602010 RCX: 0000000000000000 > [ 0.891850] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffffc0602010 > [ 0.892588] RBP: ff3f93e5c052fc88 R08: 0000000000000020 R09: 0000000000000000 > [ 0.893305] R10: 000000002a378b84 R11: ffffffffc0602010 R12: 00000000000069c6 > [ 0.894003] R13: ff1f0090c5596900 R14: ff1f0090c15a55c0 R15: 0000000000000000 > [ 0.894693] FS: 00007ffb712c0740(0000) GS:ff1f00942fb80000(0000) knlGS:0000000000000000 > [ 0.895453] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [ 0.896020] CR2: 00007ffffc4424c8 CR3: 0000000100af4002 CR4: 0000000000771ef0 > [ 0.896698] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > [ 0.897391] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > [ 0.898077] PKRU: 55555554 > [ 0.898337] Call Trace: > [ 0.898577] > [ 0.898784] ? __die_body+0x6a/0xb0 > [ 0.899132] ? die+0xa4/0xd0 > [ 0.899413] ? do_trap+0xa6/0x180 > [ 0.899740] ? do_one_initcall+0x128/0x380 > [ 0.900130] ? do_one_initcall+0x128/0x380 > [ 0.900523] ? handle_invalid_op+0x6a/0x90 > [ 0.900917] ? do_one_initcall+0x128/0x380 > [ 0.901311] ? exc_invalid_op+0x38/0x60 > [ 0.901679] ? asm_exc_invalid_op+0x1a/0x20 > [ 0.902081] ? __cfi_init_module+0x10/0x10 [crc32c_intel 5331566c5540f82df397056699bc4ddac8be1306] > [ 0.902933] ? __cfi_init_module+0x10/0x10 [crc32c_intel 5331566c5540f82df397056699bc4ddac8be1306] > [ 0.903781] ? __cfi_init_module+0x10/0x10 [crc32c_intel 5331566c5540f82df397056699bc4ddac8be1306] > [ 0.904634] ? do_one_initcall+0x128/0x380 > [ 0.905028] ? idr_alloc_cyclic+0x139/0x1d0 > [ 0.905437] ? security_kernfs_init_security+0x54/0x190 > [ 0.905958] ? __kernfs_new_node+0x1ba/0x240 > [ 0.906377] ? sysfs_create_dir_ns+0x8f/0x140 > [ 0.906795] ? kernfs_link_sibling+0xf2/0x110 > [ 0.907211] ? kernfs_activate+0x2c/0x110 > [ 0.907599] ? kernfs_add_one+0x108/0x150 > [ 0.907981] ? __kernfs_create_file+0x75/0xa0 > [ 0.908407] ? sysfs_create_bin_file+0xc6/0x120 > [ 0.908853] ? __vunmap_range_noflush+0x347/0x420 > [ 0.909313] ? _raw_spin_unlock+0xe/0x30 > [ 0.909692] ? free_unref_page+0x22c/0x4c0 > [ 0.910097] ? __kmalloc_cache_noprof+0x1a8/0x360 > [ 0.910546] do_init_module+0x60/0x250 > [ 0.910910] __se_sys_finit_module+0x316/0x420 > [ 0.911351] do_syscall_64+0x88/0x170 > [ 0.911699] ? __x64_sys_lseek+0x68/0xb0 > [ 0.912077] ? syscall_exit_to_user_mode+0x97/0xc0 > [ 0.912538] ? do_syscall_64+0x94/0x170 > [ 0.912902] ? syscall_exit_to_user_mode+0x97/0xc0 > [ 0.913353] ? do_syscall_64+0x94/0x170 > [ 0.913709] ? clear_bhb_loop+0x45/0xa0 > [ 0.914071] ? clear_bhb_loop+0x45/0xa0 > [ 0.914428] ? clear_bhb_loop+0x45/0xa0 > [ 0.914767] entry_SYSCALL_64_after_hwframe+0x76/0x7e > [ 0.915089] RIP: 0033:0x7ffb713dc1fd > [ 0.915316] Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d e3 fa 0c 00 f7 d8 64 89 01 48 > [ 0.916491] RSP: 002b:00007ffffc4454a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 > [ 0.916964] RAX: ffffffffffffffda RBX: 000055f28c6a5420 RCX: 00007ffb713dc1fd > [ 0.917413] RDX: 0000000000000000 RSI: 000055f26c40cc03 RDI: 0000000000000003 > [ 0.917858] RBP: 00007ffffc445560 R08: 0000000000000001 R09: 00007ffffc4454f0 > [ 0.918302] R10: 0000000000000040 R11: 0000000000000246 R12: 000055f26c40cc03 > [ 0.918748] R13: 0000000000060000 R14: 000055f28c6a4b50 R15: 000055f28c6ac5b0 > [ 0.919211] > [ 0.919356] Modules linked in: crc32c_intel(+) > [ 0.919661] ---[ end trace 0000000000000000 ]--- > > I also see some other WARNs interleaved along the lines of > > [ 0.982759] no CFI hash found at: 0xffffffffc0608000 ffffffffc0608000 cc cc cc cc cc > [ 0.982767] WARNING: CPU: 5 PID: 170 at arch/x86/kernel/alternative.c:1204 __apply_fineibt+0xa6d/0xab0 > > The console appears to be a bit of a mess after that initial message. > > If there is any more information I can provide or patches I can test, I > am more than happy to do so. I've got similar report from kbuild bot a few days ago: https://lore.kernel.org/all/202410202257.b7edc376-lkp@intel.com I fixed fineibt handling in v7: https://lore.kernel.org/linux-mm/20241023162711.2579610-1-rppt@kernel.org > Cheers, > Nathan > -- Sincerely yours, Mike.