linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v7 02/13] x86/um: nommu: elf loader for fdpic
       [not found] <cover.1737348399.git.thehajime@gmail.com>
@ 2025-01-20  6:00 ` Hajime Tazaki
  2025-04-25 13:49 ` [PATCH v7 00/13] nommu UML Lorenzo Stoakes
  1 sibling, 0 replies; 6+ messages in thread
From: Hajime Tazaki @ 2025-01-20  6:00 UTC (permalink / raw)
  To: linux-um
  Cc: thehajime, ricarkol, Liam.Howlett, Eric Biederman, Kees Cook,
	Alexander Viro, Christian Brauner, Jan Kara, linux-mm,
	linux-fsdevel

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 <ebiederm@xmission.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: linux-mm@kvack.org
Cc: linux-fsdevel@vger.kernel.org
Acked-by: Kees Cook <kees@kernel.org>
Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
Signed-off-by: Ricardo Koller <ricarkol@google.com>
---
 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 <skas.h>
 
 #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
-- 
2.43.0



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v7 00/13] nommu UML
       [not found] <cover.1737348399.git.thehajime@gmail.com>
  2025-01-20  6:00 ` [PATCH v7 02/13] x86/um: nommu: elf loader for fdpic Hajime Tazaki
@ 2025-04-25 13:49 ` Lorenzo Stoakes
  2025-04-27  3:49   ` Hajime Tazaki
  1 sibling, 1 reply; 6+ messages in thread
From: Lorenzo Stoakes @ 2025-04-25 13:49 UTC (permalink / raw)
  To: Hajime Tazaki
  Cc: linux-um, ricarkol, Liam.Howlett, Richard Weinberger,
	Anton Ivanov, Johannes Berg, linux-mm, linux-kernel

+cc current UML maintainers as per- current MAINTAINERS file, mm + kernel
lists.

Hi,

It seemed this series died, which is a pity, i'd be very useful to have
this functionality to aid in easily testing nommu in mm code.

I know that I pushed back a little (or rather - wondering about the status
of nommu in general) back in v2, however with it confirmed that nommu is
required, this series becomes really quite important.

This would need rebasing of course for a v8, but I wonder if there is any
appetite for it or why this didn't go anywhere?

In any case, if you are still interested in this Hajime (thanks so much for
all your hard work on it!), just saying there are definitely users out
there.

Thanks, Lorenzo

On Mon, Jan 20, 2025 at 03:00:02PM +0900, Hajime Tazaki wrote:
> This patchset is another spin of nommu mode addition to UML.  It doesn't
> change a lot since the last version (v5), but contain clean ups.  It would
> be nice to hear about your opinions on that.
>
> There are still several limitations/issues which we already found;
> here is the list of those issues.
>
> - memory mapped by loadable modules are not distinguished from
>   userspace memory.
>
> -- Hajime
>
> v7:
> - properly handle FP register upon signal delivery [10/13]
> - update benchmark result with new FP register handling [12/13]
> - fix arch_has_single_step() for !MMU case [07/13]
> - revert stack alignment as it is in uml/fixes tree [10/13]
>
> v6:
> - rebase to the latest uml/next tree
> - more clean up on mmu/nommu for signal handling [10/13]
> - rename functions of mcontext routines [06,10/13]
> - added Acked-by tag for binfmt_elf_fdpic [02/13]
> - https://lore.kernel.org/linux-um/cover.1736853925.git.thehajime@gmail.com/
>
> v5:
> - clean up stack manipulation code [05,06,07,10/13]
> - https://lore.kernel.org/linux-um/cover.1733998168.git.thehajime@gmail.com/
>
> v4:
> - add arch/um/nommu, arch/x86/um/nommu to contain !MMU specific codes
> - remove zpoline patch
> - drop binfmt_elf_fdpic patch
> - reduce ifndef CONFIG_MMU if possible
> - split to elf header cleanup patch [01/13]
> - fix kernel test robot warnings [06/13]
> - fix coding styles [07/13]
> - move task_top_of_stack definition [05/13]
> - https://lore.kernel.org/linux-um/cover.1733652929.git.thehajime@gmail.com/
>
> v3:
> - https://lore.kernel.org/linux-um/cover.1733199769.git.thehajime@gmail.com/
> - add seccomp-based syscall hook in addition to zpoline [06/13]
> - remove RFC, add a line to MAINTAINERS file
> - fix kernel test robot warnings [02/13,08/13,10/13]
> - add base-commit tag to cover letter
> - pull the latest uml/next
> - clean up SIGSEGV handling [10/13]
> - detect fsgsbase availability with elf aux vector [08/13]
> - simplify vdso code with macros [09/13]
>
> RFC v2:
> - https://lore.kernel.org/linux-um/cover.1731290567.git.thehajime@gmail.com/
> - base branch is now uml/linux.git instead of torvalds/linux.git.
> - reorganize the patch series to clean up
> - fixed various coding styles issues
> - clean up exec code path [07/13]
> - fixed the crash/SIGSEGV case on userspace programs [10/13]
> - add seccomp filter to limit syscall caller address [06/13]
> - detect fsgsbase availability with sigsetjmp/siglongjmp [08/13]
> - removes unrelated changes
> - removes unneeded ifndef CONFIG_MMU
> - convert UML_CONFIG_MMU to CONFIG_MMU as using uml/linux.git
> - proposed a patch of maple-tree issue (resolving a limitation in RFC v1)
>   https://lore.kernel.org/linux-mm/20241108222834.3625217-1-thehajime@gmail.com/
>
> RFC:
> - https://lore.kernel.org/linux-um/cover.1729770373.git.thehajime@gmail.com/
>
> Hajime Tazaki (13):
>   x86/um: clean up elf specific definitions
>   x86/um: nommu: elf loader for fdpic
>   um: decouple MMU specific code from the common part
>   um: nommu: memory handling
>   x86/um: nommu: syscall handling
>   um: nommu: seccomp syscalls hook
>   x86/um: nommu: process/thread handling
>   um: nommu: configure fs register on host syscall invocation
>   x86/um/vdso: nommu: vdso memory update
>   x86/um: nommu: signal handling
>   um: change machine name for uname output
>   um: nommu: add documentation of nommu UML
>   um: nommu: plug nommu code into build system
>
>  Documentation/virt/uml/nommu-uml.rst    | 177 ++++++++++++++++++++++
>  MAINTAINERS                             |   1 +
>  arch/um/Kconfig                         |  14 +-
>  arch/um/Makefile                        |  10 ++
>  arch/um/configs/x86_64_nommu_defconfig  |  64 ++++++++
>  arch/um/include/asm/Kbuild              |   1 +
>  arch/um/include/asm/futex.h             |   4 +
>  arch/um/include/asm/mmu.h               |   8 +
>  arch/um/include/asm/mmu_context.h       |   2 +
>  arch/um/include/asm/ptrace-generic.h    |   8 +-
>  arch/um/include/asm/uaccess.h           |   7 +-
>  arch/um/include/shared/kern_util.h      |  12 ++
>  arch/um/include/shared/os.h             |  16 ++
>  arch/um/kernel/Makefile                 |   5 +-
>  arch/um/kernel/mem-pgtable.c            |  55 +++++++
>  arch/um/kernel/mem.c                    |  39 +----
>  arch/um/kernel/process.c                |  25 ++++
>  arch/um/kernel/skas/process.c           |  27 ----
>  arch/um/kernel/um_arch.c                |   3 +
>  arch/um/nommu/Makefile                  |   3 +
>  arch/um/nommu/os-Linux/Makefile         |   7 +
>  arch/um/nommu/os-Linux/signal.c         |  28 ++++
>  arch/um/nommu/trap.c                    | 188 ++++++++++++++++++++++++
>  arch/um/os-Linux/Makefile               |   8 +-
>  arch/um/os-Linux/internal.h             |   5 +
>  arch/um/os-Linux/mem.c                  |   4 +
>  arch/um/os-Linux/process.c              | 149 ++++++++++++++++++-
>  arch/um/os-Linux/seccomp.c              |  87 +++++++++++
>  arch/um/os-Linux/signal.c               |  31 +++-
>  arch/um/os-Linux/skas/process.c         | 132 -----------------
>  arch/um/os-Linux/start_up.c             |  20 +++
>  arch/um/os-Linux/util.c                 |   3 +-
>  arch/x86/um/Makefile                    |   7 +-
>  arch/x86/um/asm/elf.h                   |   8 +-
>  arch/x86/um/asm/module.h                |  24 ---
>  arch/x86/um/nommu/Makefile              |   8 +
>  arch/x86/um/nommu/do_syscall_64.c       |  80 ++++++++++
>  arch/x86/um/nommu/entry_64.S            | 113 ++++++++++++++
>  arch/x86/um/nommu/os-Linux/Makefile     |   6 +
>  arch/x86/um/nommu/os-Linux/mcontext.c   |  24 +++
>  arch/x86/um/nommu/syscalls.h            |  16 ++
>  arch/x86/um/nommu/syscalls_64.c         | 115 +++++++++++++++
>  arch/x86/um/shared/sysdep/mcontext.h    |   4 +
>  arch/x86/um/shared/sysdep/ptrace.h      |   2 +-
>  arch/x86/um/shared/sysdep/syscalls_64.h |   6 +
>  arch/x86/um/vdso/vma.c                  |  17 ++-
>  fs/Kconfig.binfmt                       |   2 +-
>  47 files changed, 1329 insertions(+), 246 deletions(-)
>  create mode 100644 Documentation/virt/uml/nommu-uml.rst
>  create mode 100644 arch/um/configs/x86_64_nommu_defconfig
>  create mode 100644 arch/um/kernel/mem-pgtable.c
>  create mode 100644 arch/um/nommu/Makefile
>  create mode 100644 arch/um/nommu/os-Linux/Makefile
>  create mode 100644 arch/um/nommu/os-Linux/signal.c
>  create mode 100644 arch/um/nommu/trap.c
>  create mode 100644 arch/um/os-Linux/seccomp.c
>  delete mode 100644 arch/x86/um/asm/module.h
>  create mode 100644 arch/x86/um/nommu/Makefile
>  create mode 100644 arch/x86/um/nommu/do_syscall_64.c
>  create mode 100644 arch/x86/um/nommu/entry_64.S
>  create mode 100644 arch/x86/um/nommu/os-Linux/Makefile
>  create mode 100644 arch/x86/um/nommu/os-Linux/mcontext.c
>  create mode 100644 arch/x86/um/nommu/syscalls.h
>  create mode 100644 arch/x86/um/nommu/syscalls_64.c
>
>
> base-commit: 2d2b61ae38bd91217ea7cc5bc700a2b9e75b3937
> --
> 2.43.0
>
>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v7 00/13] nommu UML
  2025-04-25 13:49 ` [PATCH v7 00/13] nommu UML Lorenzo Stoakes
