Commit c3a5950a authored by Arun Sharma's avatar Arun Sharma Committed by Tony Luck

[IA64] sparse annotations and cleanups for ia32 subsystem

+ Add sparse annotations to ia32 subsystem so it checks out cleanly.
+ Add set_fs(KERNEL_DS) in elfcore32.h
+ Use compat_ptr() instead of P()
+ Fix a bug in ia32_sigsuspend() by introducing __ia32_rt_sigsuspend()
Signed-off-by: default avatarDavid Mosberger-Tang <davidm@hpl.hp.com>
Signed-off-by: default avatarArun Sharma <arun.sharma@intel.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent 795fff87
......@@ -103,11 +103,15 @@ static inline int
elf_core_copy_task_fpregs(struct task_struct *tsk, struct pt_regs *regs, elf_fpregset_t *fpu)
{
struct ia32_user_i387_struct *fpstate = (void*)fpu;
mm_segment_t old_fs;
if (!tsk->used_math)
return 0;
save_ia32_fpstate(tsk, fpstate);
old_fs = get_fs();
set_fs(KERNEL_DS);
save_ia32_fpstate(tsk, (struct ia32_user_i387_struct __user *) fpstate);
set_fs(old_fs);
return 1;
}
......@@ -117,11 +121,15 @@ static inline int
elf_core_copy_task_xfpregs(struct task_struct *tsk, elf_fpxregset_t *xfpu)
{
struct ia32_user_fxsr_struct *fpxstate = (void*) xfpu;
mm_segment_t old_fs;
if (!tsk->used_math)
return 0;
save_ia32_fpxstate(tsk, fpxstate);
old_fs = get_fs();
set_fs(KERNEL_DS);
save_ia32_fpxstate(tsk, (struct ia32_user_fxsr_struct __user *) fpxstate);
set_fs(old_fs);
return 1;
}
......
/*
* Copyright (C) 2001 Hewlett-Packard Co
* Copyright (C) 2001, 2004 Hewlett-Packard Co
* David Mosberger-Tang <davidm@hpl.hp.com>
*
* Adapted from arch/i386/kernel/ldt.c
......@@ -17,25 +17,24 @@
#include "ia32priv.h"
#define P(p) ((void *) (unsigned long) (p))
/*
* read_ldt() is not really atomic - this is not a problem since synchronization of reads
* and writes done to the LDT has to be assured by user-space anyway. Writes are atomic,
* to protect the security checks done on new descriptors.
*/
static int
read_ldt (void *ptr, unsigned long bytecount)
read_ldt (void __user *ptr, unsigned long bytecount)
{
char *src, *dst, buf[256]; /* temporary buffer (don't overflow kernel stack!) */
unsigned long bytes_left, n;
char __user *src, *dst;
char buf[256]; /* temporary buffer (don't overflow kernel stack!) */
if (bytecount > IA32_LDT_ENTRIES*IA32_LDT_ENTRY_SIZE)
bytecount = IA32_LDT_ENTRIES*IA32_LDT_ENTRY_SIZE;
bytes_left = bytecount;
src = (void *) IA32_LDT_OFFSET;
src = (void __user *) IA32_LDT_OFFSET;
dst = ptr;
while (bytes_left) {
......@@ -61,7 +60,7 @@ read_ldt (void *ptr, unsigned long bytecount)
}
static int
read_default_ldt (void * ptr, unsigned long bytecount)
read_default_ldt (void __user * ptr, unsigned long bytecount)
{
unsigned long size;
int err;
......@@ -80,7 +79,7 @@ read_default_ldt (void * ptr, unsigned long bytecount)
}
static int
write_ldt (void * ptr, unsigned long bytecount, int oldmode)
write_ldt (void __user * ptr, unsigned long bytecount, int oldmode)
{
struct ia32_user_desc ldt_info;
__u64 entry;
......@@ -120,7 +119,7 @@ write_ldt (void * ptr, unsigned long bytecount, int oldmode)
* memory, but we still need to guard against out-of-memory, hence we must use
* put_user().
*/
ret = __put_user(entry, (__u64 *) IA32_LDT_OFFSET + ldt_info.entry_number);
ret = __put_user(entry, (__u64 __user *) IA32_LDT_OFFSET + ldt_info.entry_number);
ia32_load_segment_descriptors(current);
return ret;
}
......@@ -132,16 +131,16 @@ sys32_modify_ldt (int func, unsigned int ptr, unsigned int bytecount)
switch (func) {
case 0:
ret = read_ldt(P(ptr), bytecount);
ret = read_ldt(compat_ptr(ptr), bytecount);
break;
case 1:
ret = write_ldt(P(ptr), bytecount, 1);
ret = write_ldt(compat_ptr(ptr), bytecount, 1);
break;
case 2:
ret = read_default_ldt(P(ptr), bytecount);
ret = read_default_ldt(compat_ptr(ptr), bytecount);
break;
case 0x11:
ret = write_ldt(P(ptr), bytecount, 0);
ret = write_ldt(compat_ptr(ptr), bytecount, 0);
break;
}
return ret;
......
This diff is collapsed.
......@@ -76,7 +76,7 @@ ia32_clone_tls (struct task_struct *child, struct pt_regs *childregs)
struct ia32_user_desc info;
int idx;
if (copy_from_user(&info, (void *)(childregs->r14 & 0xffffffff), sizeof(info)))
if (copy_from_user(&info, (void __user *)(childregs->r14 & 0xffffffff), sizeof(info)))
return -EFAULT;
if (LDT_empty(&info))
return -EINVAL;
......
......@@ -556,8 +556,8 @@ struct user_regs_struct32 {
};
/* Prototypes for use in elfcore32.h */
extern int save_ia32_fpstate (struct task_struct *tsk, struct ia32_user_i387_struct *save);
extern int save_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct *save);
extern int save_ia32_fpstate (struct task_struct *, struct ia32_user_i387_struct __user *);
extern int save_ia32_fpxstate (struct task_struct *, struct ia32_user_fxsr_struct __user *);
#endif /* !CONFIG_IA32_SUPPORT */
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment