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 0CE3BD1CA11 for ; Tue, 5 Nov 2024 07:02:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63DB76B008C; Tue, 5 Nov 2024 02:02:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ED0E6B0093; Tue, 5 Nov 2024 02:02:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B5316B0098; Tue, 5 Nov 2024 02:02:58 -0500 (EST) 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 2DF1A6B008C for ; Tue, 5 Nov 2024 02:02:58 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7E664A0FC0 for ; Tue, 5 Nov 2024 07:02:57 +0000 (UTC) X-FDA: 82751148564.04.48A3A51 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf01.hostedemail.com (Postfix) with ESMTP id 30EC140007 for ; Tue, 5 Nov 2024 07:02:29 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=i3dpbmwH; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 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=1730789992; 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=hDoiW9FoXeBueu7rvRElcbTxwRRFVCkHCMlNMIMFTMg=; b=8OWH4aqjZJvEbT81nJ6B5bF9OWj64iQyhUoH6KJ5c9fozNQjsAaA1pPkS0BLuF3YB2ZEaH oDlVVGGEE9JF4sdRfnOUHjZR+xHEHA7Ai2ET61YJFGiMibutYAa00yvpwuuiyR8AyannDg LwSrwUuL6oCoWI+yWudhSOOAtu8ScA4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=i3dpbmwH; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 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=1730789992; a=rsa-sha256; cv=none; b=1FJaSVHzsyTEiLEp6JCoHhzvQWQo3NfErE1uxd5WuHB2BufyPI2ZRJNpYErhvMwv17jbEh xHVv74Yx2ctbxtqaLytMj9JJA6knkgdEgs0R6eVnYtmJR3YOHMdStZ4dKJy24wqeY+4qFI S/bcRXQNaSTz0fG2mukIWtwr8rYLBT4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id DE148A42167; Tue, 5 Nov 2024 07:00:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4B12C4CECF; Tue, 5 Nov 2024 07:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730790174; bh=vfcX72EWl1PlKyFBzjhHz5V71yaLAfzK3VjVgomZL4Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i3dpbmwHLfd+qUmJoaWeTGPHb10DC+M0kf+DMEykGWoYpGOuSUDviaUCAAx4zIAfi my4z1l/oyVoPrY5WEhvGAqrSv0MLPuXbzVIKUoMd0jh8oEVUCEONnRV4s7PDepCIp9 ZD54y4ohFGVDY1Cs7nPdmpyfCNtvqUqW5KJ/Ch+xipF5ZFMCAivKT3JR6Xd9V1a/4G LvZ1wHQ1rlIUNyplCl+fPkOtsT/XeAFLJAPXe+EdvajpWUHCrgFIHiD89oCp0/Bkx4 xYtH7/sknC5+POJtdvm/YMmFy0WRYObll2kMIURKDi3pF/30ytxQP7HSq81EZrmTXO namiYtOl86+Aw== Date: Tue, 5 Nov 2024 09:02:26 +0200 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 v7 6/8] x86/module: prepare module loading for ROX allocations of text Message-ID: References: <20241023162711.2579610-1-rppt@kernel.org> <20241023162711.2579610-7-rppt@kernel.org> <20241104232741.GA3843610@thelio-3990X> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241104232741.GA3843610@thelio-3990X> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 30EC140007 X-Stat-Signature: jrppq5qh3k4sdx8gnk19tnmxgzgj7ptz X-Rspam-User: X-HE-Tag: 1730790149-290457 X-HE-Meta: U2FsdGVkX1/raBKSWqXcIkSz3JwaOKollYw5eR2TTDLNgOt9DTnaEljqA04G90hlPImu+uGrOlPcHgUhjkIpBvacK6jlFEBO1GFrywQcO8gT55rVijU5nvrCDW6PzBwxa1EOdX+Jr5QiBRBLEIE80ZlEioq8GP/WJYcvGXdMNRtZfmm7PwnZ4nt5HsOayLWpglTt1YvV05E95jgiMg+xqHokg0ynsRPH68eD4g1pvN+vbM6FQRGcrVY7zZzvBgBCpo/sDs9l/YKFSLniTnPVcjU1lkpBDxbLINSwBnfTAm0PO9d7LwAsXnb2D+Z64clLF1iHJo5kPlg0LgV/s4/mwt7KwAEWCWZMwzv39Gb/uzqGXjHZr3bRWx7R8YKaR6z+UZnzKykBMB2M+P/lD3W+P1SRUinxrL4Y7r7LuaXGMYvhpKSFgel/HP1ehzL5fqd/DIc+fXM70fstaVmJgftVlDxX/iSXMT6reb+WQljwDc8hVa5EOF3UUTwuIZuQFB89/H9slEZX5DObk+krt2t1ynSk5R+gQbw4qV4vQa7gAkrPzy304yO+Y7RgJmNTLnbxweYq7itL7nvq4oCdQoR0FDZQH387FqxkY4RQVCMNBNDK3UWJWxf7yoRM7mMO5DWPyzuaSJ6oeNnvRmNBuE2zYjSD6jSoTbgMC8vCdHM2jh5hUiUF6XXnlQvA3pR0Z5XD9ibH1bwrQZZO0STTF07v8qBCmxZuNlptmgZQojtWnn9lRUHssEOzZ/I76oPC+AeV6cBye9r0OPAx6qQ/ag7g0pp21qHd7QQOyT7P/857kF7yk+8qj4R3ylxiQZ8kzRpeK8VePDHrUt60dwq03EyQTSE2VNdHqKwQRNuDnZTZuq8H3hMtaWRVX6mIAH9dtoF2dQ2JCdf74XR6h0b7QV24VwCUZdPcnS/wXFky6HL++aJb8H4i++OjteRHKBf0VRnXe85uZfWBuEDf6at40Q+ ZpLrhC3g 1pUAak4HDhorBoDhc0NZqlzRvs411Pummcm/GNGOjp/JXKym4xyC04urxk4TH6z/gfE+pn9X2SclyCGkydRkShQxvfavKhf/Lgz5GlwmItdtf9pzvyv4ulJFQECsdyo4+S95wKJ6nSbktcibATZkxASWrK2C4l1u1nvYagbXO74RCi340ybFNYpace1q31YWsyf+zLpG41XN7oyETQVbw5zYU0qjDS5VJNgSP9XsSUO3aF1Fd+c1Hto1MWk1QfSKXkP00cgbVArG1JoL5zNqsl6WScsF7gzSSn7+vKWcafAipi6fvCIgW5+u2LQ== 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, Nov 04, 2024 at 04:27:41PM -0700, Nathan Chancellor wrote: > Hi Mike, > > On Wed, Oct 23, 2024 at 07:27:09PM +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) > > Tested-by: kdevops > > Hopefully the last time you have to hear from me, as I am only > experiencing issues with only one of my test machines at this point and > it is my only machine that supports IBT, so it seems to point to > something specific with the IBT part of the FineIBT support. I notice > either a boot hang or an almost immediate reboot (triple fault?). I > guess this is how I missed reporting this earlier, as my machine was > falling back to the default distribution kernel after the restart and I > did not notice I was not actually testing a -next kernel. > > Checking out the version of this change that is in next-20241104, commit > 7ca6ed09db62 ("x86/module: prepare module loading for ROX allocations of > text"), it boots with either 'cfi=off' or 'cfi=kcfi' but it exhibits the > issues noted above with 'cfi=fineibt'. At the immediate parent, commit > b575d981092f ("arch: introduce set_direct_map_valid_noflush()"), all > three combinations boot fine. > > $ uname -r; tr ' ' '\n' > 6.12.0-rc5-debug-00214-g7ca6ed09db62 > cfi=kcfi > > 6.12.0-rc5-debug-00214-g7ca6ed09db62 > cfi=off > > 6.12.0-rc5-debug-00213-gb575d981092f > cfi=fineibt > > 6.12.0-rc5-debug-00213-gb575d981092f > cfi=kcfi > > 6.12.0-rc5-debug-00213-gb575d981092f > cfi=off > > I do not think this machine has an accessible serial port and I do not > think IBT virtualization is supported via either KVM or TCG in QEMU, so > I am not sure how to get more information about what is going on here. I > wanted to try reverting these changes on top of next-20241104 but there > was a non-trivial conflict in mm/execmem.c due to some changes on top, > so I just tested in the mm history. > > If there is any other information I can provide or patches I can test, I > am more than happy to do so. Yes, please :) There's a silly mistake in cfi_rewrite_endbr() in that commit, the patch below should fix it. Can you please test? diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 3407efc26528..243843e44e89 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -1241,7 +1241,7 @@ static void cfi_rewrite_endbr(s32 *start, s32 *end, struct module *mod) void *addr = (void *)s + *s; void *wr_addr = module_writable_address(mod, addr); - poison_endbr(addr+16, wr_addr, false); + poison_endbr(addr + 16, wr_addr + 16, false); } } > Cheers, > Nathan -- Sincerely yours, Mike.