Essentially all users of is_compat_task in the kernel are trying to determine whether they are executing in the context of a compat syscall. On at least x86_64 and sparc, these are not at all the same question. On x86_64 and sparc, therefore, is_compat_task doesn't return the overall compat state of the task; it returns true if the task is currently in a compat syscall. This confusion has been the source of bugs in the past. Rename the function to make it much clearer what it does. This results in some odd definitions in the s390 headers. s390 maintainers, are you okay with that? If not, I'd be happy to clean it up if you let me know how you'd like me to do it. This patch was generated by: $ find \( -name \*.c -o -name \*.h \) -a -type f -exec sed -i -e 's/is_compat_task/in_compat_syscall/g' '{}' \; Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Cc: x86@xxxxxxxxxx Cc: linux-arch@xxxxxxxxxxxxxxx Cc: David Miller <davem@xxxxxxxxxxxxx> Cc: linux-s390@xxxxxxxxxxxxxxx Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxx> --- Hi Linus- This is the patch I threatened to send late in the 4.5 merge window. I decided to send it early enough to let arch people take a look. What do you all think? arch/arm64/include/asm/compat.h | 2 +- arch/arm64/include/asm/ftrace.h | 2 +- arch/arm64/include/asm/syscall.h | 2 +- arch/arm64/kernel/hw_breakpoint.c | 2 +- arch/arm64/kernel/process.c | 2 +- arch/arm64/kernel/ptrace.c | 6 +++--- arch/arm64/kernel/signal.c | 4 ++-- arch/arm64/kernel/traps.c | 2 +- arch/mips/include/asm/compat.h | 2 +- arch/parisc/include/asm/compat.h | 6 +++--- arch/parisc/include/asm/syscall.h | 2 +- arch/parisc/kernel/ptrace.c | 2 +- arch/parisc/kernel/signal.c | 14 +++++++------- arch/powerpc/include/asm/compat.h | 2 +- arch/s390/hypfs/hypfs_sprp.c | 2 +- arch/s390/include/asm/compat.h | 4 ++-- arch/s390/include/asm/elf.h | 8 ++++---- arch/s390/kernel/process.c | 2 +- arch/s390/kernel/ptrace.c | 4 ++-- arch/s390/kernel/signal.c | 2 +- arch/s390/kernel/uprobes.c | 4 ++-- arch/s390/kernel/vdso.c | 2 +- arch/s390/mm/mmap.c | 6 +++--- arch/sparc/include/asm/compat.h | 2 +- arch/tile/include/asm/compat.h | 2 +- arch/tile/include/asm/syscall.h | 2 +- arch/tile/kernel/process.c | 2 +- arch/tile/kernel/ptrace.c | 4 ++-- arch/tile/kernel/signal.c | 2 +- arch/tile/kernel/unaligned.c | 2 +- arch/tile/kernel/vdso.c | 2 +- arch/tile/mm/mmap.c | 2 +- arch/x86/include/asm/compat.h | 2 +- arch/x86/include/asm/ftrace.h | 2 +- arch/x86/kernel/process_64.c | 2 +- drivers/firewire/core-cdev.c | 4 ++-- drivers/firmware/efi/efivars.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 +- drivers/hid/uhid.c | 2 +- drivers/input/input-compat.h | 2 +- drivers/s390/block/dasd_eckd.c | 2 +- drivers/s390/block/dasd_ioctl.c | 2 +- drivers/s390/char/fs3270.c | 2 +- drivers/s390/char/sclp_ctl.c | 4 ++-- drivers/s390/char/vmcp.c | 2 +- drivers/s390/cio/chsc_sch.c | 2 +- drivers/s390/net/qeth_core_main.c | 2 +- drivers/staging/lustre/lustre/llite/llite_internal.h | 2 +- fs/ext4/dir.c | 2 +- include/linux/compat.h | 2 +- kernel/auditsc.c | 2 +- kernel/ptrace.c | 2 +- kernel/seccomp.c | 4 ++-- net/sctp/socket.c | 2 +- net/xfrm/xfrm_user.c | 2 +- 56 files changed, 79 insertions(+), 79 deletions(-) diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h index eb8432bb82b8..eb16d2d4dd48 100644 --- a/arch/arm64/include/asm/compat.h +++ b/arch/arm64/include/asm/compat.h @@ -298,7 +298,7 @@ struct compat_shmid64_ds { compat_ulong_t __unused5; }; -static inline int is_compat_task(void) +static inline int in_compat_syscall(void) { return test_thread_flag(TIF_32BIT); } diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h index 3c60f37e48ab..d3d60ed2f6c2 100644 --- a/arch/arm64/include/asm/ftrace.h +++ b/arch/arm64/include/asm/ftrace.h @@ -54,7 +54,7 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) { - return is_compat_task(); + return in_compat_syscall(); } #endif /* ifndef __ASSEMBLY__ */ diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h index 709a574468f0..6dfe0d190494 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -113,7 +113,7 @@ static inline void syscall_set_arguments(struct task_struct *task, */ static inline int syscall_get_arch(void) { - if (is_compat_task()) + if (in_compat_syscall()) return AUDIT_ARCH_ARM; return AUDIT_ARCH_AARCH64; diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c index b45c95d34b83..4028a7664244 100644 --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c @@ -679,7 +679,7 @@ static int watchpoint_handler(unsigned long addr, unsigned int esr, info = counter_arch_bp(wp); /* AArch32 watchpoints are either 4 or 8 bytes aligned. */ - if (is_compat_task()) { + if (in_compat_syscall()) { if (info->ctrl.len == ARM_BREAKPOINT_LEN_8) alignment_mask = 0x7; else diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 88d742ba19d5..1aedccf72790 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -210,7 +210,7 @@ static void tls_thread_flush(void) { asm ("msr tpidr_el0, xzr"); - if (is_compat_task()) { + if (in_compat_syscall()) { current->thread.tp_value = 0; /* diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index ff7f13239515..69a410b7a073 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -85,7 +85,7 @@ static void ptrace_hbptriggered(struct perf_event *bp, #ifdef CONFIG_COMPAT int i; - if (!is_compat_task()) + if (!in_compat_syscall()) goto send_sig; for (i = 0; i < ARM_MAX_BRP; ++i) { @@ -1203,7 +1203,7 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task) * 32-bit children use an extended user_aarch32_ptrace_view to allow * access to the TLS register. */ - if (is_compat_task()) + if (in_compat_syscall()) return &user_aarch32_view; else if (is_compat_thread(task_thread_info(task))) return &user_aarch32_ptrace_view; @@ -1232,7 +1232,7 @@ static void tracehook_report_syscall(struct pt_regs *regs, * A scratch register (ip(r12) on AArch32, x7 on AArch64) is * used to denote syscall entry/exit: */ - regno = (is_compat_task() ? 12 : 7); + regno = (in_compat_syscall() ? 12 : 7); saved_reg = regs->regs[regno]; regs->regs[regno] = dir; diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index e18c48cb6db1..e462ab0cb4fc 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -276,7 +276,7 @@ static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, static void setup_restart_syscall(struct pt_regs *regs) { - if (is_compat_task()) + if (in_compat_syscall()) compat_setup_restart_syscall(regs); else regs->regs[8] = __NR_restart_syscall; @@ -295,7 +295,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) /* * Set up the stack frame */ - if (is_compat_task()) { + if (in_compat_syscall()) { if (ksig->ka.sa.sa_flags & SA_SIGINFO) ret = compat_setup_rt_frame(usig, ksig, oldset, regs); else diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index cbedd724f48e..90270b245bc7 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -396,7 +396,7 @@ asmlinkage long do_ni_syscall(struct pt_regs *regs) { #ifdef CONFIG_COMPAT long ret; - if (is_compat_task()) { + if (in_compat_syscall()) { ret = compat_arm_syscall(regs); if (ret != -ENOSYS) return ret; diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h index a9580097cba8..d1685ea7a9d0 100644 --- a/arch/mips/include/asm/compat.h +++ b/arch/mips/include/asm/compat.h @@ -302,7 +302,7 @@ typedef struct compat_sigaltstack { } compat_stack_t; #define compat_sigaltstack compat_sigaltstack -static inline int is_compat_task(void) +static inline int in_compat_syscall(void) { return test_thread_flag(TIF_32BIT_ADDR); } diff --git a/arch/parisc/include/asm/compat.h b/arch/parisc/include/asm/compat.h index 0448a2c8eafb..0d335cde6e09 100644 --- a/arch/parisc/include/asm/compat.h +++ b/arch/parisc/include/asm/compat.h @@ -272,14 +272,14 @@ static __inline__ void __user *arch_compat_alloc_user_space(long len) return (void __user *)regs->gr[30]; } -static inline int __is_compat_task(struct task_struct *t) +static inline int __in_compat_syscall(struct task_struct *t) { return test_ti_thread_flag(task_thread_info(t), TIF_32BIT); } -static inline int is_compat_task(void) +static inline int in_compat_syscall(void) { - return __is_compat_task(current); + return __in_compat_syscall(current); } #endif /* _ASM_PARISC_COMPAT_H */ diff --git a/arch/parisc/include/asm/syscall.h b/arch/parisc/include/asm/syscall.h index a5eba95d87fe..35e6f9acc72e 100644 --- a/arch/parisc/include/asm/syscall.h +++ b/arch/parisc/include/asm/syscall.h @@ -43,7 +43,7 @@ static inline int syscall_get_arch(void) { int arch = AUDIT_ARCH_PARISC; #ifdef CONFIG_64BIT - if (!is_compat_task()) + if (!in_compat_syscall()) arch = AUDIT_ARCH_PARISC64; #endif return arch; diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c index 9585c81f755f..40f9f6935360 100644 --- a/arch/parisc/kernel/ptrace.c +++ b/arch/parisc/kernel/ptrace.c @@ -279,7 +279,7 @@ long do_syscall_trace_enter(struct pt_regs *regs) ret = -1L; #ifdef CONFIG_64BIT - if (!is_compat_task()) + if (!in_compat_syscall()) audit_syscall_entry(regs->gr[20], regs->gr[26], regs->gr[25], regs->gr[24], regs->gr[23]); else diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c index 2264f68f3c2f..2f8cbf345f01 100644 --- a/arch/parisc/kernel/signal.c +++ b/arch/parisc/kernel/signal.c @@ -94,7 +94,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall) compat_sigset_t compat_set; struct compat_rt_sigframe __user * compat_frame; - if (is_compat_task()) + if (in_compat_syscall()) sigframe_size = PARISC_RT_SIGFRAME_SIZE32; #endif @@ -110,7 +110,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall) #ifdef CONFIG_64BIT compat_frame = (struct compat_rt_sigframe __user *)frame; - if (is_compat_task()) { + if (in_compat_syscall()) { DBG(2,"sys_rt_sigreturn: ELF32 process.\n"); if (__copy_from_user(&compat_set, &compat_frame->uc.uc_sigmask, sizeof(compat_set))) goto give_sigsegv; @@ -126,7 +126,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall) /* Good thing we saved the old gr[30], eh? */ #ifdef CONFIG_64BIT - if (is_compat_task()) { + if (in_compat_syscall()) { DBG(1,"sys_rt_sigreturn: compat_frame->uc.uc_mcontext 0x%p\n", &compat_frame->uc.uc_mcontext); // FIXME: Load upper half from register file @@ -250,7 +250,7 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs, compat_frame = (struct compat_rt_sigframe __user *)frame; - if (is_compat_task()) { + if (in_compat_syscall()) { DBG(1,"setup_rt_frame: frame->info = 0x%p\n", &compat_frame->info); err |= copy_siginfo_to_user32(&compat_frame->info, &ksig->info); err |= __compat_save_altstack( &compat_frame->uc.uc_stack, regs->gr[30]); @@ -316,7 +316,7 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs, haddr = A(ksig->ka.sa.sa_handler); /* The sa_handler may be a pointer to a function descriptor */ #ifdef CONFIG_64BIT - if (is_compat_task()) { + if (in_compat_syscall()) { #endif if (haddr & PA_PLABEL_FDESC) { Elf32_Fdesc fdesc; @@ -351,7 +351,7 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs, */ sigframe_size = PARISC_RT_SIGFRAME_SIZE; #ifdef CONFIG_64BIT - if (is_compat_task()) + if (in_compat_syscall()) sigframe_size = PARISC_RT_SIGFRAME_SIZE32; #endif if (in_syscall) { @@ -388,7 +388,7 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs, regs->gr[26] = ksig->sig; /* signal number */ #ifdef CONFIG_64BIT - if (is_compat_task()) { + if (in_compat_syscall()) { regs->gr[25] = A(&compat_frame->info); /* siginfo pointer */ regs->gr[24] = A(&compat_frame->uc); /* ucontext pointer */ } else diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h index 4f2df589ec1d..1d4e4e091dc6 100644 --- a/arch/powerpc/include/asm/compat.h +++ b/arch/powerpc/include/asm/compat.h @@ -282,7 +282,7 @@ struct compat_shmid64_ds { compat_ulong_t __unused6; }; -static inline int is_compat_task(void) +static inline int in_compat_syscall(void) { return is_32bit_task(); } diff --git a/arch/s390/hypfs/hypfs_sprp.c b/arch/s390/hypfs/hypfs_sprp.c index c9e5c72f78bd..29542de93f62 100644 --- a/arch/s390/hypfs/hypfs_sprp.c +++ b/arch/s390/hypfs/hypfs_sprp.c @@ -113,7 +113,7 @@ static long hypfs_sprp_ioctl(struct file *file, unsigned int cmd, if (!capable(CAP_SYS_ADMIN)) return -EACCES; - if (is_compat_task()) + if (in_compat_syscall()) argp = compat_ptr(arg); else argp = (void __user *) arg; diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h index 352f7bdaf11f..7fd83571884b 100644 --- a/arch/s390/include/asm/compat.h +++ b/arch/s390/include/asm/compat.h @@ -282,7 +282,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr) #ifdef CONFIG_COMPAT -static inline int is_compat_task(void) +static inline int in_compat_syscall(void) { return test_thread_flag(TIF_31BIT); } @@ -292,7 +292,7 @@ static inline void __user *arch_compat_alloc_user_space(long len) unsigned long stack; stack = KSTK_ESP(current); - if (is_compat_task()) + if (in_compat_syscall()) stack &= 0x7fffffffUL; return (void __user *) (stack - len); } diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h index 563ab9f44874..3acbb3fd6089 100644 --- a/arch/s390/include/asm/elf.h +++ b/arch/s390/include/asm/elf.h @@ -163,7 +163,7 @@ extern unsigned int vdso_enabled; the loader. We need to make sure that it is out of the way of the program that it will "exec", and that there is sufficient room for the brk. 64-bit tasks are aligned to 4GB. */ -#define ELF_ET_DYN_BASE (is_compat_task() ? \ +#define ELF_ET_DYN_BASE (in_compat_syscall() ? \ (STACK_TOP / 3 * 2) : \ (STACK_TOP / 3 * 2) & ~((1UL << 32) - 1)) @@ -220,9 +220,9 @@ do { \ * of up to 1GB. For 31-bit processes the virtual address space is limited, * use no alignment and limit the randomization to 8MB. */ -#define BRK_RND_MASK (is_compat_task() ? 0x7ffUL : 0x3ffffUL) -#define MMAP_RND_MASK (is_compat_task() ? 0x7ffUL : 0x3ff80UL) -#define MMAP_ALIGN_MASK (is_compat_task() ? 0 : 0x7fUL) +#define BRK_RND_MASK (in_compat_syscall() ? 0x7ffUL : 0x3ffffUL) +#define MMAP_RND_MASK (in_compat_syscall() ? 0x7ffUL : 0x3ff80UL) +#define MMAP_ALIGN_MASK (in_compat_syscall() ? 0 : 0x7fUL) #define STACK_RND_MASK MMAP_RND_MASK #define ARCH_DLINFO \ diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c index 114ee8b96f17..789de957cfdd 100644 --- a/arch/s390/kernel/process.c +++ b/arch/s390/kernel/process.c @@ -176,7 +176,7 @@ int copy_thread(unsigned long clone_flags, unsigned long new_stackp, /* Set a new TLS ? */ if (clone_flags & CLONE_SETTLS) { unsigned long tls = frame->childregs.gprs[6]; - if (is_compat_task()) { + if (in_compat_syscall()) { p->thread.acrs[0] = (unsigned int)tls; } else { p->thread.acrs[0] = (unsigned int)(tls >> 32); diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c index 01c37b36caf9..6619419fe794 100644 --- a/arch/s390/kernel/ptrace.c +++ b/arch/s390/kernel/ptrace.c @@ -642,7 +642,7 @@ static int peek_user_compat(struct task_struct *child, { __u32 tmp; - if (!is_compat_task() || (addr & 3) || addr > sizeof(struct user) - 3) + if (!in_compat_syscall() || (addr & 3) || addr > sizeof(struct user) - 3) return -EIO; tmp = __peek_user_compat(child, addr); @@ -763,7 +763,7 @@ static int __poke_user_compat(struct task_struct *child, static int poke_user_compat(struct task_struct *child, addr_t addr, addr_t data) { - if (!is_compat_task() || (addr & 3) || + if (!in_compat_syscall() || (addr & 3) || addr > sizeof(struct compat_user) - 3) return -EIO; diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c index 028cc46cb82a..66762e126b20 100644 --- a/arch/s390/kernel/signal.c +++ b/arch/s390/kernel/signal.c @@ -498,7 +498,7 @@ void do_signal(struct pt_regs *regs) /* No longer in a system call */ clear_pt_regs_flag(regs, PIF_SYSCALL); - if (is_compat_task()) + if (in_compat_syscall()) handle_signal32(&ksig, oldset, regs); else handle_signal(&ksig, oldset, regs); diff --git a/arch/s390/kernel/uprobes.c b/arch/s390/kernel/uprobes.c index 66956c09d5bf..9a0b88dfaefb 100644 --- a/arch/s390/kernel/uprobes.c +++ b/arch/s390/kernel/uprobes.c @@ -27,7 +27,7 @@ int arch_uprobe_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) { if (psw_bits(regs->psw).eaba == PSW_AMODE_24BIT) return -EINVAL; - if (!is_compat_task() && psw_bits(regs->psw).eaba == PSW_AMODE_31BIT) + if (!in_compat_syscall() && psw_bits(regs->psw).eaba == PSW_AMODE_31BIT) return -EINVAL; clear_pt_regs_flag(regs, PIF_PER_TRAP); auprobe->saved_per = psw_bits(regs->psw).r; @@ -372,7 +372,7 @@ bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs) { if ((psw_bits(regs->psw).eaba == PSW_AMODE_24BIT) || ((psw_bits(regs->psw).eaba == PSW_AMODE_31BIT) && - !is_compat_task())) { + !in_compat_syscall())) { regs->psw.addr = __rewind_psw(regs->psw, UPROBE_SWBP_INSN_SIZE); do_report_trap(regs, SIGILL, ILL_ILLADR, NULL); return true; diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c index 94495cac8be3..bc1b9a35ad2b 100644 --- a/arch/s390/kernel/vdso.c +++ b/arch/s390/kernel/vdso.c @@ -197,7 +197,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) vdso_pagelist = vdso64_pagelist; vdso_pages = vdso64_pages; #ifdef CONFIG_COMPAT - if (is_compat_task()) { + if (in_compat_syscall()) { vdso_pagelist = vdso32_pagelist; vdso_pages = vdso32_pages; } diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index ea01477b4aa6..9bd23548415d 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -169,7 +169,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, int s390_mmap_check(unsigned long addr, unsigned long len, unsigned long flags) { - if (is_compat_task() || (TASK_SIZE >= (1UL << 53))) + if (in_compat_syscall() || (TASK_SIZE >= (1UL << 53))) return 0; if (!(flags & MAP_FIXED)) addr = 0; @@ -189,7 +189,7 @@ s390_get_unmapped_area(struct file *filp, unsigned long addr, area = arch_get_unmapped_area(filp, addr, len, pgoff, flags); if (!(area & ~PAGE_MASK)) return area; - if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < (1UL << 53)) { + if (area == -ENOMEM && !in_compat_syscall() && TASK_SIZE < (1UL << 53)) { /* Upgrade the page table to 4 levels and retry. */ rc = crst_table_upgrade(mm, 1UL << 53); if (rc) @@ -211,7 +211,7 @@ s390_get_unmapped_area_topdown(struct file *filp, const unsigned long addr, area = arch_get_unmapped_area_topdown(filp, addr, len, pgoff, flags); if (!(area & ~PAGE_MASK)) return area; - if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < (1UL << 53)) { + if (area == -ENOMEM && !in_compat_syscall() && TASK_SIZE < (1UL << 53)) { /* Upgrade the page table to 4 levels and retry. */ rc = crst_table_upgrade(mm, 1UL << 53); if (rc) diff --git a/arch/sparc/include/asm/compat.h b/arch/sparc/include/asm/compat.h index 830502fe62b4..8b3f137cf2e5 100644 --- a/arch/sparc/include/asm/compat.h +++ b/arch/sparc/include/asm/compat.h @@ -302,7 +302,7 @@ struct compat_shmid64_ds { unsigned int __unused2; }; -static inline int is_compat_task(void) +static inline int in_compat_syscall(void) { return test_thread_flag(TIF_32BIT); } diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h index c14e36f008c8..0d788778ca56 100644 --- a/arch/tile/include/asm/compat.h +++ b/arch/tile/include/asm/compat.h @@ -262,7 +262,7 @@ static inline void __user *arch_compat_alloc_user_space(long len) return (void __user *)regs->sp - len; } -static inline int is_compat_task(void) +static inline int in_compat_syscall(void) { return current_thread_info()->status & TS_COMPAT; } diff --git a/arch/tile/include/asm/syscall.h b/arch/tile/include/asm/syscall.h index 373d73064ea1..a39f4d0cf876 100644 --- a/arch/tile/include/asm/syscall.h +++ b/arch/tile/include/asm/syscall.h @@ -98,7 +98,7 @@ static inline void syscall_set_arguments(struct task_struct *task, */ static inline int syscall_get_arch(void) { - if (is_compat_task()) + if (in_compat_syscall()) return AUDIT_ARCH_TILEGX32; #ifdef CONFIG_TILEGX diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c index 7d5769310bef..be577d2a6fe5 100644 --- a/arch/tile/kernel/process.c +++ b/arch/tile/kernel/process.c @@ -573,7 +573,7 @@ void tile_show_regs(struct pt_regs *regs) #endif pr_err(" pc : "REGFMT" ex1: %ld faultnum: %ld flags:%s%s%s%s\n", regs->pc, regs->ex1, regs->faultnum, - is_compat_task() ? " compat" : "", + in_compat_syscall() ? " compat" : "", (regs->flags & PT_FLAGS_DISABLE_IRQ) ? " noirq" : "", !(regs->flags & PT_FLAGS_CALLER_SAVES) ? " nocallersave" : "", (regs->flags & PT_FLAGS_RESTORE_REGS) ? " restoreregs" : ""); diff --git a/arch/tile/kernel/ptrace.c b/arch/tile/kernel/ptrace.c index bdc126faf741..7a96fa24fb9b 100644 --- a/arch/tile/kernel/ptrace.c +++ b/arch/tile/kernel/ptrace.c @@ -163,7 +163,7 @@ long arch_ptrace(struct task_struct *child, long request, break; childreg = getregs(child, ©regs) + addr; #ifdef CONFIG_COMPAT - if (is_compat_task()) { + if (in_compat_syscall()) { if (addr & (sizeof(compat_long_t)-1)) break; ret = put_user(*(compat_long_t *)childreg, @@ -182,7 +182,7 @@ long arch_ptrace(struct task_struct *child, long request, break; childreg = getregs(child, ©regs) + addr; #ifdef CONFIG_COMPAT - if (is_compat_task()) { + if (in_compat_syscall()) { if (addr & (sizeof(compat_long_t)-1)) break; *(compat_long_t *)childreg = data; diff --git a/arch/tile/kernel/signal.c b/arch/tile/kernel/signal.c index 87299a6cfec8..473b816724bb 100644 --- a/arch/tile/kernel/signal.c +++ b/arch/tile/kernel/signal.c @@ -237,7 +237,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) /* Set up the stack frame */ #ifdef CONFIG_COMPAT - if (is_compat_task()) + if (in_compat_syscall()) ret = compat_setup_rt_frame(ksig, oldset, regs); else #endif diff --git a/arch/tile/kernel/unaligned.c b/arch/tile/kernel/unaligned.c index d075f92ccee0..17cee9931c82 100644 --- a/arch/tile/kernel/unaligned.c +++ b/arch/tile/kernel/unaligned.c @@ -1559,7 +1559,7 @@ void do_unaligned(struct pt_regs *regs, int vecnum) * the kernel will choose another location and we'll * remember it for later. */ - if (is_compat_task()) + if (in_compat_syscall()) user_page = NULL; else user_page = (void __user *)(TASK_SIZE - (1UL << 36)) + diff --git a/arch/tile/kernel/vdso.c b/arch/tile/kernel/vdso.c index 5bc51d7dfdcb..8f4619990331 100644 --- a/arch/tile/kernel/vdso.c +++ b/arch/tile/kernel/vdso.c @@ -137,7 +137,7 @@ int setup_vdso_pages(void) pagelist = vdso_pagelist; pages = vdso_pages; #ifdef CONFIG_COMPAT - if (is_compat_task()) { + if (in_compat_syscall()) { pagelist = vdso32_pagelist; pages = vdso32_pages; } diff --git a/arch/tile/mm/mmap.c b/arch/tile/mm/mmap.c index 851a94e6ae58..40eda4df41d0 100644 --- a/arch/tile/mm/mmap.c +++ b/arch/tile/mm/mmap.c @@ -54,7 +54,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm) #if !defined(__tilegx__) int is_32bit = 1; #elif defined(CONFIG_COMPAT) - int is_32bit = is_compat_task(); + int is_32bit = in_compat_syscall(); #else int is_32bit = 0; #endif diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h index acdee09228b3..5c2631d07043 100644 --- a/arch/x86/include/asm/compat.h +++ b/arch/x86/include/asm/compat.h @@ -316,7 +316,7 @@ static inline bool is_x32_task(void) return false; } -static inline bool is_compat_task(void) +static inline bool in_compat_syscall(void) { return is_ia32_task() || is_x32_task(); } diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h index 24938852db30..21b66dbf3601 100644 --- a/arch/x86/include/asm/ftrace.h +++ b/arch/x86/include/asm/ftrace.h @@ -58,7 +58,7 @@ int ftrace_int3_handler(struct pt_regs *regs); #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) { - if (is_compat_task()) + if (in_compat_syscall()) return true; return false; } diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index b9d99e0f82c4..71a18a22ae2f 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -476,7 +476,7 @@ void set_personality_ia32(bool x32) if (current->mm) current->mm->context.ia32_compat = TIF_X32; current->personality &= ~READ_IMPLIES_EXEC; - /* is_compat_task() uses the presence of the x32 + /* in_compat_syscall() uses the presence of the x32 syscall bit flag to determine compat status */ current_thread_info()->status &= ~TS_COMPAT; } else { diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 36a7c2d89a01..aee149bdf4c0 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -221,7 +221,7 @@ struct inbound_phy_packet_event { #ifdef CONFIG_COMPAT static void __user *u64_to_uptr(u64 value) { - if (is_compat_task()) + if (in_compat_syscall()) return compat_ptr(value); else return (void __user *)(unsigned long)value; @@ -229,7 +229,7 @@ static void __user *u64_to_uptr(u64 value) static u64 uptr_to_u64(void __user *ptr) { - if (is_compat_task()) + if (in_compat_syscall()) return ptr_to_compat(ptr); else return (u64)(unsigned long)ptr; diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c index 756eca8c4cf8..21c3b2016b2d 100644 --- a/drivers/firmware/efi/efivars.c +++ b/drivers/firmware/efi/efivars.c @@ -231,7 +231,7 @@ sanity_check(struct efi_variable *var, efi_char16_t *name, efi_guid_t vendor, static inline bool is_compat(void) { - if (IS_ENABLED(CONFIG_COMPAT) && is_compat_task()) + if (IS_ENABLED(CONFIG_COMPAT) && in_compat_syscall()) return true; return false; diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index d2b49c026cf6..07ac724e3ec9 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -107,7 +107,7 @@ static int kfd_open(struct inode *inode, struct file *filep) if (iminor(inode) != 0) return -ENODEV; - is_32bit_user_mode = is_compat_task(); + is_32bit_user_mode = in_compat_syscall(); if (is_32bit_user_mode == true) { dev_warn(kfd_device, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index 9be007081b72..fd1a90a0f435 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -311,7 +311,7 @@ static struct kfd_process *create_process(const struct task_struct *thread) goto err_process_pqm_init; /* init process apertures*/ - process->is_32bit_user_mode = is_compat_task(); + process->is_32bit_user_mode = in_compat_syscall(); if (kfd_init_apertures(process) != 0) goto err_init_apretures; diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index e094c572b86e..16b6f11a0700 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c @@ -384,7 +384,7 @@ struct uhid_create_req_compat { static int uhid_event_from_user(const char __user *buffer, size_t len, struct uhid_event *event) { - if (is_compat_task()) { + if (in_compat_syscall()) { u32 type; if (get_user(type, buffer)) diff --git a/drivers/input/input-compat.h b/drivers/input/input-compat.h index 148f66fe3205..fbe4337b7316 100644 --- a/drivers/input/input-compat.h +++ b/drivers/input/input-compat.h @@ -20,7 +20,7 @@ /* Note to the author of this code: did it ever occur to you why the ifdefs are needed? Think about it again. -AK */ #if defined(CONFIG_X86_64) || defined(CONFIG_TILE) -# define INPUT_COMPAT_TEST is_compat_task() +# define INPUT_COMPAT_TEST in_compat_syscall() #elif defined(CONFIG_S390) # define INPUT_COMPAT_TEST test_thread_flag(TIF_31BIT) #elif defined(CONFIG_MIPS) diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index 9083247f55a8..d798feba52f8 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c @@ -4006,7 +4006,7 @@ static int dasd_symm_io(struct dasd_device *device, void __user *argp) rc = -EFAULT; if (copy_from_user(&usrparm, argp, sizeof(usrparm))) goto out; - if (is_compat_task()) { + if (in_compat_syscall()) { /* Make sure pointers are sane even on 31 bit. */ rc = -EINVAL; if ((usrparm.psf_data >> 32) != 0) diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c index 02837d0ad942..7c4f3dd13965 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c @@ -504,7 +504,7 @@ int dasd_ioctl(struct block_device *bdev, fmode_t mode, void __user *argp; int rc; - if (is_compat_task()) + if (in_compat_syscall()) argp = compat_ptr(arg); else argp = (void __user *)arg; diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c index 71e974738014..c91f3318be3c 100644 --- a/drivers/s390/char/fs3270.c +++ b/drivers/s390/char/fs3270.c @@ -333,7 +333,7 @@ fs3270_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) fp = filp->private_data; if (!fp) return -ENODEV; - if (is_compat_task()) + if (in_compat_syscall()) argp = compat_ptr(arg); else argp = (char __user *)arg; diff --git a/drivers/s390/char/sclp_ctl.c b/drivers/s390/char/sclp_ctl.c index 648cb86afd42..1274d583d7bc 100644 --- a/drivers/s390/char/sclp_ctl.c +++ b/drivers/s390/char/sclp_ctl.c @@ -43,7 +43,7 @@ static int sclp_ctl_cmdw_supported(unsigned int cmdw) static void __user *u64_to_uptr(u64 value) { - if (is_compat_task()) + if (in_compat_syscall()) return compat_ptr(value); else return (void __user *)(unsigned long)value; @@ -93,7 +93,7 @@ static long sclp_ctl_ioctl(struct file *filp, unsigned int cmd, { void __user *argp; - if (is_compat_task()) + if (in_compat_syscall()) argp = compat_ptr(arg); else argp = (void __user *) arg; diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c index 2a67b496a9e2..f4e134e42bae 100644 --- a/drivers/s390/char/vmcp.c +++ b/drivers/s390/char/vmcp.c @@ -134,7 +134,7 @@ static long vmcp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) int temp; session = file->private_data; - if (is_compat_task()) + if (in_compat_syscall()) argp = compat_ptr(arg); else argp = (int __user *)arg; diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c index b6f12c2bb114..be3a0cb5e23c 100644 --- a/drivers/s390/cio/chsc_sch.c +++ b/drivers/s390/cio/chsc_sch.c @@ -883,7 +883,7 @@ static long chsc_ioctl(struct file *filp, unsigned int cmd, void __user *argp; CHSC_MSG(2, "chsc_ioctl called, cmd=%x\n", cmd); - if (is_compat_task()) + if (in_compat_syscall()) argp = compat_ptr(arg); else argp = (void __user *)arg; diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 787153764120..b6574b39a9f8 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -4699,7 +4699,7 @@ int qeth_query_oat_command(struct qeth_card *card, char __user *udata) rc = qeth_send_ipa_cmd(card, iob, qeth_setadpparms_query_oat_cb, &priv); if (!rc) { - if (is_compat_task()) + if (in_compat_syscall()) tmp = compat_ptr(oat_data.ptr); else tmp = (void __user *)(unsigned long)oat_data.ptr; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index ee8a1d67d191..275bce53578d 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -649,7 +649,7 @@ static inline int ll_need_32bit_api(struct ll_sb_info *sbi) #if BITS_PER_LONG == 32 return 1; #elif defined(CONFIG_COMPAT) - return unlikely(is_compat_task() || (sbi->ll_flags & LL_SBI_32BIT_API)); + return unlikely(in_compat_syscall() || (sbi->ll_flags & LL_SBI_32BIT_API)); #else return unlikely(sbi->ll_flags & LL_SBI_32BIT_API); #endif diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index 1d1bca74f844..6395456edea6 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c @@ -276,7 +276,7 @@ errout: static inline int is_32bit_api(void) { #ifdef CONFIG_COMPAT - return is_compat_task(); + return in_compat_syscall(); #else return (BITS_PER_LONG == 32); #endif diff --git a/include/linux/compat.h b/include/linux/compat.h index a76c9172b2eb..4d5353dc97f5 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -715,7 +715,7 @@ asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32, int, const char __user *); #else -#define is_compat_task() (0) +#define in_compat_syscall() (0) #endif /* CONFIG_COMPAT */ #endif /* _LINUX_COMPAT_H */ diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 195ffaee50b9..68ea5c35e1c7 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2412,7 +2412,7 @@ void __audit_seccomp(unsigned long syscall, long signr, int code) return; audit_log_task(ab); audit_log_format(ab, " sig=%ld arch=%x syscall=%ld compat=%d ip=0x%lx code=0x%x", - signr, syscall_get_arch(), syscall, is_compat_task(), + signr, syscall_get_arch(), syscall, in_compat_syscall(), KSTK_EIP(current), code); audit_log_end(ab); } diff --git a/kernel/ptrace.c b/kernel/ptrace.c index b760bae64cf1..a7538f8248fb 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -652,7 +652,7 @@ static int ptrace_peek_siginfo(struct task_struct *child, break; #ifdef CONFIG_COMPAT - if (unlikely(is_compat_task())) { + if (unlikely(in_compat_syscall())) { compat_siginfo_t __user *uinfo = compat_ptr(data); if (copy_siginfo_to_user32(uinfo, &info) || diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 580ac2d4024f..26858fa43a60 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -395,7 +395,7 @@ seccomp_prepare_user_filter(const char __user *user_filter) struct seccomp_filter *filter = ERR_PTR(-EFAULT); #ifdef CONFIG_COMPAT - if (is_compat_task()) { + if (in_compat_syscall()) { struct compat_sock_fprog fprog32; if (copy_from_user(&fprog32, user_filter, sizeof(fprog32))) goto out; @@ -529,7 +529,7 @@ static void __secure_computing_strict(int this_syscall) { int *syscall_whitelist = mode1_syscalls; #ifdef CONFIG_COMPAT - if (is_compat_task()) + if (in_compat_syscall()) syscall_whitelist = mode1_syscalls_32; #endif do { diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 9bb80ec4c08f..20ab6b2bbbb9 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -1389,7 +1389,7 @@ static int sctp_getsockopt_connectx3(struct sock *sk, int len, int err = 0; #ifdef CONFIG_COMPAT - if (is_compat_task()) { + if (in_compat_syscall()) { struct compat_sctp_getaddrs_old param32; if (len < sizeof(param32)) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 805681a7d356..2cc7af858c6f 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -2449,7 +2449,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) int type, err; #ifdef CONFIG_COMPAT - if (is_compat_task()) + if (in_compat_syscall()) return -ENOTSUPP; #endif -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html