[PATCH v2] um: Remove double zero check

2024-10-24 Thread shaojiedong
free_pages() performs a parameter null check inside previous code also does zero check as following if (stack == 0) goto out; to_mm->id.stack = stack; therefore remove double zero check here. Signed-off-by: shaojiedong --- Changes in v2: - EDITME: describe what is new in this se

Re: [PATCH v2] um: Remove double zero check

2024-10-24 Thread Dmitry Baryshkov
On Fri, Oct 25, 2024 at 02:03:32PM +0800, shaojiedong wrote: > free_pages() performs a parameter null check inside > previous code also does zero check as following > if (stack == 0) > goto out; > > to_mm->id.stack = stack; > > therefore remove double zero check here. > > Signed-

[RFC PATCH 12/13] um: nommu: add documentation of nommu UML

2024-10-24 Thread Hajime Tazaki
This commit adds an initial documentation for !MMU mode of UML. Signed-off-by: Hajime Tazaki --- Documentation/virt/uml/nommu-uml.rst | 219 +++ 1 file changed, 219 insertions(+) create mode 100644 Documentation/virt/uml/nommu-uml.rst diff --git a/Documentation/virt/uml

[RFC PATCH 11/13] um: change machine name for uname output

2024-10-24 Thread Hajime Tazaki
This commit tries to display MMU/!MMU mode from the output of uname(2) so that users can distinguish which mode of UML is running right now. Signed-off-by: Hajime Tazaki --- arch/um/Makefile| 6 ++ arch/um/os-Linux/util.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff

[RFC PATCH 13/13] um: nommu: plug nommu code into build system

2024-10-24 Thread Hajime Tazaki
Add nommu kernel for um build. defconfig is also provided. Signed-off-by: Hajime Tazaki Signed-off-by: Ricardo Koller --- arch/um/Kconfig | 13 - arch/um/configs/x86_64_nommu_defconfig | 64 + arch/um/include/shared/common-offsets.h | 3 ++

[PATCH 0/4] um: Set parent-death signal for sub-processes

2024-10-24 Thread Tiwei Bie
The ubd io and write_sigio threads/processes may leak e.g. when the main process is killed by "kill -9". Fix it by setting the parent-death signal for them. Tiwei Bie (4): um: Add os_set_pdeathsig helper function um: Set parent-death signal for ubd io thread/process um: Set parent-death sign

[PATCH 4/4] um: Use os_set_pdeathsig helper in winch thread/process

2024-10-24 Thread Tiwei Bie
Since we have a helper now, let's switch to using it. It will make the code slightly more consistent. Signed-off-by: Tiwei Bie --- arch/um/drivers/chan_user.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c index 143

[PATCH 2/4] um: Set parent-death signal for ubd io thread/process

2024-10-24 Thread Tiwei Bie
The ubd io thread is not really a traditional thread. Set the parent-death signal for it to ensure that it will be killed if the UML kernel dies unexpectedly without proper cleanup. Signed-off-by: Tiwei Bie --- arch/um/drivers/ubd_kern.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/u

[RFC PATCH 08/13] x86/um/vdso: nommu: vdso memory update

2024-10-24 Thread Hajime Tazaki
On !MMU mode, the address of vdso is accessible from userspace. This commit implements the entry point by pointing a block of page address. This commit also add memory permission configuration of vdso page to be executable. Signed-off-by: Hajime Tazaki Signed-off-by: Ricardo Koller --- arch/x

[RFC PATCH 10/13] x86/um: nommu: stack save/restore on vfork

2024-10-24 Thread Hajime Tazaki
This fork can only come from libc's vfork, which does this: popq %%rdx; call *%rax; // zpoline => __kernel_vsyscall pushq %%rdx; %rcx stores the return address which is stored at pt_regs[HOST_IP] at the moment. As child returns via userspace() with a jmp instruction (whil

[RFC PATCH 02/13] x86/um: nommu: elf loader for fdpic

2024-10-24 Thread Hajime Tazaki
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

[RFC PATCH 07/13] um: nommu: configure fs register on host syscall invocation

2024-10-24 Thread Hajime Tazaki
As userspace on UML/!MMU also need to configure %fs register when it is running to correctly access thread structure, host syscalls implemented in os-Linux drivers may be puzzled when they are called. Thus it has to configure %fs register via arch_prctl(SET_FS) on every host syscalls. Signed-off-

[RFC PATCH 03/13] um: nommu: memory handling

2024-10-24 Thread Hajime Tazaki
This commit adds memory operations on UML under !MMU environment. Some part of the original UML code relying on CONFIG_MMU are excluded from compilation when !CONFIG_MMU. Additionally, generic functions such as uaccess, futex, memcpy/strnlen/strncpy can be used as user- and kernel-space share the

[RFC PATCH 06/13] x86/um: nommu: process/thread handling

2024-10-24 Thread Hajime Tazaki
Since ptrace facility isn't used under !MMU of UML, there is different code path to invoke proceeses/threads; on an entry to the syscall interface, the stack pointer should be manipulated to handle vfork(2) return address, no external process is used, and need to properlly configure some of registe

[RFC PATCH 09/13] x86/um: nommu: signal handling

2024-10-24 Thread Hajime Tazaki
This commit updates the behavior of signal handling under !MMU environment. 1) the stack preparation for the signal handlers and 2) retoration of stack after rt_sigreturn(2) syscall. Those are needed as the stack usage on vfork(2) syscall is different. Signed-off-by: Hajime Tazaki --- arch/x86/

[RFC PATCH 01/13] fs: binfmt_elf_efpic: add architecture hook elf_arch_finalize_exec

2024-10-24 Thread Hajime Tazaki
FDPIC ELF loader adds an architecture hook at the end of loading binaries to finalize the mapped memory before moving toward exec function. The hook is used by UML under !MMU when translating syscall/sysenter instructions before calling execve. Cc: Alexander Viro Cc: Christian Brauner Cc: Jan K

Re: [RFC PATCH v2 9/9] um: pass FD for memory operations when needed

2024-10-24 Thread Tiwei Bie
On 2024/10/23 22:08, Benjamin Berg wrote: [...] > diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c > index c663b67c3fd3..a29957e021f3 100644 > --- a/arch/um/os-Linux/skas/process.c > +++ b/arch/um/os-Linux/skas/process.c > @@ -16,6 +16,7 @@ > #include > #include >

Re: [PATCH v6 6/8] x86/module: prepare module loading for ROX allocations of text

2024-10-24 Thread Mike Rapoport
Hi Nathan, On Mon, Oct 21, 2024 at 03:15:19PM -0700, Nathan Chancellor wrote: > Hi Mike, > > On Wed, Oct 16, 2024 at 03:24:22PM +0300, Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > When module text memory will be allocated with ROX permissions, the > > memory at the actual