From patchwork Sun Dec 8 10:15:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 13898526 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 21DB4E77173 for ; Sun, 8 Dec 2024 10:16:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 430336B0377; Sun, 8 Dec 2024 05:16:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3DD266B0378; Sun, 8 Dec 2024 05:16:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27FAC6B0379; Sun, 8 Dec 2024 05:16:03 -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 08F196B0377 for ; Sun, 8 Dec 2024 05:16:03 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 49F858054D for ; Sun, 8 Dec 2024 10:16:02 +0000 (UTC) X-FDA: 82871385408.06.1981FEA Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf09.hostedemail.com (Postfix) with ESMTP id 6FAF0140005 for ; Sun, 8 Dec 2024 10:15:43 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=O7E1Lvh5; spf=pass (imf09.hostedemail.com: domain of thehajime@gmail.com designates 209.85.214.174 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=1733652947; 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=ad6tqlkSsXxixjDmAohrGr+9bkt9HIbloV0j26+4YVKlysYNE8BE2HUHjh742zY/TcZJyB /uiJMb0muHP5LbNAAk4i/he87OoPQkVh90Yk88P4/u2xYS9EelC+6VbjG7+cgS2oMsWKXM 9+9kLwjlOzYZ8KSZG5am/hMCFG2DD34= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=O7E1Lvh5; spf=pass (imf09.hostedemail.com: domain of thehajime@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=thehajime@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733652947; a=rsa-sha256; cv=none; b=Zsw/i2IG/U9Vc4Fam6gwtLDc7iuDWPx0+iIieJ6DdYSRto8yON7iLrIotBh8MLjVBamFpP txYJHc2CZ48u0qwAeeawkI/gtPxUH94sQou9hxgkZViEexKtYwvSmAniyvzdMPoJ2vtzhy PFujcxie99edEXPPXg0zekLYd2hySIQ= Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-20cf3e36a76so29480055ad.0 for ; Sun, 08 Dec 2024 02:15:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733652955; x=1734257755; 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=O7E1Lvh5QLndLv48WKKKBZSnAEzvW5FtLY6j4kDu2G/K9lqUex/8Ob+5cbjCKblAVK YfPW2y4YMYMz3IIy3+kZHQ1neiV4+keFku2/QCQpy+Q/rlXRb6DHj6oH5vjBzUnVWZjM rcT/QW4hf9EeMt2AZAGH9r+Twj7ieeQSg+bfm9WmROgZKw+AbKIaw6yap/AHlGzhDuf6 BjFt0vTVfv0sLx14tbPOPrHfqBwej4a6KBbRoronnrRvleTCNL0OZiUGdkg4cFEWRlKN cvGTpuEPvBkP5SNWcM86LEke0zs3Sc2tPHvZSAAr49V+vca190EPOAhZWH7Kl19/rlAR xU9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733652955; x=1734257755; 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=ozwt2k78Fa4xmjmq1HDe/djjYVGRxyN7i+u2hoAUX3UIpN9fupSovYUkuLJrD6hADh VWbbcjeog6bgw/s6/FUgeASyLwv6Ydm49mEL8DqSU8DRTOHOPCbsylI531t8mhwIwUzr KyVZ0TaFK8A/hl78T6zJHYQmwDv954if0ZP3cnlDjzTRLSBZrS4SzMFabePlfoBQUQck Kv1f4iC9oTur2j9YK+SGYHehqxXYm20ipcFV3I7qF+EZ0SwOOW2oY3kjpz/jjKvAwgOK eOTDUfaOMRSSWZluLK4BwK/sEeWeuZ97PgpLo96VhWGpflR4nJu22DNu2vZWUp1bUQV2 yYBA== X-Forwarded-Encrypted: i=1; AJvYcCU0RgIoIXBZg4T223Fm/Nm2RaDRb7c7DZB02RcfWL7j+kaMGtMGzPQa/ZiHIXx2MVco+HBqm6teGQ==@kvack.org X-Gm-Message-State: AOJu0YxkY+ce4eVfTfbVBJfEsW8wwXmAvIu1fgZ1eS9ma6710TwW8VNV JcejKx4NktwFAZc/GMktUVc2tcT4Mgx9zBxOdIbuU5RA2vk9v9q+ X-Gm-Gg: ASbGncvoS5FrkssNX+2rQ9safjAPtAlo+BTG0J1IkmbyhxTPXkqdgtWys50QS02Yh05 rjLuFmb3xksMVM/TjEtbo5dNBdrsOYEG4aaJh2+RMJM9VoI+1SCNpJsLQmVeRmZFbsClJzf+38h vctdULtFjdcGVXl3iL9VlfuRQuHOeyb6o7LULKSvLKV3/JzuGvXNkYu4EnUZkbnJtAJqEn4ZLbT Q/JZ9Hajb6LQnGt3M4vhLrmnPqz+IR3gO5Dq1FTyeJ9e66Reg55BSEuoPvQ24OwvCqPcXTlUvjx 7xL5d+riL3KMAk1M3IW4 X-Google-Smtp-Source: AGHT+IFQct9SApUaLux90fR0aNxlzm2wMoioHTPd27lhStCGrHuRbObEG0AcO2vIjjIL4fIUoZbNUg== X-Received: by 2002:a17:902:f54d:b0:215:5bd8:9f7b with SMTP id d9443c01a7336-21614d456b1mr116100605ad.15.1733652955174; Sun, 08 Dec 2024 02:15:55 -0800 (PST) Received: from ikb-h07-29-noble.in.iijlab.net ([202.214.97.5]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215f8ef9ee4sm54638735ad.161.2024.12.08.02.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 02:15:54 -0800 (PST) Received: by ikb-h07-29-noble.in.iijlab.net (Postfix, from userid 1010) id 17ADBDDB022; Sun, 8 Dec 2024 19:15:53 +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 v4 02/13] x86/um: nommu: elf loader for fdpic Date: Sun, 8 Dec 2024 19:15:29 +0900 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 6FAF0140005 X-Stat-Signature: wi8h7otgamuwqfkz5dk9cya1hwp7e66f X-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+bWYN9HNVAbsU4FKA0hgKt/j+XFE6MMq+SLDgxJ1690ZcXMU925FEXKmVlxyVACqNy8MU2rG6Dn/rcSOh3Rhs408Fb0ZNEC0FKZwXvdE76s3HItkBe/TjgRupRWPwWuaH28VMV2ZDvpoVTPe0GTjkTNn2ZKu6mGyBDYC5EvS30YdJlnXVYKQl1OoLY4FQ0LbTcnDz6z7tn3BYYo+rkcvyUtr0PrVG/D28hEaZztfoC6a52NukLYNS0NDpmYerT8ctM/sLS4sqgLeUqQpUvAntS8GNvl+nG0eY8Ns8T+wbNflQlp0ahygyrLN2Me3FJG94mBHyq91tITuBjUoAjcm4rXGcPw6cVbJn111QGGth35lOi5ZFBc2qtjgIcNVB6q/qkhkg5e5XQc/6yIgJt9olkr9VPiAzEU+hx8M/83t8b9lQr8DZTCsXYeLCidq0G/3OCebElOvs/JdUtmzuggQm1f00X8iD6h5IhE9P5o2SNIva/FVWF/ogHXqmuw1+tAMlCCBgfk8T4aqoBmib50luWv16M3nZI6R+DGSUvUbj3VMnTeXhpX35PUGjguFASK8M X-Bogosity: Ham, tests=bogofilter, spamicity=0.000019, 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