From patchwork Mon Jan 20 06:00:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 13944774 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 B46DCC02188 for ; Mon, 20 Jan 2025 06:00:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48A2C6B0085; Mon, 20 Jan 2025 01:00:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 413066B0088; Mon, 20 Jan 2025 01:00:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28CAF6B0089; Mon, 20 Jan 2025 01:00:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 075AD6B0085 for ; Mon, 20 Jan 2025 01:00:31 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7A3EF4A99E for ; Mon, 20 Jan 2025 06:00:30 +0000 (UTC) X-FDA: 83026780620.01.BF32B2F Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf30.hostedemail.com (Postfix) with ESMTP id 91D2C8000A for ; Mon, 20 Jan 2025 06:00:28 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=H7mQJE1m; spf=pass (imf30.hostedemail.com: domain of thehajime@gmail.com designates 209.85.216.41 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=1737352828; 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=ukyNfs65nuvgTdhSkdJYZ2Y9345NLuFCWN/gVQv/aLg=; b=K1QBHFuzW/Wbw5PcxwzlCmxfS4VRrhoTztzx2/mrLlvYd02WzNqBboXRvPdZb2ehSF3ezi D0i6CRCUo/XWWK9iJuCuekxqFPhcC8O5ZypxObWkeM2H/rvcgKk5FGG5Cbos/URf15L1OA nEEneOhS+iEZIc7HekzYu7C6RLBZByM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737352828; a=rsa-sha256; cv=none; b=2Y2QNXeawii6rRVQWIo484M9gVzP1e1oIzBN4qm4bb8MMXcIEabOLYCqeBaCGGLGxzAo76 YViS4l0EdI1h/tlgvKDmuqulZouO1tXtBmb+zUm2MA8+8H0cSnkP6kM2G//jrD7lllXrOG V8/qiihp8qCvzGnYmhYGqHxuSdg6occ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=H7mQJE1m; spf=pass (imf30.hostedemail.com: domain of thehajime@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=thehajime@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2ee786b3277so5200467a91.1 for ; Sun, 19 Jan 2025 22:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737352827; x=1737957627; 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=ukyNfs65nuvgTdhSkdJYZ2Y9345NLuFCWN/gVQv/aLg=; b=H7mQJE1mQF1T546uEjoORn0iYwCzuviIMlTrAKW3kX4hnkDLMVuDFzjtSwiGY7jegK K+bCtlO3tQkalTYQIhQie0d7+OjzfhZv5s98V6pRqG+7kCpS0x5BNSTrC7y4DIkYqYkc O3QgwOjzC1ZpSgUnDRZ30SubEeospCCi+5JlB4n8BcCj8lTqBQ76t8rhQuSJcJXp5JkK 2OZLa1IkSkmzeMCWO1T0cHroAqkd+hVDk3TwqFQWgf90DURfrHbFFJFuJYens+UB9xVF kMjfIEX4BWaGlqfbjbld6Ygm18NxDuctFaENadqP34Pfqkkk7dnm1ETO7Xy6W/kHM9EK 8fzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737352827; x=1737957627; 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=ukyNfs65nuvgTdhSkdJYZ2Y9345NLuFCWN/gVQv/aLg=; b=lWos8ZiNy5jU9L/ZckNaPFhzFmbH2WzrDXSbfHJ30LL3VE0HIb+QeAcrdkHSv8nE+y INvBmCg7wnrMP3Q3OizcPYgQ271M7JUlQydztrH2Mn+9/CfM548FFfCdA0IwNdc395U+ l3h0BmDshJ+VA3LL/7+afPPcqgMQoPN7fXhpsOiFAp9lMS2pSTt1JNzMLiieK8l8C+kl rvfG2AqxpDkywbRWbifDmwhacGx9+OBO8uE6PA3klgGIZW8MMW/x8kNl/a+x/DLW/vQs 5ha4NSa8JlbtGq6//YyHxpwLpFepxKy6W/hm0AEZWJLCIdUFjMkxJ84dImE2mgOSZGCJ EWdg== X-Forwarded-Encrypted: i=1; AJvYcCX//rDDkE/vmrIgwq6HYB7QSNcytmI3JTZdvHOrktUlDE3kWM1ynYlY2eBcHv625YSSJUz632/8YQ==@kvack.org X-Gm-Message-State: AOJu0Yzb22dPhT2VJ+VVmkEaV+yw7KxO8jJinAo16KXFAILauhBbKeIf o4bM9imzVD5JO9uEr3PCGin6KAqfMYXl++zbSCWV1/2K5zVS7uuf X-Gm-Gg: ASbGnctv0XWAQjSfiveXR84838iScZzZ14bYfGV5XSZDeWsRtLhUGkz4sn3Gdr3M87Z s2dBqZZ7sl1RwPEJA4300Lf78HUyGkLX+onlb35czqqGDcE9fgy9aT6Ajuz2Q+bL/Xxig0r3f5U NJd9C/fdh72SPVTFqlbd4nZ4NMFRbdV9JUmWa5qNfF8nB9UbzOnU/TwppW7UVUKukdYBSAa5hxH Tcq4X8v24CAt/Dr+5WwStNNDo2ePehdu70rygGcc2kLsLS5sUcTOXmbQxFIhtfaAozG639yis2/ ewV5knteOvjdtHTbSGFUU8OlNgjhDWno9pbuAUOTVQ== X-Google-Smtp-Source: AGHT+IEHeuTXy8q3JvsQ/TcxbAalRbkjb77Hq4RpM8tf7n3KtZQMqCH3X3otCgb8yHvy546rNESfFA== X-Received: by 2002:a05:6a00:4fcb:b0:727:99a8:cd31 with SMTP id d2e1a72fcca58-72daf97b5d3mr18400418b3a.14.1737352826972; Sun, 19 Jan 2025 22:00:26 -0800 (PST) Received: from ikb-h07-29-noble.in.iijlab.net ([202.214.97.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72dab9b9966sm6149948b3a.86.2025.01.19.22.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jan 2025 22:00:24 -0800 (PST) Received: by ikb-h07-29-noble.in.iijlab.net (Postfix, from userid 1010) id 8684EE27526; Mon, 20 Jan 2025 15:00:22 +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 v7 02/13] x86/um: nommu: elf loader for fdpic Date: Mon, 20 Jan 2025 15:00:04 +0900 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 91D2C8000A X-Stat-Signature: t6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W8GAC 8SWyjJOVKQA4aS4WozYQ+uEUqRFN9gt9f1isTrYb3OI6UiczoRQ1YrB3YQYXJ2n6hEOrufbE9PQyIk429Q555xNod1LRUZEVzZBr2xNldWJEtwPG0JpLZUVaqNJ8pPtCiWCIwVBI+y+oPR8o8nw5BF05W/alCadNeW7ekVw1FT1vXqQUPqUsrnqlnSYj2zFPd/S2o7mZuQY3cDszsFF76YNsZDx6Ip9n8GGDsS3RRG9zHT0NAzkeu3loIPuIsk4WrYhPpyXH1123uuvx/3A5w5DEbh8MumT4zRxxmX11FyfJk5PAu5HKTo1+3s102cYJ4cezeSAQc2SfQX3ShXly1yLk7oGoW98kPVnW1yv6M5SFSBnYflVXMlz11EMW172ku1Bu/Lag0Pq67h13sZyMlaw8CPPHA1XHrFU4dAChe5XeZ3NWxvuxqx6II5F+OQ5uB2kNbggzmKYuQ7k4egDhXu8oWENmsm8KUVD6+m7w2X83g5SmIHnYDFec98bQm0uAmZh1YCRCJHf/SpjdqCOGNU7uq2jTkaAPTNHFxE1BGYGz/vUtl/AlKZthBVgWvRwNbyS228CTOHlxbHoGw1yRn80L2S58lw25o6CzY 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: 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 Acked-by: Kees Cook 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