From patchwork Thu Dec 12 10:12:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 13904950 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 64455E7717F for ; Thu, 12 Dec 2024 10:14:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E45C66B0088; Thu, 12 Dec 2024 05:14:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DCE326B0089; Thu, 12 Dec 2024 05:14:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C48386B008A; Thu, 12 Dec 2024 05:14:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9E3386B0088 for ; Thu, 12 Dec 2024 05:14:18 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 235C4AEF55 for ; Thu, 12 Dec 2024 10:14:18 +0000 (UTC) X-FDA: 82885896534.04.B416FAA Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by imf15.hostedemail.com (Postfix) with ESMTP id 332D3A000F for ; Thu, 12 Dec 2024 10:13:47 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DhiX9bqF; spf=pass (imf15.hostedemail.com: domain of thehajime@gmail.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=thehajime@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733998444; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=imtbBrBEkPVKtbCA/xxwe0ZEaWgNsfGZobwNJy/U71E=; b=XQd0EulyDre9ccqQAPjyMuuxxuUVlJi4xrnTYb/XrQyTqobLUYmX1auzqdOXyzTeZEBRKJ c0MRRT2Is74gi5CMgdPetbhKdrlc9kXuWoXvhBFyKc0rV1kOJAmpu9QxC3H3RI2GJ2ILVb g5Oog4a7V4juU+o50/DN1/6gpnrxYmI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733998444; a=rsa-sha256; cv=none; b=GWga1vh2vrCG0d8fU0goFfNxobNWdl0Tw5+dU4KONSUMVabFUuzQWCkABTy82uVRsuZ840 EqQnGtX1a4kjaQQG2d3mjlbHzw5euAcP/Aq3+Q3KmM/N/vxmYLctpm/jsSGHZG1DMIrB6o 9G6DZaQAmFauIq4qHOVNQn0G/v1rIik= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DhiX9bqF; spf=pass (imf15.hostedemail.com: domain of thehajime@gmail.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=thehajime@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-7fd10cd5b1aso346820a12.2 for ; Thu, 12 Dec 2024 02:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733998455; x=1734603255; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=imtbBrBEkPVKtbCA/xxwe0ZEaWgNsfGZobwNJy/U71E=; b=DhiX9bqFWUOQzHrhWNHc0vsiJr/nlnLjfBDECujT0n9Bv/DutZBgZPdDISEDGVga3K cOdT3MmCMHLISgUKM0m77bQj9R+REa87qtJ2+AFSPDpcNdax6ZVvEkYWcrgt2wgmTejQ QgmDFfk3NOX+zZA8PVL9E9U820G5E0Y7O4wCMdP3I3Z7vslg35Nc30EHWkiCJxjJiAvB IqREDSqtalbnPH+XnhoYsLf+PrjnKggTY+WnytysO/XgEjrQdDQ6Fk1BWsNPaELRBd4j hYcNhBKk5UBtQPCGwDVt6V0Y6js7ZxXvkPPEhpjRzEKJFNslrNCnq5XpTkV8uBaHOxj3 NGvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733998455; x=1734603255; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=imtbBrBEkPVKtbCA/xxwe0ZEaWgNsfGZobwNJy/U71E=; b=qtMNnSoOkMB/0ZEobfhoD0F/Ek/iR/jZH2JcnI3JPr+3qvx7vIgQqzrkVlsecd0sZc GV2olbsef6YDrqoqy5F6EBIZ1nuVKJVJlS9C1PR08vXi5ypecvoYqFXY2XlY8lfn7BFt UsoZ18UzPIBe2d1Pox/V0XCdn0yLBcBl+w4+L6yealP0ArMxFjkAXtnTGxyAiqeukIDS aaS9OhLJko8n3IPI37dlo56rc/eX2E092TQ720bucb1gLIo9Q1yDPgSnvCsgpC+oDZ8v c0J8rH+9is38gq9dn/2tTlQu58+3XgBHgJdzypXfeuVN0KOGwujf4/vkMrSBkJ6zN6cb BEWQ== X-Forwarded-Encrypted: i=1; AJvYcCVRBqz0BBBK41oDmF/s5SCXsoNn7TbBFuTIQB9yOPu0xtDiEr7gpkHRPNorbfNF6kZ5CAeIf+bQ1g==@kvack.org X-Gm-Message-State: AOJu0YyltcafUsH25nm4DUFiZb2JHmyWL7MILuwH8i2/fScFj4ZBJu9e 6C89y9lIbv1W/ZhKDVLvLST5FxXujowkyb0nksrkrklhvZqoZjDt X-Gm-Gg: ASbGncu0yjNVKMAFkDJ+8MFX9dshzPUYrPyq7ibtgTMhBjpO3rnECWT0zc+PtHFHtNv tyjqTWgFpt+DbMFkX2PnT0iZ6pQ0GyvyKTzUzdCl+ffSOxSyT0Nb9Ua8tS+QwPW7WwBttu08vLC 5e5KYvxBVnIBVMYPIVWXzw8LywXQRc2T8HlGK/UBwOS3DpZXHOSCa7G5KXPFLTmAF3OoceNkvtp bxRbPzXtsmqlsg317eKr0GF5IQQtbrKnAxd+tPbdnfFPTSmvf5hfKIus5izCvf5ww/GEVF6xUJb DwlEgyGdr51jhPPi9c7STeU9qio= X-Google-Smtp-Source: AGHT+IFVhbe01ozM68JjhYH4Ulu2767FV6uMDBATKo9A5IIcvIgwdzomTiXfbfiCL1mxVboFbfpF4Q== X-Received: by 2002:a05:6a21:398f:b0:1e1:b12e:edb8 with SMTP id adf61e73a8af0-1e1cebb7f15mr4365029637.30.1733998454879; Thu, 12 Dec 2024 02:14:14 -0800 (PST) Received: from ikb-h07-29-noble.in.iijlab.net ([202.214.97.5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd3e2d63fbsm8473250a12.6.2024.12.12.02.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 02:14:14 -0800 (PST) Received: by ikb-h07-29-noble.in.iijlab.net (Postfix, from userid 1010) id 2DA5FDDEEC0; Thu, 12 Dec 2024 19:14:12 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org Cc: thehajime@gmail.com, ricarkol@google.com, Liam.Howlett@oracle.com, Eric Biederman , Kees Cook , Alexander Viro , Christian Brauner , Jan Kara , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v5 02/13] x86/um: nommu: elf loader for fdpic Date: Thu, 12 Dec 2024 19:12:09 +0900 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 332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YUMn92+V2oyhhijBPNItEEKJxvCbvhD6risHYWtIpUaXOK+Ui/EcEmHqewSvAdCKfY0qp23cFTwDB/XbT164wAb7HAha57Rr+hrCKMOLN+ijaLPb8UIqAogwXhNikz8bG/XPM+Wb6oYY0CCkdZFDGCZOog7lniNJ7q4+j3EOSROe1/vI8HOcbd+7cYTe1/YUT+Ug48TxoHBCoFEWXVGdO7ipWE4qK237rnbRjGgqaPVnObTdQrU9TJE0mMPA2jLPHKKUA+37rpUTuYe+8Tad9Z7TIF4zYVgTNLUeR/f1Td5Vk4nvi4NclYxaQoPzH/aH/zdm9NvS9dXnKXxLT99L6LskjzdJ4UKt/4+nonrjyp3dAJRTQiIoi+OA8MHs+rDffPJyegzkzeHqPUZT4w1Grz6sa2DX0c7nRJxjtguRF6RPKE7TFgH79i9RazWhtxVOxRL+7V2DOCMnCDeGrmwFejjBSUTNSP+WV2DYd5eddMii3MY9/DubDMaEe/EXVVHYAV1zjPJCttQwqcfS6EfLXu0+5xe4WQhYKXaz85SQ3gSPOSWykoGxmBUzpmXhuv9jbiMhy6zcbt4ZmRabZ/tY82gu2MX2ar3e X-Bogosity: Ham, tests=bogofilter, spamicity=0.005115, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: As UML supports CONFIG_MMU=n case, it has to use an alternate ELF loader, FDPIC ELF loader. In this commit, we added necessary definitions in the arch, as UML has not been used so far. It also updates Kconfig file to use BINFMT_ELF_FDPIC under !MMU environment. Cc: Eric Biederman Cc: Kees Cook Cc: Alexander Viro Cc: Christian Brauner Cc: Jan Kara Cc: linux-mm@kvack.org Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Hajime Tazaki Signed-off-by: Ricardo Koller --- arch/um/include/asm/mmu.h | 5 +++++ arch/um/include/asm/ptrace-generic.h | 6 ++++++ arch/x86/um/asm/elf.h | 8 ++++++-- fs/Kconfig.binfmt | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/arch/um/include/asm/mmu.h b/arch/um/include/asm/mmu.h index a3eaca41ff61..01422b761aa0 100644 --- a/arch/um/include/asm/mmu.h +++ b/arch/um/include/asm/mmu.h @@ -14,6 +14,11 @@ typedef struct mm_context { /* Address range in need of a TLB sync */ unsigned long sync_tlb_range_from; unsigned long sync_tlb_range_to; + +#ifdef CONFIG_BINFMT_ELF_FDPIC + unsigned long exec_fdpic_loadmap; + unsigned long interp_fdpic_loadmap; +#endif } mm_context_t; #endif diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h index 4696f24d1492..4ff844bcb1cd 100644 --- a/arch/um/include/asm/ptrace-generic.h +++ b/arch/um/include/asm/ptrace-generic.h @@ -29,6 +29,12 @@ struct pt_regs { #define PTRACE_OLDSETOPTIONS 21 +#ifdef CONFIG_BINFMT_ELF_FDPIC +#define PTRACE_GETFDPIC 31 +#define PTRACE_GETFDPIC_EXEC 0 +#define PTRACE_GETFDPIC_INTERP 1 +#endif + struct task_struct; extern long subarch_ptrace(struct task_struct *child, long request, diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h index 62ed5d68a978..33f69f1eac10 100644 --- a/arch/x86/um/asm/elf.h +++ b/arch/x86/um/asm/elf.h @@ -9,6 +9,7 @@ #include #define CORE_DUMP_USE_REGSET +#define ELF_FDPIC_CORE_EFLAGS 0 #ifdef CONFIG_X86_32 @@ -190,8 +191,11 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, extern unsigned long um_vdso_addr; #define AT_SYSINFO_EHDR 33 -#define ARCH_DLINFO NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr) - +#define ARCH_DLINFO \ +do { \ + NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr); \ + NEW_AUX_ENT(AT_MINSIGSTKSZ, 0); \ +} while (0) #endif typedef unsigned long elf_greg_t; diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index bd2f530e5740..419ba0282806 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -58,7 +58,7 @@ config ARCH_USE_GNU_PROPERTY config BINFMT_ELF_FDPIC bool "Kernel support for FDPIC ELF binaries" default y if !BINFMT_ELF - depends on ARM || ((M68K || RISCV || SUPERH || XTENSA) && !MMU) + depends on ARM || ((M68K || RISCV || SUPERH || UML || XTENSA) && !MMU) select ELFCORE help ELF FDPIC binaries are based on ELF, but allow the individual load