@ 2025-04-27  3:49   ` Hajime Tazaki
  2025-04-29 13:23     ` Lorenzo Stoakes
  0 siblings, 1 reply; 6+ messages in thread
From: Hajime Tazaki @ 2025-04-27  3:49 UTC (permalink / raw)
  To: lorenzo.stoakes
  Cc: linux-um, ricarkol, Liam.Howlett, richard, anton.ivanov,
	johannes, linux-mm, linux-kernel


Hello Lorenzo,

On Fri, 25 Apr 2025 22:49:31 +0900,
Lorenzo Stoakes wrote:

> It seemed this series died, which is a pity, i'd be very useful to have
> this functionality to aid in easily testing nommu in mm code.
> 
> I know that I pushed back a little (or rather - wondering about the status
> of nommu in general) back in v2, however with it confirmed that nommu is
> required, this series becomes really quite important.
> 
> This would need rebasing of course for a v8, but I wonder if there is any
> appetite for it or why this didn't go anywhere?
> 
> In any case, if you are still interested in this Hajime (thanks so much for
> all your hard work on it!), just saying there are definitely users out
> there.

I've been waiting for opinions from the um maintainers to the v7
patchset, and am ready to send v8 series with rebasing the current
uml/next branch.

I believe the v7 series is still in the patchwork queue so, I hope
it'll be reviewed soon.

