Re: [PATCH v2 18/18] uaccess: drop maining CONFIG_SET_FS users
On 2/16/22 07:13, Arnd Bergmann wrote: From: Arnd Bergmann There are no remaining callers of set_fs(), so CONFIG_SET_FS can be removed globally, along with the thread_info field and any references to it. This turns access_ok() into a cheaper check against TASK_SIZE_MAX. With CONFIG_SET_FS gone, so drop all remaining references to set_fs()/get_fs(), mm_segment_t and uaccess_kernel(). Signed-off-by: Arnd Bergmann --- arch/Kconfig | 3 - arch/alpha/Kconfig| 1 - arch/alpha/include/asm/processor.h| 4 -- arch/alpha/include/asm/thread_info.h | 2 - arch/alpha/include/asm/uaccess.h | 19 -- arch/arc/Kconfig | 1 - arch/arc/include/asm/segment.h| 20 --- arch/arc/include/asm/thread_info.h| 3 - arch/arc/include/asm/uaccess.h| 1 - arch/arm/lib/uaccess_with_memcpy.c| 10 arch/csky/Kconfig | 1 - arch/csky/include/asm/processor.h | 2 - arch/csky/include/asm/segment.h | 10 arch/csky/include/asm/thread_info.h | 2 - arch/csky/include/asm/uaccess.h | 3 - arch/csky/kernel/asm-offsets.c| 1 - arch/h8300/Kconfig| 1 - arch/h8300/include/asm/processor.h| 1 - arch/h8300/include/asm/segment.h | 40 - arch/h8300/include/asm/thread_info.h | 3 - arch/h8300/kernel/entry.S | 1 - arch/h8300/kernel/head_ram.S | 1 - arch/h8300/mm/init.c | 6 -- arch/h8300/mm/memory.c| 1 - arch/hexagon/Kconfig | 1 - arch/hexagon/include/asm/thread_info.h| 6 -- arch/hexagon/kernel/process.c | 1 - arch/microblaze/Kconfig | 1 - arch/microblaze/include/asm/thread_info.h | 6 -- arch/microblaze/include/asm/uaccess.h | 24 arch/microblaze/kernel/asm-offsets.c | 1 - arch/microblaze/kernel/process.c | 1 - arch/nds32/Kconfig| 1 - arch/nds32/include/asm/thread_info.h | 4 -- arch/nds32/include/asm/uaccess.h | 15 + arch/nds32/kernel/process.c | 5 +- arch/nds32/mm/alignment.c | 3 - arch/nios2/Kconfig| 1 - arch/nios2/include/asm/thread_info.h | 9 --- arch/nios2/include/asm/uaccess.h | 12 For NIOS2: Acked-by: Dinh Nguyen ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2 18/18] uaccess: drop maining CONFIG_SET_FS users
On Wed, Feb 16, 2022 at 02:13:32PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann > > There are no remaining callers of set_fs(), so CONFIG_SET_FS > can be removed globally, along with the thread_info field and > any references to it. > > This turns access_ok() into a cheaper check against TASK_SIZE_MAX. > > With CONFIG_SET_FS gone, so drop all remaining references to > set_fs()/get_fs(), mm_segment_t and uaccess_kernel(). > > Signed-off-by: Arnd Bergmann > --- ... > arch/openrisc/Kconfig | 1 - > arch/openrisc/include/asm/thread_info.h | 7 --- > arch/openrisc/include/asm/uaccess.h | 23 ... > fs/exec.c | 6 -- > include/asm-generic/access_ok.h | 10 +--- > include/asm-generic/uaccess.h | 25 +--- > include/linux/syscalls.h | 4 -- > include/linux/uaccess.h | 33 --- > include/rdma/ib.h | 2 +- > kernel/events/callchain.c | 4 -- > kernel/events/core.c | 3 - > kernel/exit.c | 14 - > kernel/kthread.c | 5 -- > kernel/stacktrace.c | 3 - > kernel/trace/bpf_trace.c | 4 -- > mm/maccess.c | 11 > mm/memory.c | 8 --- > net/bpfilter/bpfilter_kern.c | 2 +- > 72 files changed, 10 insertions(+), 522 deletions(-) > delete mode 100644 arch/arc/include/asm/segment.h > delete mode 100644 arch/csky/include/asm/segment.h > delete mode 100644 arch/h8300/include/asm/segment.h > > diff --git a/arch/Kconfig b/arch/Kconfig > index fa5db36bda67..99349547afed 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -24,9 +24,6 @@ config KEXEC_ELF > config HAVE_IMA_KEXEC > bool > > -config SET_FS > - bool > - > config HOTPLUG_SMT > bool > ... > diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig > index f724b3f1aeed..0d68adf6e02b 100644 > --- a/arch/openrisc/Kconfig > +++ b/arch/openrisc/Kconfig > @@ -36,7 +36,6 @@ config OPENRISC > select ARCH_WANT_FRAME_POINTERS > select GENERIC_IRQ_MULTI_HANDLER > select MMU_GATHER_NO_RANGE if MMU > - select SET_FS > select TRACE_IRQFLAGS_SUPPORT > > config CPU_BIG_ENDIAN > diff --git a/arch/openrisc/include/asm/thread_info.h > b/arch/openrisc/include/asm/thread_info.h > index 659834ab87fa..4af3049c34c2 100644 > --- a/arch/openrisc/include/asm/thread_info.h > +++ b/arch/openrisc/include/asm/thread_info.h > @@ -40,18 +40,12 @@ > */ > #ifndef __ASSEMBLY__ > > -typedef unsigned long mm_segment_t; > - > struct thread_info { > struct task_struct *task; /* main task structure */ > unsigned long flags; /* low level flags */ > __u32 cpu;/* current CPU */ > __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ > > - mm_segment_taddr_limit; /* thread address space: > -0-0x7FFF for user-thead > -0-0x for kernel-thread > - */ > __u8supervisor_stack[0]; > > /* saved context data */ > @@ -71,7 +65,6 @@ struct thread_info { > .flags = 0,\ > .cpu= 0,\ > .preempt_count = INIT_PREEMPT_COUNT, \ > - .addr_limit = KERNEL_DS,\ > .ksp= 0,\ > } > > diff --git a/arch/openrisc/include/asm/uaccess.h > b/arch/openrisc/include/asm/uaccess.h > index 8f049ec99b3e..d6500a374e18 100644 > --- a/arch/openrisc/include/asm/uaccess.h > +++ b/arch/openrisc/include/asm/uaccess.h > @@ -22,29 +22,6 @@ > #include > #include > #include > - > -/* > - * The fs value determines whether argument validity checking should be > - * performed or not. If get_fs() == USER_DS, checking is performed, with > - * get_fs() == KERNEL_DS, checking is bypassed. > - * > - * For historical reasons, these macros are grossly misnamed. > - */ > - > -/* addr_limit is the maximum accessible address for the task. we misuse > - * the KERNEL_DS and USER_DS values to both assign and compare the > - * addr_limit values through the equally misnamed get/set_fs macros. > - * (see above) > - */ > - > -#define KERNEL_DS(~0UL) > - > -#define USER_DS (TASK_SIZE) > -#define get_fs() (current_thread_info()->addr_limit) > -#define set_fs(x)(current_thread_info()->addr_limit = (x)) > - > -#define uaccess_kernel() (get_fs() == KERNEL_DS) > - > #include > > /* ... > diff --git a/fs/exec.c b/fs/exec.c > index 79f2c9483302..bc68a0c089ac 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -1303,12 +1303,6 @@ int
Re: [PATCH v2 18/18] uaccess: drop maining CONFIG_SET_FS users
Hi Arnd, > From: Arnd Bergmann > > There are no remaining callers of set_fs(), so CONFIG_SET_FS > can be removed globally, along with the thread_info field and > any references to it. > > This turns access_ok() into a cheaper check against TASK_SIZE_MAX. > > With CONFIG_SET_FS gone, so drop all remaining references to > set_fs()/get_fs(), mm_segment_t and uaccess_kernel(). > > Signed-off-by: Arnd Bergmann Tested-by: Sergey Matyukevich # for arc changes Regards, Sergey ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2 18/18] uaccess: drop maining CONFIG_SET_FS users
On Fri, Feb 18, 2022 at 7:37 AM Christoph Hellwig wrote: > > s/maining/remaining/ ? > > Or maybe rather: > > uaccess: remove CONFIG_SET_FS > > because it is all gone now. > > > With CONFIG_SET_FS gone, so drop all remaining references to > > set_fs()/get_fs(), mm_segment_t and uaccess_kernel(). > > And this sentence does not parse. Both fixed now, thanks! Arnd ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2 18/18] uaccess: drop maining CONFIG_SET_FS users
s/maining/remaining/ ? Or maybe rather: uaccess: remove CONFIG_SET_FS because it is all gone now. > With CONFIG_SET_FS gone, so drop all remaining references to > set_fs()/get_fs(), mm_segment_t and uaccess_kernel(). And this sentence does not parse. ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2 18/18] uaccess: drop maining CONFIG_SET_FS users
Arnd Bergmann writes: > From: Arnd Bergmann > > There are no remaining callers of set_fs(), so CONFIG_SET_FS > can be removed globally, along with the thread_info field and > any references to it. > > This turns access_ok() into a cheaper check against TASK_SIZE_MAX. > > With CONFIG_SET_FS gone, so drop all remaining references to > set_fs()/get_fs(), mm_segment_t and uaccess_kernel(). For the bits I have looked at recently, and think I understand. Acked-by: "Eric W. Biederman" > > Signed-off-by: Arnd Bergmann > --- > fs/exec.c | 6 -- > kernel/exit.c | 14 - > kernel/kthread.c | 5 -- > > diff --git a/fs/exec.c b/fs/exec.c > index 79f2c9483302..bc68a0c089ac 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -1303,12 +1303,6 @@ int begin_new_exec(struct linux_binprm * bprm) > if (retval) > goto out_unlock; > > - /* > - * Ensure that the uaccess routines can actually operate on userspace > - * pointers: > - */ > - force_uaccess_begin(); > - > if (me->flags & PF_KTHREAD) > free_kthread_struct(me); > me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD | > diff --git a/kernel/exit.c b/kernel/exit.c > index b00a25bb4ab9..0884a75bc2f8 100644 > --- a/kernel/exit.c > +++ b/kernel/exit.c > @@ -737,20 +737,6 @@ void __noreturn do_exit(long code) > > WARN_ON(blk_needs_flush_plug(tsk)); > > - /* > - * If do_dead is called because this processes oopsed, it's possible > - * that get_fs() was left as KERNEL_DS, so reset it to USER_DS before > - * continuing. Amongst other possible reasons, this is to prevent > - * mm_release()->clear_child_tid() from writing to a user-controlled > - * kernel address. > - * > - * On uptodate architectures force_uaccess_begin is a noop. On > - * architectures that still have set_fs/get_fs in addition to handling > - * oopses handles kernel threads that run as set_fs(KERNEL_DS) by > - * default. > - */ > - force_uaccess_begin(); > - > kcov_task_exit(tsk); > > coredump_task_exit(tsk); > diff --git a/kernel/kthread.c b/kernel/kthread.c > index 38c6dd822da8..16c2275d4b50 100644 > --- a/kernel/kthread.c > +++ b/kernel/kthread.c > @@ -55,7 +55,6 @@ struct kthread { > int result; > int (*threadfn)(void *); > void *data; > - mm_segment_t oldfs; > struct completion parked; > struct completion exited; > #ifdef CONFIG_BLK_CGROUP > @@ -1441,8 +1440,6 @@ void kthread_use_mm(struct mm_struct *mm) > mmdrop(active_mm); > else > smp_mb(); > - > - to_kthread(tsk)->oldfs = force_uaccess_begin(); > } > EXPORT_SYMBOL_GPL(kthread_use_mm); > > @@ -1457,8 +1454,6 @@ void kthread_unuse_mm(struct mm_struct *mm) > WARN_ON_ONCE(!(tsk->flags & PF_KTHREAD)); > WARN_ON_ONCE(!tsk->mm); > > - force_uaccess_end(to_kthread(tsk)->oldfs); > - > task_lock(tsk); > /* >* When a kthread stops operating on an address space, the loop ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2 18/18] uaccess: drop maining CONFIG_SET_FS users
On Wed, Feb 16, 2022 at 7:44 PM Sam Ravnborg wrote: > > Hi Arnd, > > Fix spelling in $subject... done > sparc/Kconfig b/arch/sparc/Kconfig > > index 9f6f9bce5292..9276f321b3e3 100644 > > --- a/arch/sparc/Kconfig > > +++ b/arch/sparc/Kconfig > > @@ -46,7 +46,6 @@ config SPARC > > select LOCKDEP_SMALL if LOCKDEP > > select NEED_DMA_MAP_STATE > > select NEED_SG_DMA_LENGTH > > - select SET_FS > > select TRACE_IRQFLAGS_SUPPORT > > > > config SPARC32 > > @@ -101,6 +100,7 @@ config SPARC64 > > select HAVE_SETUP_PER_CPU_AREA > > select NEED_PER_CPU_EMBED_FIRST_CHUNK > > select NEED_PER_CPU_PAGE_FIRST_CHUNK > > + select SET_FS > This looks wrong - looks like some merge went wrong here. Fixed now. > > Other than the above the sparc32 changes looks fine, and with the Kconf > stuff fixed: > Acked-by: Sam Ravnborg # for sparc32 changes Thanks! Arnd ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2 18/18] uaccess: drop maining CONFIG_SET_FS users
Hi Arnd, Fix spelling in $subject... sparc/Kconfig b/arch/sparc/Kconfig > index 9f6f9bce5292..9276f321b3e3 100644 > --- a/arch/sparc/Kconfig > +++ b/arch/sparc/Kconfig > @@ -46,7 +46,6 @@ config SPARC > select LOCKDEP_SMALL if LOCKDEP > select NEED_DMA_MAP_STATE > select NEED_SG_DMA_LENGTH > - select SET_FS > select TRACE_IRQFLAGS_SUPPORT > > config SPARC32 > @@ -101,6 +100,7 @@ config SPARC64 > select HAVE_SETUP_PER_CPU_AREA > select NEED_PER_CPU_EMBED_FIRST_CHUNK > select NEED_PER_CPU_PAGE_FIRST_CHUNK > + select SET_FS This looks wrong - looks like some merge went wrong here. > > config ARCH_PROC_KCORE_TEXT > def_bool y > diff --git a/arch/sparc/include/asm/processor_32.h > b/arch/sparc/include/asm/processor_32.h > index 647bf0ac7beb..b26c35336b51 100644 > --- a/arch/sparc/include/asm/processor_32.h > +++ b/arch/sparc/include/asm/processor_32.h > @@ -32,10 +32,6 @@ struct fpq { > }; > #endif > > -typedef struct { > - int seg; > -} mm_segment_t; > - > /* The Sparc processor specific thread struct. */ > struct thread_struct { > struct pt_regs *kregs; > @@ -50,11 +46,9 @@ struct thread_struct { > unsigned long fsr; > unsigned long fpqdepth; > struct fpq fpqueue[16]; > - mm_segment_t current_ds; > }; > > #define INIT_THREAD { \ > - .current_ds = KERNEL_DS, \ > .kregs = (struct pt_regs *)(init_stack+THREAD_SIZE)-1 \ > } > > diff --git a/arch/sparc/include/asm/uaccess_32.h > b/arch/sparc/include/asm/uaccess_32.h > index 367747116260..9fd6c53644b6 100644 > --- a/arch/sparc/include/asm/uaccess_32.h > +++ b/arch/sparc/include/asm/uaccess_32.h > @@ -12,19 +12,6 @@ > #include > > #include > - > -/* Sparc is not segmented, however we need to be able to fool access_ok() > - * when doing system calls from kernel mode legitimately. > - * > - * "For historical reasons, these macros are grossly misnamed." -Linus > - */ > - > -#define KERNEL_DS ((mm_segment_t) { 0 }) > -#define USER_DS ((mm_segment_t) { -1 }) > - > -#define get_fs() (current->thread.current_ds) > -#define set_fs(val) ((current->thread.current_ds) = (val)) > - > #include > > /* Uh, these should become the main single-value transfer routines.. > diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c > index 2dc0bf9fe62e..88c0c14aaff0 100644 > --- a/arch/sparc/kernel/process_32.c > +++ b/arch/sparc/kernel/process_32.c > @@ -300,7 +300,6 @@ int copy_thread(unsigned long clone_flags, unsigned long > sp, unsigned long arg, > extern int nwindows; > unsigned long psr; > memset(new_stack, 0, STACKFRAME_SZ + TRACEREG_SZ); > - p->thread.current_ds = KERNEL_DS; > ti->kpc = (((unsigned long) ret_from_kernel_thread) - 0x8); > childregs->u_regs[UREG_G1] = sp; /* function */ > childregs->u_regs[UREG_G2] = arg; > @@ -311,7 +310,6 @@ int copy_thread(unsigned long clone_flags, unsigned long > sp, unsigned long arg, > } > memcpy(new_stack, (char *)regs - STACKFRAME_SZ, STACKFRAME_SZ + > TRACEREG_SZ); > childregs->u_regs[UREG_FP] = sp; > - p->thread.current_ds = USER_DS; > ti->kpc = (((unsigned long) ret_from_fork) - 0x8); > ti->kpsr = current->thread.fork_kpsr | PSR_PIL; > ti->kwim = current->thread.fork_kwim; Other than the above the sparc32 changes looks fine, and with the Kconf stuff fixed: Acked-by: Sam Ravnborg # for sparc32 changes ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v2 18/18] uaccess: drop maining CONFIG_SET_FS users
From: Arnd Bergmann There are no remaining callers of set_fs(), so CONFIG_SET_FS can be removed globally, along with the thread_info field and any references to it. This turns access_ok() into a cheaper check against TASK_SIZE_MAX. With CONFIG_SET_FS gone, so drop all remaining references to set_fs()/get_fs(), mm_segment_t and uaccess_kernel(). Signed-off-by: Arnd Bergmann --- arch/Kconfig | 3 - arch/alpha/Kconfig| 1 - arch/alpha/include/asm/processor.h| 4 -- arch/alpha/include/asm/thread_info.h | 2 - arch/alpha/include/asm/uaccess.h | 19 -- arch/arc/Kconfig | 1 - arch/arc/include/asm/segment.h| 20 --- arch/arc/include/asm/thread_info.h| 3 - arch/arc/include/asm/uaccess.h| 1 - arch/arm/lib/uaccess_with_memcpy.c| 10 arch/csky/Kconfig | 1 - arch/csky/include/asm/processor.h | 2 - arch/csky/include/asm/segment.h | 10 arch/csky/include/asm/thread_info.h | 2 - arch/csky/include/asm/uaccess.h | 3 - arch/csky/kernel/asm-offsets.c| 1 - arch/h8300/Kconfig| 1 - arch/h8300/include/asm/processor.h| 1 - arch/h8300/include/asm/segment.h | 40 - arch/h8300/include/asm/thread_info.h | 3 - arch/h8300/kernel/entry.S | 1 - arch/h8300/kernel/head_ram.S | 1 - arch/h8300/mm/init.c | 6 -- arch/h8300/mm/memory.c| 1 - arch/hexagon/Kconfig | 1 - arch/hexagon/include/asm/thread_info.h| 6 -- arch/hexagon/kernel/process.c | 1 - arch/microblaze/Kconfig | 1 - arch/microblaze/include/asm/thread_info.h | 6 -- arch/microblaze/include/asm/uaccess.h | 24 arch/microblaze/kernel/asm-offsets.c | 1 - arch/microblaze/kernel/process.c | 1 - arch/nds32/Kconfig| 1 - arch/nds32/include/asm/thread_info.h | 4 -- arch/nds32/include/asm/uaccess.h | 15 + arch/nds32/kernel/process.c | 5 +- arch/nds32/mm/alignment.c | 3 - arch/nios2/Kconfig| 1 - arch/nios2/include/asm/thread_info.h | 9 --- arch/nios2/include/asm/uaccess.h | 12 arch/openrisc/Kconfig | 1 - arch/openrisc/include/asm/thread_info.h | 7 --- arch/openrisc/include/asm/uaccess.h | 23 arch/parisc/include/asm/futex.h | 6 -- arch/parisc/lib/memcpy.c | 2 +- arch/sparc/Kconfig| 2 +- arch/sparc/include/asm/processor_32.h | 6 -- arch/sparc/include/asm/uaccess_32.h | 13 - arch/sparc/kernel/process_32.c| 2 - arch/xtensa/Kconfig | 1 - arch/xtensa/include/asm/asm-uaccess.h | 71 --- arch/xtensa/include/asm/processor.h | 7 --- arch/xtensa/include/asm/thread_info.h | 3 - arch/xtensa/include/asm/uaccess.h | 16 - arch/xtensa/kernel/asm-offsets.c | 3 - drivers/hid/uhid.c| 2 +- drivers/scsi/sg.c | 5 -- fs/exec.c | 6 -- include/asm-generic/access_ok.h | 10 +--- include/asm-generic/uaccess.h | 25 +--- include/linux/syscalls.h | 4 -- include/linux/uaccess.h | 33 --- include/rdma/ib.h | 2 +- kernel/events/callchain.c | 4 -- kernel/events/core.c | 3 - kernel/exit.c | 14 - kernel/kthread.c | 5 -- kernel/stacktrace.c | 3 - kernel/trace/bpf_trace.c | 4 -- mm/maccess.c | 11 mm/memory.c | 8 --- net/bpfilter/bpfilter_kern.c | 2 +- 72 files changed, 10 insertions(+), 522 deletions(-) delete mode 100644 arch/arc/include/asm/segment.h delete mode 100644 arch/csky/include/asm/segment.h delete mode 100644 arch/h8300/include/asm/segment.h diff --git a/arch/Kconfig b/arch/Kconfig index fa5db36bda67..99349547afed 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -24,9 +24,6 @@ config KEXEC_ELF config HAVE_IMA_KEXEC bool -config SET_FS - bool - config HOTPLUG_SMT bool diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 4e87783c90ad..eee8b5b0a58b 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -35,7 +35,6 @@ config ALPHA select OLD_SIGSUSPEND select CPU_NO_EFFICIENT_FFS if !ALPHA_EV67 select MMU_GATHER_NO_RANGE - select SET_FS select SPARSEMEM_EXTREME if SPARSEMEM select ZONE_DMA help diff --git