diff options
Diffstat (limited to 'arch/x86/um/tls_32.c')
-rw-r--r-- | arch/x86/um/tls_32.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c index 66162eafd8e8..cb3f17627d16 100644 --- a/arch/x86/um/tls_32.c +++ b/arch/x86/um/tls_32.c @@ -11,6 +11,8 @@ #include <os.h> #include <skas.h> #include <sysdep/tls.h> +#include <asm/desc.h> +#include <stub-data.h> /* * If needed we can detect when it's uninitialized. @@ -20,33 +22,28 @@ static int host_supports_tls = -1; int host_gdt_entry_tls_min; -int do_set_thread_area(struct user_desc *info) +static int do_set_thread_area(struct task_struct* task, struct user_desc *info) { int ret; - u32 cpu; - cpu = get_cpu(); - ret = os_set_thread_area(info, userspace_pid[cpu]); - put_cpu(); + if (info->entry_number < host_gdt_entry_tls_min || + info->entry_number >= host_gdt_entry_tls_min + GDT_ENTRY_TLS_ENTRIES) + return -EINVAL; - if (ret) - printk(KERN_ERR "PTRACE_SET_THREAD_AREA failed, err = %d, " - "index = %d\n", ret, info->entry_number); + if (using_seccomp) { + int idx = info->entry_number - host_gdt_entry_tls_min; + struct stub_data *data = (void *)task->mm->context.id.stack; - return ret; -} + data->arch_data.tls[idx] = *info; + data->arch_data.sync |= BIT(idx); -int do_get_thread_area(struct user_desc *info) -{ - int ret; - u32 cpu; + return 0; + } - cpu = get_cpu(); - ret = os_get_thread_area(info, userspace_pid[cpu]); - put_cpu(); + ret = os_set_thread_area(info, task->mm->context.id.pid); if (ret) - printk(KERN_ERR "PTRACE_GET_THREAD_AREA failed, err = %d, " + printk(KERN_ERR "PTRACE_SET_THREAD_AREA failed, err = %d, " "index = %d\n", ret, info->entry_number); return ret; @@ -112,7 +109,7 @@ static int load_TLS(int flags, struct task_struct *to) if (!(flags & O_FORCE) && curr->flushed) continue; - ret = do_set_thread_area(&curr->tls); + ret = do_set_thread_area(current, &curr->tls); if (ret) goto out; @@ -231,7 +228,6 @@ out: return ret; } -/* XXX: use do_get_thread_area to read the host value? I'm not at all sure! */ static int get_tls_entry(struct task_struct *task, struct user_desc *info, int idx) { @@ -291,7 +287,7 @@ SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, user_desc) return -EFAULT; } - ret = do_set_thread_area(&info); + ret = do_set_thread_area(current, &info); if (ret) return ret; return set_tls_entry(current, &info, idx, 1); |