# thanks for the information that this feature is useful to test mm
  code.

-- Hajime


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v7 00/13] nommu UML
  2025-04-27  3:49   ` Hajime Tazaki
@ 2025-04-29 13:23     ` Lorenzo Stoakes
  2025-04-30  9:51       ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Lorenzo Stoakes @ 2025-04-29 13:23 UTC (permalink / raw)
  To: Hajime Tazaki
  Cc: linux-um, ricarkol, Liam.Howlett, richard, anton.ivanov,
	johannes, linux-mm, linux-kernel

On Sun, Apr 27, 2025 at 12:49:36PM +0900, Hajime Tazaki wrote:
>
> Hello Lorenzo,
>
> On Fri, 25 Apr 2025 22:49:31 +0900,
> Lorenzo Stoakes wrote:
>
> > It seemed this series died, which is a pity, i'd be very useful to have
> > this functionality to aid in easily testing nommu in mm code.
> >
> > I know that I pushed back a little (or rather - wondering about the status
> > of nommu in general) back in v2, however with it confirmed that nommu is
> > required, this series becomes really quite important.
> >
> > This would need rebasing of course for a v8, but I wonder if there is any
> > appetite for it or why this didn't go anywhere?
> >
> > In any case, if you are still interested in this Hajime (thanks so much for
> > all your hard work on it!), just saying there are definitely users out
> > there.
>
> I've been waiting for opinions from the um maintainers to the v7
> patchset, and am ready to send v8 series with rebasing the current
> uml/next branch.
>
> I believe the v7 series is still in the patchwork queue so, I hope
> it'll be reviewed soon.
>
> # thanks for the information that this feature is useful to test mm
>   code.

