Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169999
b: refs/heads/master
c: da3f6f9
h: refs/heads/master
i:
  169997: f805c05
  169995: aacf77c
  169991: 71a030c
  169983: e3df3fc
v: v3
  • Loading branch information
Eric W. Biederman committed Nov 6, 2009
1 parent 7fc8c2b commit 065ee7e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 53 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2830b68361a9f58354ad043c6d85043ea917f907
refs/heads/master: da3f6f9b3e0d1e73975ca81ae124406bf1587d40
52 changes: 0 additions & 52 deletions trunk/arch/powerpc/kernel/sys_ppc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,58 +520,6 @@ asmlinkage long compat_sys_umask(u32 mask)
return sys_umask((int)mask);
}

#ifdef CONFIG_SYSCTL_SYSCALL
struct __sysctl_args32 {
u32 name;
int nlen;
u32 oldval;
u32 oldlenp;
u32 newval;
u32 newlen;
u32 __unused[4];
};

asmlinkage long compat_sys_sysctl(struct __sysctl_args32 __user *args)
{
struct __sysctl_args32 tmp;
int error;
size_t oldlen;
size_t __user *oldlenp = NULL;
unsigned long addr = (((unsigned long)&args->__unused[0]) + 7) & ~7;

if (copy_from_user(&tmp, args, sizeof(tmp)))
return -EFAULT;

if (tmp.oldval && tmp.oldlenp) {
/* Duh, this is ugly and might not work if sysctl_args
is in read-only memory, but do_sysctl does indirectly
a lot of uaccess in both directions and we'd have to
basically copy the whole sysctl.c here, and
glibc's __sysctl uses rw memory for the structure
anyway. */
oldlenp = (size_t __user *)addr;
if (get_user(oldlen, (compat_size_t __user *)compat_ptr(tmp.oldlenp)) ||
put_user(oldlen, oldlenp))
return -EFAULT;
}

lock_kernel();
error = do_sysctl(compat_ptr(tmp.name), tmp.nlen,
compat_ptr(tmp.oldval), oldlenp,
compat_ptr(tmp.newval), tmp.newlen);
unlock_kernel();
if (oldlenp) {
if (!error) {
if (get_user(oldlen, oldlenp) ||
put_user(oldlen, (compat_size_t __user *)compat_ptr(tmp.oldlenp)))
error = -EFAULT;
}
copy_to_user(args->__unused, tmp.__unused, sizeof(tmp.__unused));
}
return error;
}
#endif

unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
unsigned long prot, unsigned long flags,
unsigned long fd, unsigned long pgoff)
Expand Down
50 changes: 50 additions & 0 deletions trunk/kernel/sysctl_binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,53 @@ SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)

return error;
}

#ifdef CONFIG_COMPAT
#include <asm/compat.h>

struct compat_sysctl_args {
compat_uptr_t name;
int nlen;
compat_uptr_t oldval;
compat_uptr_t oldlenp;
compat_uptr_t newval;
compat_size_t newlen;
compat_ulong_t __unused[4];
};

asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args)
{
struct compat_sysctl_args tmp;
compat_size_t __user *compat_oldlenp;
size_t __user *oldlenp = NULL;
size_t oldlen = 0;
ssize_t result;

if (copy_from_user(&tmp, args, sizeof(tmp)))
return -EFAULT;

compat_oldlenp = compat_ptr(tmp.oldlenp);
if (compat_oldlenp) {
oldlenp = compat_alloc_user_space(sizeof(*compat_oldlenp));

if (get_user(oldlen, compat_oldlenp) ||
put_user(oldlen, oldlenp))
return -EFAULT;
}

lock_kernel();
result = do_sysctl(compat_ptr(tmp.name), tmp.nlen,
compat_ptr(tmp.oldval), oldlenp,
compat_ptr(tmp.newval), tmp.newlen);
unlock_kernel();

if (oldlenp && !result) {
if (get_user(oldlen, oldlenp) ||
put_user(oldlen, compat_oldlenp))
return -EFAULT;
}

return result;
}

#endif /* CONFIG_COMPAT */

0 comments on commit 065ee7e

Please sign in to comment.