Thanks, appreciate the response. I would say send a v8 that's rebased to
make life easier for maintainers :) if you already have it ready to go that
is!

I think at this stage that makes more sense, as gives the maintainers a
chance to run locally + account for any recent changes etc.

Thank you again for all your hard work on this! This could be super useful
for us over in mm :)

>
> -- Hajime

Cheers, Lorenzo


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v7 00/13] nommu UML
  2025-04-29 13:23     ` Lorenzo Stoakes
@ 2025-04-30  9:51       ` Johannes Berg
  2025-05-01 10:40         ` Lorenzo Stoakes
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2025-04-30  9:51 UTC (permalink / raw)
  To: Lorenzo Stoakes, Hajime Tazaki
  Cc: linux-um, ricarkol, Liam.Howlett, richard, anton.ivanov,
	linux-mm, linux-kernel

On Tue, 2025-04-29 at 14:23 +0100, Lorenzo Stoakes wrote:
> Thanks, appreciate the response. I would say send a v8 that's rebased to
> make life easier for maintainers :) if you already have it ready to go that
> is!

There probably haven't been that many patches since, but I guess why not
:)

I was sort of hoping to get the seccomp patches from Benjamin - that
have been waiting far longer - in first to see what overlap if any there
might be, but I think he and Hajime have already concluded there wasn't
all that much overlap anyway.

But it's good to hear that it'd be useful to you.

johannes


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v7 00/13] nommu UML
  2025-04-30  9:51       ` Johannes Berg
@ 2025-05-01 10:40         ` Lorenzo Stoakes
  0 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Stoakes @ 2025-05-01 10:40 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Hajime Tazaki, linux-um, ricarkol, Liam.Howlett, richard,
	anton.ivanov, linux-mm, linux-kernel

On Wed, Apr 30, 2025 at 11:51:47AM +0200, Johannes Berg wrote:
> On Tue, 2025-04-29 at 14:23 +0100, Lorenzo Stoakes wrote:
> > Thanks, appreciate the response. I would say send a v8 that's rebased to
> > make life easier for maintainers :) if you already have it ready to go that
> > is!
>
> There probably haven't been that many patches since, but I guess why not
> :)

Appreciate you having a look again! :>)

Perhaps I'm being selfish :P but it at least needs a rebase, perhaps just a
trivial one, as b4 shazam refused to play ball when I tried.

>
> I was sort of hoping to get the seccomp patches from Benjamin - that
> have been waiting far longer - in first to see what overlap if any there
> might be, but I think he and Hajime have already concluded there wasn't
> all that much overlap anyway.

Ah thanks for the insight, hopefully not too much friction on that.

>
> But it's good to hear that it'd be useful to you.

Yeah, I (for one) at least struggle with a workable nommu setup, I had a
buildroot for m68k-nommu but it broke in various unpleasant ways, so having
something really straightforward would be hugely helpful.

>
> johannes

Cheers, Lorenzo


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-05-01 10:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1737348399.git.thehajime@gmail.com>
2025-01-20  6:00 ` [PATCH v7 02/13] x86/um: nommu: elf loader for fdpic Hajime Tazaki
2025-04-25 13:49 ` [PATCH v7 00/13] nommu UML Lorenzo Stoakes
2025-04-27  3:49   ` Hajime Tazaki
2025-04-29 13:23     ` Lorenzo Stoakes
2025-04-30  9:51       ` Johannes Berg
2025-05-01 10:40         ` Lorenzo Stoakes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox