2003-03-11 00:33:31

by Stephen Rothwell

[permalink] [raw]
Subject: [PATCH][COMPAT] compat_sys_fcntl{,64} 1/9 Generic part

Hi Linus,

This patch creates compat_sys_fcntl{,64}. The diffstat for the whole
patch set is below, but this is just the generic part, the architecture
specific parts will follow.

This patch also removes struct flock64 from all the 64 bit architectures
(except parisc).

I think I have answered all the questions from the last time I posted
this, so please apply.

arch/ia64/ia32/ia32_entry.S | 4 -
arch/ia64/ia32/sys_ia32.c | 92 -----------------------
arch/mips64/kernel/linux32.c | 44 -----------
arch/mips64/kernel/scall_o32.S | 4 -
arch/parisc/kernel/sys_parisc32.c | 51 -------------
arch/parisc/kernel/syscall.S | 5 -
arch/ppc64/kernel/misc.S | 4 -
arch/ppc64/kernel/sys_ppc32.c | 33 --------
arch/s390x/kernel/entry.S | 4 -
arch/s390x/kernel/linux32.c | 51 -------------
arch/s390x/kernel/linux32.h | 4 -
arch/s390x/kernel/wrapper32.S | 12 +--
arch/sparc64/kernel/sys_sparc32.c | 35 ---------
arch/sparc64/kernel/systbls.S | 6 -
arch/x86_64/ia32/ia32entry.S | 4 -
arch/x86_64/ia32/sys_ia32.c | 96 ------------------------
fs/compat.c | 147 ++++++++++++++++++++++++++++++--------
include/asm-alpha/fcntl.h | 3
include/asm-ia64/compat.h | 19 ++++
include/asm-ia64/fcntl.h | 5 -
include/asm-ia64/ia32.h | 4 -
include/asm-mips64/compat.h | 18 ++++
include/asm-mips64/fcntl.h | 10 --
include/asm-parisc/compat.h | 11 ++
include/asm-ppc64/compat.h | 16 +++-
include/asm-ppc64/fcntl.h | 13 ---
include/asm-s390x/compat.h | 16 +++-
include/asm-s390x/fcntl.h | 2
include/asm-sparc64/compat.h | 16 ++++
include/asm-sparc64/fcntl.h | 11 --
include/asm-x86_64/compat.h | 19 ++++
include/asm-x86_64/fcntl.h | 4 -
include/asm-x86_64/ia32.h | 12 ---
include/linux/compat.h | 3
include/linux/fs.h | 2
35 files changed, 255 insertions(+), 525 deletions(-)

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003030918-32bit.1/fs/compat.c 2.5.64-2003030918-32bit.2/fs/compat.c
--- 2.5.64-2003030918-32bit.1/fs/compat.c 2003-01-14 09:57:57.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/fs/compat.c 2003-03-09 20:34:45.000000000 +1100
@@ -75,36 +75,6 @@
return error;
}

-int get_compat_flock(struct flock *kfl, struct compat_flock *ufl)
-{
- int err;
-
- if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)))
- return -EFAULT;
-
- err = __get_user(kfl->l_type, &ufl->l_type);
- err |= __get_user(kfl->l_whence, &ufl->l_whence);
- err |= __get_user(kfl->l_start, &ufl->l_start);
- err |= __get_user(kfl->l_len, &ufl->l_len);
- err |= __get_user(kfl->l_pid, &ufl->l_pid);
- return err;
-}
-
-int put_compat_flock(struct flock *kfl, struct compat_flock *ufl)
-{
- int err;
-
- if (!access_ok(VERIFY_WRITE, ufl, sizeof(*ufl)))
- return -EFAULT;
-
- err = __put_user(kfl->l_type, &ufl->l_type);
- err |= __put_user(kfl->l_whence, &ufl->l_whence);
- err |= __put_user(kfl->l_start, &ufl->l_start);
- err |= __put_user(kfl->l_len, &ufl->l_len);
- err |= __put_user(kfl->l_pid, &ufl->l_pid);
- return err;
-}
-
static int put_compat_statfs(struct compat_statfs *ubuf, struct statfs *kbuf)
{
if (verify_area(VERIFY_WRITE, ubuf, sizeof(*ubuf)) ||
@@ -159,3 +129,120 @@
out:
return error;
}
+
+static int get_compat_flock(struct flock *kfl, struct compat_flock *ufl)
+{
+ if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) ||
+ __get_user(kfl->l_type, &ufl->l_type) ||
+ __get_user(kfl->l_whence, &ufl->l_whence) ||
+ __get_user(kfl->l_start, &ufl->l_start) ||
+ __get_user(kfl->l_len, &ufl->l_len) ||
+ __get_user(kfl->l_pid, &ufl->l_pid))
+ return -EFAULT;
+ return 0;
+}
+
+static int put_compat_flock(struct flock *kfl, struct compat_flock *ufl)
+{
+ if (!access_ok(VERIFY_WRITE, ufl, sizeof(*ufl)) ||
+ __put_user(kfl->l_type, &ufl->l_type) ||
+ __put_user(kfl->l_whence, &ufl->l_whence) ||
+ __put_user(kfl->l_start, &ufl->l_start) ||
+ __put_user(kfl->l_len, &ufl->l_len) ||
+ __put_user(kfl->l_pid, &ufl->l_pid))
+ return -EFAULT;
+ return 0;
+}
+
+static int get_compat_flock64(struct flock *kfl, struct compat_flock64 *ufl)
+{
+ if (!access_ok(VERIFY_READ, ufl, sizeof(*ufl)) ||
+ __get_user(kfl->l_type, &ufl->l_type) ||
+ __get_user(kfl->l_whence, &ufl->l_whence) ||
+ __get_user(kfl->l_start, &ufl->l_start) ||
+ __get_user(kfl->l_len, &ufl->l_len) ||
+ __get_user(kfl->l_pid, &ufl->l_pid))
+ return -EFAULT;
+ return 0;
+}
+
+static int put_compat_flock64(struct flock *kfl, struct compat_flock64 *ufl)
+{
+ if (!access_ok(VERIFY_WRITE, ufl, sizeof(*ufl)) ||
+ __put_user(kfl->l_type, &ufl->l_type) ||
+ __put_user(kfl->l_whence, &ufl->l_whence) ||
+ __put_user(kfl->l_start, &ufl->l_start) ||
+ __put_user(kfl->l_len, &ufl->l_len) ||
+ __put_user(kfl->l_pid, &ufl->l_pid))
+ return -EFAULT;
+ return 0;
+}
+
+extern asmlinkage long sys_fcntl(unsigned int, unsigned int, unsigned long);
+
+asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
+ unsigned long arg)
+{
+ mm_segment_t old_fs;
+ struct flock f;
+ long ret;
+
+ switch (cmd) {
+ case F_GETLK:
+ case F_SETLK:
+ case F_SETLKW:
+ ret = get_compat_flock(&f, (struct compat_flock *)arg);
+ if (ret != 0)
+ break;
+ old_fs = get_fs();
+ set_fs(KERNEL_DS);
+ ret = sys_fcntl(fd, cmd, (unsigned long)&f);
+ set_fs(old_fs);
+ if ((cmd == F_GETLK) && (ret == 0)) {
+ if ((f.l_start >= COMPAT_OFF_T_MAX) ||
+ ((f.l_start + f.l_len) >= COMPAT_OFF_T_MAX))
+ ret = -EOVERFLOW;
+ if (ret == 0)
+ ret = put_compat_flock(&f,
+ (struct compat_flock *)arg);
+ }
+ break;
+
+ case F_GETLK64:
+ case F_SETLK64:
+ case F_SETLKW64:
+ ret = get_compat_flock64(&f, (struct compat_flock64 *)arg);
+ if (ret != 0)
+ break;
+ old_fs = get_fs();
+ set_fs(KERNEL_DS);
+ ret = sys_fcntl(fd, F_GETLK, (unsigned long)&f);
+ ret = sys_fcntl(fd, (cmd == F_GETLK64) ? F_GETLK :
+ ((cmd == F_SETLK64) ? F_SETLK : F_SETLKW),
+ (unsigned long)&f);
+ set_fs(old_fs);
+ if ((cmd == F_GETLK64) && (ret == 0)) {
+ if ((f.l_start >= COMPAT_LOFF_T_MAX) ||
+ ((f.l_start + f.l_len) >= COMPAT_LOFF_T_MAX))
+ ret = -EOVERFLOW;
+ if (ret == 0)
+ ret = put_compat_flock64(&f,
+ (struct compat_flock64 *)arg);
+ }
+ break;
+
+ default:
+ ret = sys_fcntl(fd, cmd, arg);
+ break;
+ }
+ return ret;
+}
+
+asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
+ unsigned long arg)
+{
+ if ((cmd == F_GETLK64) || (cmd == F_SETLK64) || (cmd == F_SETLKW64))
+ return -EINVAL;
+ return compat_sys_fcntl64(fd, cmd, arg);
+}
+
diff -ruN 2.5.64-2003030918-32bit.1/include/linux/compat.h 2.5.64-2003030918-32bit.2/include/linux/compat.h
--- 2.5.64-2003030918-32bit.1/include/linux/compat.h 2003-01-17 14:01:07.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/linux/compat.h 2003-03-09 20:34:45.000000000 +1100
@@ -10,7 +10,6 @@

#include <linux/stat.h>
#include <linux/param.h> /* for HZ */
-#include <linux/fcntl.h> /* for struct flock */
#include <asm/compat.h>

#define compat_jiffies_to_clock_t(x) \
@@ -40,8 +39,6 @@
} compat_sigset_t;

extern int cp_compat_stat(struct kstat *, struct compat_stat *);
-extern int get_compat_flock(struct flock *, struct compat_flock *);
-extern int put_compat_flock(struct flock *, struct compat_flock *);
extern int get_compat_timespec(struct timespec *, struct compat_timespec *);
extern int put_compat_timespec(struct timespec *, struct compat_timespec *);

diff -ruN 2.5.64-2003030918-32bit.1/include/linux/fs.h 2.5.64-2003030918-32bit.2/include/linux/fs.h
--- 2.5.64-2003030918-32bit.1/include/linux/fs.h 2003-03-09 20:09:18.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/linux/fs.h 2003-03-09 20:34:45.000000000 +1100
@@ -526,8 +526,10 @@
extern int fcntl_getlk(struct file *, struct flock *);
extern int fcntl_setlk(struct file *, unsigned int, struct flock *);

+#if BITS_PER_LONG == 32
extern int fcntl_getlk64(struct file *, struct flock64 *);
extern int fcntl_setlk64(struct file *, unsigned int, struct flock64 *);
+#endif

/* fs/locks.c */
extern void locks_init_lock(struct file_lock *);


2003-03-11 00:37:03

by Stephen Rothwell

[permalink] [raw]
Subject: [PATCH][COMPAT] compat_sys_fcntl{,64} 2/9 ppc64 part

Hi Anton,

Here is the ppc64 part. Please apply after Linus has applied the generic
part.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003030918-32bit.1/arch/ppc64/kernel/misc.S 2.5.64-2003030918-32bit.2/arch/ppc64/kernel/misc.S
--- 2.5.64-2003030918-32bit.1/arch/ppc64/kernel/misc.S 2003-02-25 12:59:28.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/ppc64/kernel/misc.S 2003-03-09 20:34:44.000000000 +1100
@@ -557,7 +557,7 @@
.llong .sys32_umount
.llong .sys_ni_syscall /* old lock syscall */
.llong .sys32_ioctl
- .llong .sys32_fcntl /* 55 */
+ .llong .compat_sys_fcntl /* 55 */
.llong .sys_ni_syscall /* old mpx syscall */
.llong .sys32_setpgid
.llong .sys_ni_syscall /* old ulimit syscall */
@@ -706,7 +706,7 @@
.llong .sys_ni_syscall /* reserved for MacOnLinux */
.llong .sys_getdents64
.llong .sys_pivot_root
- .llong .sys32_fcntl64
+ .llong .compat_sys_fcntl64
.llong .sys_madvise /* 205 */
.llong .sys_mincore
.llong .sys_gettid
diff -ruN 2.5.64-2003030918-32bit.1/arch/ppc64/kernel/sys_ppc32.c 2.5.64-2003030918-32bit.2/arch/ppc64/kernel/sys_ppc32.c
--- 2.5.64-2003030918-32bit.1/arch/ppc64/kernel/sys_ppc32.c 2003-02-25 12:59:29.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/ppc64/kernel/sys_ppc32.c 2003-03-09 20:34:44.000000000 +1100
@@ -248,32 +248,6 @@
return ret;
}

-extern asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
-asmlinkage long sys32_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- switch (cmd) {
- case F_GETLK:
- case F_SETLK:
- case F_SETLKW:
- {
- struct flock f;
- mm_segment_t old_fs;
- long ret;
-
- if(get_compat_flock(&f, (struct compat_flock *)arg))
- return -EFAULT;
- old_fs = get_fs(); set_fs (KERNEL_DS);
- ret = sys_fcntl(fd, cmd, (unsigned long)&f);
- set_fs (old_fs);
- if(put_compat_flock(&f, (struct compat_flock *)arg))
- return -EFAULT;
- return ret;
- }
- default:
- return sys_fcntl(fd, cmd, (unsigned long)arg);
- }
-}
-
struct ncp_mount_data32_v3 {
int version;
unsigned int ncp_fd;
@@ -3552,13 +3526,6 @@
return sys_umount(name, (int)flags);
}

-asmlinkage long sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- if (cmd >= F_GETLK64 && cmd <= F_SETLKW64)
- return sys_fcntl(fd, cmd + F_GETLK - F_GETLK64, arg);
- return sys32_fcntl(fd, cmd, arg);
-}
-
struct __sysctl_args32 {
u32 name;
int nlen;
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-ppc64/compat.h 2.5.64-2003030918-32bit.2/include/asm-ppc64/compat.h
--- 2.5.64-2003030918-32bit.1/include/asm-ppc64/compat.h 2003-02-11 09:39:59.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-ppc64/compat.h 2003-03-09 20:34:45.000000000 +1100
@@ -61,7 +61,18 @@
compat_off_t l_start;
compat_off_t l_len;
compat_pid_t l_pid;
- short __unused;
+};
+
+#define F_GETLK64 12 /* using 'struct flock64' */
+#define F_SETLK64 13
+#define F_SETLKW64 14
+
+struct compat_flock64 {
+ short l_type;
+ short l_whence;
+ compat_loff_t l_start;
+ compat_loff_t l_len;
+ compat_pid_t l_pid;
};

struct compat_statfs {
@@ -84,4 +95,7 @@

typedef u32 compat_sigset_word;

+#define COMPAT_OFF_T_MAX 0x7fffffff
+#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
+
#endif /* _ASM_PPC64_COMPAT_H */
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-ppc64/fcntl.h 2.5.64-2003030918-32bit.2/include/asm-ppc64/fcntl.h
--- 2.5.64-2003030918-32bit.1/include/asm-ppc64/fcntl.h 2002-06-03 12:13:01.000000000 +1000
+++ 2.5.64-2003030918-32bit.2/include/asm-ppc64/fcntl.h 2003-03-09 20:34:45.000000000 +1100
@@ -42,10 +42,6 @@
#define F_SETSIG 10 /* for sockets. */
#define F_GETSIG 11 /* for sockets. */

-#define F_GETLK64 12 /* using 'struct flock64' */
-#define F_SETLK64 13
-#define F_SETLKW64 14
-
/* for F_[GET|SET]FL */
#define FD_CLOEXEC 1 /* actually anything with low bit set goes */

@@ -87,13 +83,6 @@
pid_t l_pid;
};

-struct flock64 {
- short l_type;
- short l_whence;
- loff_t l_start;
- loff_t l_len;
- pid_t l_pid;
-};
-
#define F_LINUX_SPECIFIC_BASE 1024
+
#endif /* _PPC64_FCNTL_H */

2003-03-11 00:39:36

by Stephen Rothwell

[permalink] [raw]
Subject: [PATCH][COMPAT] compat_sys_fcntl{,64} 3/9 sparc64 part

Hi Dave,

Here is the sparc64 part of the patch. Please apply after Linus applies
the gerneic part.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003030918-32bit.1/arch/sparc64/kernel/sys_sparc32.c 2.5.64-2003030918-32bit.2/arch/sparc64/kernel/sys_sparc32.c
--- 2.5.64-2003030918-32bit.1/arch/sparc64/kernel/sys_sparc32.c 2003-02-25 12:59:31.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/sparc64/kernel/sys_sparc32.c 2003-03-09 20:34:45.000000000 +1100
@@ -806,41 +806,6 @@
return err;
}

-extern asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
-
-asmlinkage long sys32_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- switch (cmd) {
- case F_GETLK:
- case F_SETLK:
- case F_SETLKW:
- {
- struct flock f;
- mm_segment_t old_fs;
- long ret;
-
- if (get_compat_flock(&f, (struct compat_flock *)arg))
- return -EFAULT;
- old_fs = get_fs(); set_fs (KERNEL_DS);
- ret = sys_fcntl(fd, cmd, (unsigned long)&f);
- set_fs (old_fs);
- if (ret) return ret;
- if (put_compat_flock(&f, (struct compat_flock *)arg))
- return -EFAULT;
- return 0;
- }
- default:
- return sys_fcntl(fd, cmd, (unsigned long)arg);
- }
-}
-
-asmlinkage long sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- if (cmd >= F_GETLK64 && cmd <= F_SETLKW64)
- return sys_fcntl(fd, cmd + F_GETLK - F_GETLK64, arg);
- return sys32_fcntl(fd, cmd, arg);
-}
-
extern asmlinkage long sys_truncate(const char * path, unsigned long length);
extern asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);

diff -ruN 2.5.64-2003030918-32bit.1/arch/sparc64/kernel/systbls.S 2.5.64-2003030918-32bit.2/arch/sparc64/kernel/systbls.S
--- 2.5.64-2003030918-32bit.1/arch/sparc64/kernel/systbls.S 2003-02-25 12:59:31.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/sparc64/kernel/systbls.S 2003-03-09 20:34:45.000000000 +1100
@@ -37,7 +37,7 @@
.word sys_madvise, sys_vhangup, sys32_truncate64, sys_mincore, sys32_getgroups16
/*80*/ .word sys32_setgroups16, sys_getpgrp, sys_setgroups, compat_sys_setitimer, sys32_ftruncate64
.word sys_swapon, compat_sys_getitimer, sys_setuid, sys_sethostname, sys_setgid
-/*90*/ .word sys_dup2, sys_setfsuid, sys32_fcntl, sys32_select, sys_setfsgid
+/*90*/ .word sys_dup2, sys_setfsuid, compat_sys_fcntl, sys32_select, sys_setfsgid
.word sys_fsync, sys_setpriority32, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall
/*100*/ .word sys_getpriority, sys32_rt_sigreturn, sys32_rt_sigaction, sys32_rt_sigprocmask, sys32_rt_sigpending
.word sys32_rt_sigtimedwait, sys32_rt_sigqueueinfo, sys32_rt_sigsuspend, sys_setresuid, sys_getresuid
@@ -50,7 +50,7 @@
/*140*/ .word sys32_sendfile64, sys_nis_syscall, compat_sys_futex, sys_gettid, sys32_getrlimit
.word sys32_setrlimit, sys_pivot_root, sys32_prctl, sys32_pciconfig_read, sys32_pciconfig_write
/*150*/ .word sys_nis_syscall, sys_nis_syscall, sys_nis_syscall, sys_poll, sys_getdents64
- .word sys32_fcntl64, sys_ni_syscall, compat_sys_statfs, compat_sys_fstatfs, sys_oldumount
+ .word compat_sys_fcntl64, sys_ni_syscall, compat_sys_statfs, compat_sys_fstatfs, sys_oldumount
/*160*/ .word sys32_sched_setaffinity, sys32_sched_getaffinity, sys_getdomainname, sys_setdomainname, sys_nis_syscall
.word sys_quotactl, sys_set_tid_address, sys32_mount, sys_ustat, sys_setxattr
/*170*/ .word sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr, sys32_getdents
@@ -172,7 +172,7 @@
.word compat_sys_setitimer, sunos_nosys, sys_swapon
.word compat_sys_getitimer, sys_gethostname, sys_sethostname
.word sunos_getdtablesize, sys_dup2, sunos_nop
- .word sys32_fcntl, sunos_select, sunos_nop
+ .word compat_sys_fcntl, sunos_select, sunos_nop
.word sys_fsync, sys_setpriority32, sunos_socket
.word sys_connect, sunos_accept
/*100*/ .word sys_getpriority, sunos_send, sunos_recv
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-sparc64/compat.h 2.5.64-2003030918-32bit.2/include/asm-sparc64/compat.h
--- 2.5.64-2003030918-32bit.1/include/asm-sparc64/compat.h 2003-02-11 09:40:00.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-sparc64/compat.h 2003-03-09 20:34:45.000000000 +1100
@@ -64,6 +64,19 @@
short __unused;
};

+#define F_GETLK64 12
+#define F_SETLK64 13
+#define F_SETLKW64 14
+
+struct compat_flock64 {
+ short l_type;
+ short l_whence;
+ compat_loff_t l_start;
+ compat_loff_t l_len;
+ compat_pid_t l_pid;
+ short __unused;
+};
+
struct compat_statfs {
int f_type;
int f_bsize;
@@ -84,4 +97,7 @@

typedef u32 compat_sigset_word;

+#define COMPAT_OFF_T_MAX 0x7fffffff
+#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
+
#endif /* _ASM_SPARC64_COMPAT_H */
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-sparc64/fcntl.h 2.5.64-2003030918-32bit.2/include/asm-sparc64/fcntl.h
--- 2.5.64-2003030918-32bit.1/include/asm-sparc64/fcntl.h 2003-01-09 16:24:05.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-sparc64/fcntl.h 2003-03-09 20:34:45.000000000 +1100
@@ -36,12 +36,6 @@
#define F_SETSIG 10 /* for sockets. */
#define F_GETSIG 11 /* for sockets. */

-#ifdef __KERNEL__
-#define F_GETLK64 12
-#define F_SETLK64 13
-#define F_SETLKW64 14
-#endif
-
/* for F_[GET|SET]FL */
#define FD_CLOEXEC 1 /* actually anything with low bit set goes */

@@ -78,9 +72,6 @@
short __unused;
};

-#ifdef __KERNEL__
-#define flock64 flock
-#endif
-
#define F_LINUX_SPECIFIC_BASE 1024
+
#endif /* !(_SPARC64_FCNTL_H) */

2003-03-11 00:44:03

by Stephen Rothwell

[permalink] [raw]
Subject: [PATCH][COMPAT] compat_sys_fcntl{,64} 5/9 ia64 part

Hi David,

Here is the ia64 part of the patch. Pleas apply after Linus has applied
the generic part.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003030918-32bit.1/arch/ia64/ia32/ia32_entry.S 2.5.64-2003030918-32bit.2/arch/ia64/ia32/ia32_entry.S
--- 2.5.64-2003030918-32bit.1/arch/ia64/ia32/ia32_entry.S 2003-03-09 20:08:57.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/ia64/ia32/ia32_entry.S 2003-03-09 20:34:44.000000000 +1100
@@ -253,7 +253,7 @@
data8 sys_umount /* recycled never used phys( */
data8 sys32_ni_syscall /* old lock syscall holder */
data8 sys32_ioctl
- data8 sys32_fcntl /* 55 */
+ data8 compat_sys_fcntl /* 55 */
data8 sys32_ni_syscall /* old mpx syscall holder */
data8 sys_setpgid
data8 sys32_ni_syscall /* old ulimit syscall holder */
@@ -419,7 +419,7 @@
data8 sys_mincore
data8 sys_madvise
data8 sys_getdents64 /* 220 */
- data8 sys32_fcntl64
+ data8 compat_sys_fcntl64
data8 sys_ni_syscall /* reserved for TUX */
data8 sys_ni_syscall /* reserved for Security */
data8 sys_gettid
diff -ruN 2.5.64-2003030918-32bit.1/arch/ia64/ia32/sys_ia32.c 2.5.64-2003030918-32bit.2/arch/ia64/ia32/sys_ia32.c
--- 2.5.64-2003030918-32bit.1/arch/ia64/ia32/sys_ia32.c 2003-03-09 20:08:57.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/ia64/ia32/sys_ia32.c 2003-03-09 20:34:44.000000000 +1100
@@ -2966,38 +2966,6 @@
return ret;
}

-extern asmlinkage long sys_fcntl (unsigned int fd, unsigned int cmd, unsigned long arg);
-
-asmlinkage long
-sys32_fcntl (unsigned int fd, unsigned int cmd, unsigned int arg)
-{
- mm_segment_t old_fs;
- struct flock f;
- long ret;
-
- switch (cmd) {
- case F_GETLK:
- case F_SETLK:
- case F_SETLKW:
- if (get_compat_flock(&f, (struct compat_flock *) A(arg)))
- return -EFAULT;
- old_fs = get_fs();
- set_fs(KERNEL_DS);
- ret = sys_fcntl(fd, cmd, (unsigned long) &f);
- set_fs(old_fs);
- if (cmd == F_GETLK && put_compat_flock(&f, (struct compat_flock *) A(arg)))
- return -EFAULT;
- return ret;
-
- default:
- /*
- * `sys_fcntl' lies about arg, for the F_SETOWN
- * sub-function arg can have a negative value.
- */
- return sys_fcntl(fd, cmd, arg);
- }
-}
-
asmlinkage long sys_ni_syscall(void);

asmlinkage long
@@ -3292,66 +3260,6 @@
return ret;
}

-/*
- * Unfortunately, the x86 compiler aligns variables of type "long long" to a 4 byte boundary
- * only, which means that the x86 version of "struct flock64" doesn't match the ia64 version
- * of struct flock.
- */
-
-static inline long
-ia32_put_flock (struct flock *l, unsigned long addr)
-{
- return (put_user(l->l_type, (short *) addr)
- | put_user(l->l_whence, (short *) (addr + 2))
- | put_user(l->l_start, (long *) (addr + 4))
- | put_user(l->l_len, (long *) (addr + 12))
- | put_user(l->l_pid, (int *) (addr + 20)));
-}
-
-static inline long
-ia32_get_flock (struct flock *l, unsigned long addr)
-{
- unsigned int start_lo, start_hi, len_lo, len_hi;
- int err = (get_user(l->l_type, (short *) addr)
- | get_user(l->l_whence, (short *) (addr + 2))
- | get_user(start_lo, (int *) (addr + 4))
- | get_user(start_hi, (int *) (addr + 8))
- | get_user(len_lo, (int *) (addr + 12))
- | get_user(len_hi, (int *) (addr + 16))
- | get_user(l->l_pid, (int *) (addr + 20)));
- l->l_start = ((unsigned long) start_hi << 32) | start_lo;
- l->l_len = ((unsigned long) len_hi << 32) | len_lo;
- return err;
-}
-
-asmlinkage long
-sys32_fcntl64 (unsigned int fd, unsigned int cmd, unsigned int arg)
-{
- mm_segment_t old_fs;
- struct flock f;
- long ret;
-
- switch (cmd) {
- case F_GETLK64:
- case F_SETLK64:
- case F_SETLKW64:
- if (ia32_get_flock(&f, arg))
- return -EFAULT;
- old_fs = get_fs();
- set_fs(KERNEL_DS);
- ret = sys_fcntl(fd, cmd, (unsigned long) &f);
- set_fs(old_fs);
- if (cmd == F_GETLK && ia32_put_flock(&f, arg))
- return -EFAULT;
- break;
-
- default:
- ret = sys32_fcntl(fd, cmd, arg);
- break;
- }
- return ret;
-}
-
asmlinkage long
sys32_truncate64 (unsigned int path, unsigned int len_lo, unsigned int len_hi)
{
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-ia64/compat.h 2.5.64-2003030918-32bit.2/include/asm-ia64/compat.h
--- 2.5.64-2003030918-32bit.1/include/asm-ia64/compat.h 2003-02-11 09:39:57.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-ia64/compat.h 2003-03-09 20:34:45.000000000 +1100
@@ -68,6 +68,22 @@
compat_pid_t l_pid;
};

+#define F_GETLK64 12
+#define F_SETLK64 13
+#define F_SETLKW64 14
+
+/*
+ * IA32 uses 4 byte alignment for 64 bit quantities,
+ * so we need to pack this structure.
+ */
+struct compat_flock64 {
+ short l_type;
+ short l_whence;
+ compat_loff_t l_start;
+ compat_loff_t l_len;
+ compat_pid_t l_pid;
+} __attribute__((packed));
+
struct compat_statfs {
int f_type;
int f_bsize;
@@ -88,4 +104,7 @@

typedef u32 compat_sigset_word;

+#define COMPAT_OFF_T_MAX 0x7fffffff
+#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
+
#endif /* _ASM_IA64_COMPAT_H */
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-ia64/fcntl.h 2.5.64-2003030918-32bit.2/include/asm-ia64/fcntl.h
--- 2.5.64-2003030918-32bit.1/include/asm-ia64/fcntl.h 2000-10-10 11:54:58.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-ia64/fcntl.h 2003-03-09 20:34:45.000000000 +1100
@@ -78,9 +78,6 @@
pid_t l_pid;
};

-#ifdef __KERNEL__
-# define flock64 flock
-#endif
-
#define F_LINUX_SPECIFIC_BASE 1024
+
#endif /* _ASM_IA64_FCNTL_H */
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-ia64/ia32.h 2.5.64-2003030918-32bit.2/include/asm-ia64/ia32.h
--- 2.5.64-2003030918-32bit.1/include/asm-ia64/ia32.h 2003-02-11 09:39:57.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-ia64/ia32.h 2003-03-09 20:34:45.000000000 +1100
@@ -18,10 +18,6 @@
#define IA32_PAGE_ALIGN(addr) (((addr) + IA32_PAGE_SIZE - 1) & IA32_PAGE_MASK)
#define IA32_CLOCKS_PER_SEC 100 /* Cast in stone for IA32 Linux */

-#define F_GETLK64 12
-#define F_SETLK64 13
-#define F_SETLKW64 14
-
/* sigcontext.h */
/*
* As documented in the iBCS2 standard..

2003-03-11 00:41:51

by Stephen Rothwell

[permalink] [raw]
Subject: [PATCH][COMPAT] compat_sys_fcntl{,64} 4/9 x86_64 part

Hi Linus,

Here is the x86_64 part of the patch with Andi's blessing. Please apply.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003030918-32bit.1/arch/x86_64/ia32/ia32entry.S 2.5.64-2003030918-32bit.2/arch/x86_64/ia32/ia32entry.S
--- 2.5.64-2003030918-32bit.1/arch/x86_64/ia32/ia32entry.S 2003-02-18 11:46:36.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/x86_64/ia32/ia32entry.S 2003-03-09 20:34:45.000000000 +1100
@@ -255,7 +255,7 @@
.quad sys_umount /* new_umount */
.quad ni_syscall /* old lock syscall holder */
.quad sys32_ioctl
- .quad sys32_fcntl64 /* 55 */
+ .quad compat_sys_fcntl64 /* 55 */
.quad ni_syscall /* old mpx syscall holder */
.quad sys_setpgid
.quad ni_syscall /* old ulimit syscall holder */
@@ -421,7 +421,7 @@
.quad sys_mincore
.quad sys_madvise
.quad sys_getdents64 /* 220 getdents64 */
- .quad sys32_fcntl64
+ .quad compat_sys_fcntl64
.quad sys_ni_syscall /* tux */
.quad sys_ni_syscall /* security */
.quad sys_gettid
diff -ruN 2.5.64-2003030918-32bit.1/arch/x86_64/ia32/sys_ia32.c 2.5.64-2003030918-32bit.2/arch/x86_64/ia32/sys_ia32.c
--- 2.5.64-2003030918-32bit.1/arch/x86_64/ia32/sys_ia32.c 2003-02-25 12:59:32.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/x86_64/ia32/sys_ia32.c 2003-03-09 20:34:45.000000000 +1100
@@ -1016,102 +1016,6 @@
return ret;
}

-extern asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
-asmlinkage long sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg);
-
-
-asmlinkage long sys32_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- switch (cmd) {
- case F_GETLK:
- case F_SETLK:
- case F_SETLKW:
- {
- struct flock f;
- mm_segment_t old_fs;
- long ret;
-
- if (get_compat_flock(&f, (struct compat_flock *)arg))
- return -EFAULT;
- old_fs = get_fs(); set_fs (KERNEL_DS);
- ret = sys_fcntl(fd, cmd, (unsigned long)&f);
- set_fs (old_fs);
- if (ret) return ret;
- if (put_compat_flock(&f, (struct compat_flock *)arg))
- return -EFAULT;
- return 0;
- }
- case F_GETLK64:
- case F_SETLK64:
- case F_SETLKW64:
- return sys32_fcntl64(fd,cmd,arg);
-
- default:
- return sys_fcntl(fd, cmd, (unsigned long)arg);
- }
-}
-
-static inline int get_flock64(struct ia32_flock64 *fl32, struct flock *fl64)
-{
- if (access_ok(fl32, sizeof(struct ia32_flock64), VERIFY_WRITE)) {
- int ret = __get_user(fl64->l_type, &fl32->l_type);
- ret |= __get_user(fl64->l_whence, &fl32->l_whence);
- ret |= __get_user(fl64->l_start, &fl32->l_start);
- ret |= __get_user(fl64->l_len, &fl32->l_len);
- ret |= __get_user(fl64->l_pid, &fl32->l_pid);
- return ret;
- }
- return -EFAULT;
-}
-
-static inline int put_flock64(struct ia32_flock64 *fl32, struct flock *fl64)
-{
- if (access_ok(fl32, sizeof(struct ia32_flock64), VERIFY_WRITE)) {
- int ret = __put_user(fl64->l_type, &fl32->l_type);
- ret |= __put_user(fl64->l_whence, &fl32->l_whence);
- ret |= __put_user(fl64->l_start, &fl32->l_start);
- ret |= __put_user(fl64->l_len, &fl32->l_len);
- ret |= __put_user(fl64->l_pid, &fl32->l_pid);
- return ret;
- }
- return -EFAULT;
-}
-
-asmlinkage long sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct flock fl64;
- mm_segment_t oldfs = get_fs();
- int ret = 0;
- int oldcmd = cmd;
- unsigned long oldarg = arg;
-
- switch (cmd) {
- case F_GETLK64:
- cmd = F_GETLK;
- goto cnv;
- case F_SETLK64:
- cmd = F_SETLK;
- goto cnv;
- case F_SETLKW64:
- cmd = F_SETLKW;
- cnv:
- ret = get_flock64((struct ia32_flock64 *)arg, &fl64);
- arg = (unsigned long)&fl64;
- set_fs(KERNEL_DS);
- break;
- case F_GETLK:
- case F_SETLK:
- case F_SETLKW:
- return sys32_fcntl(fd,cmd,arg);
- }
- if (!ret)
- ret = sys_fcntl(fd, cmd, arg);
- set_fs(oldfs);
- if (oldcmd == F_GETLK64 && !ret)
- ret = put_flock64((struct ia32_flock64 *)oldarg, &fl64);
- return ret;
-}
-
int sys32_ni_syscall(int call)
{
printk(KERN_INFO "IA32 syscall %d from %s not implemented\n", call,
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-x86_64/compat.h 2.5.64-2003030918-32bit.2/include/asm-x86_64/compat.h
--- 2.5.64-2003030918-32bit.1/include/asm-x86_64/compat.h 2003-02-11 09:40:00.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-x86_64/compat.h 2003-03-11 11:30:59.000000000 +1100
@@ -68,6 +68,22 @@
compat_pid_t l_pid;
};

+#define F_GETLK64 12 /* using 'struct flock64' */
+#define F_SETLK64 13
+#define F_SETLKW64 14
+
+/*
+ * IA32 uses 4 byte alignment for 64 bit quantities,
+ * so we need to pack this structure.
+ */
+struct compat_flock64 {
+ short l_type;
+ short l_whence;
+ compat_loff_t l_start;
+ compat_loff_t l_len;
+ compat_pid_t l_pid;
+} __attribute__((packed));
+
struct compat_statfs {
int f_type;
int f_bsize;
@@ -88,4 +104,7 @@

typedef u32 compat_sigset_word;

+#define COMPAT_OFF_T_MAX 0x7fffffff
+#define COMPAT_LOFF_T_MAX 0x7fffffffffffffff
+
#endif /* _ASM_X86_64_COMPAT_H */
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-x86_64/fcntl.h 2.5.64-2003030918-32bit.2/include/asm-x86_64/fcntl.h
--- 2.5.64-2003030918-32bit.1/include/asm-x86_64/fcntl.h 2002-02-20 14:13:21.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-x86_64/fcntl.h 2003-03-09 20:34:45.000000000 +1100
@@ -72,8 +72,4 @@

#define F_LINUX_SPECIFIC_BASE 1024

-#ifdef __KERNEL__
-#define flock64 flock
-#endif
-
#endif /* !_X86_64_FCNTL_H */
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-x86_64/ia32.h 2.5.64-2003030918-32bit.2/include/asm-x86_64/ia32.h
--- 2.5.64-2003030918-32bit.1/include/asm-x86_64/ia32.h 2003-02-15 23:20:00.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-x86_64/ia32.h 2003-03-09 20:34:45.000000000 +1100
@@ -11,18 +11,6 @@
* 32 bit structures for IA32 support.
*/

-struct ia32_flock64 {
- short l_type;
- short l_whence;
- loff_t l_start; /* unnatural alignment */
- loff_t l_len;
- pid_t l_pid;
-} __attribute__((packed));
-
-#define F_GETLK64 12 /* using 'struct flock64' */
-#define F_SETLK64 13
-#define F_SETLKW64 14
-
#include <asm/sigcontext32.h>

/* signal.h */

2003-03-11 00:49:19

by Stephen Rothwell

[permalink] [raw]
Subject: [PATCH][COMPAT] compat_sys_fcntl{,64} 7/9 mips64 part

Hi Ralf,

Here is the mips64 part of the patch. Please apply after Linus has applied
the generic part. This patch also depend on the previous compatibility
patch I sent you.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003030918-32bit.1/arch/mips64/kernel/linux32.c 2.5.64-2003030918-32bit.2/arch/mips64/kernel/linux32.c
--- 2.5.64-2003030918-32bit.1/arch/mips64/kernel/linux32.c 2003-03-05 15:59:10.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/mips64/kernel/linux32.c 2003-03-09 20:34:44.000000000 +1100
@@ -1068,50 +1068,6 @@
return sys_setsockopt(fd, level, optname, optval, optlen);
}

-extern asmlinkage long
-sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
-
-asmlinkage long
-sys32_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- switch (cmd) {
- case F_GETLK:
- case F_SETLK:
- case F_SETLKW:
- {
- struct flock f;
- mm_segment_t old_fs;
- long ret;
-
- if (get_compat_flock(&f, (struct compat_flock *)arg))
- return -EFAULT;
- old_fs = get_fs(); set_fs (KERNEL_DS);
- ret = sys_fcntl(fd, cmd, (unsigned long)&f);
- set_fs (old_fs);
- if (put_compat_flock(&f, (struct compat_flock *)arg))
- return -EFAULT;
- return ret;
- }
- default:
- return sys_fcntl(fd, cmd, (unsigned long)arg);
- }
-}
-
-asmlinkage long
-sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- switch (cmd) {
- case F_GETLK64:
- return sys_fcntl(fd, F_GETLK, arg);
- case F_SETLK64:
- return sys_fcntl(fd, F_SETLK, arg);
- case F_SETLKW64:
- return sys_fcntl(fd, F_SETLKW, arg);
- }
-
- return sys32_fcntl(fd, cmd, arg);
-}
-
struct msgbuf32 { s32 mtype; char mtext[1]; };

struct ipc_perm32
diff -ruN 2.5.64-2003030918-32bit.1/arch/mips64/kernel/scall_o32.S 2.5.64-2003030918-32bit.2/arch/mips64/kernel/scall_o32.S
--- 2.5.64-2003030918-32bit.1/arch/mips64/kernel/scall_o32.S 2003-03-05 15:59:10.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/mips64/kernel/scall_o32.S 2003-03-09 20:34:44.000000000 +1100
@@ -288,7 +288,7 @@
sys sys_umount 2
sys sys_ni_syscall 0
sys sys32_ioctl 3
- sys sys32_fcntl 3 /* 4055 */
+ sys compat_sys_fcntl 3 /* 4055 */
sys sys_ni_syscall 2
sys sys_setpgid 2
sys sys_ni_syscall, 0
@@ -453,7 +453,7 @@
sys sys_mincore 3
sys sys_madvise 3
sys sys_getdents64 3
- sys sys32_fcntl64 3 /* 4220 */
+ sys compat_sys_fcntl64 3 /* 4220 */
sys sys32_gettid 0
sys sys32_tkill 2
.endm
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-mips64/compat.h 2.5.64-2003030918-32bit.2/include/asm-mips64/compat.h
--- 2.5.64-2003030918-32bit.1/include/asm-mips64/compat.h 2003-03-05 15:59:10.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-mips64/compat.h 2003-03-09 20:34:45.000000000 +1100
@@ -62,8 +62,21 @@
short l_whence;
compat_off_t l_start;
compat_off_t l_len;
+ s32 l_sysid; /* ABI junk, unused on Linux */
+ compat_pid_t l_pid;
+ s32 pad[4]; /* ABI junk, unused on Linux */
+};
+
+#define F_GETLK64 33 /* using 'struct flock64' */
+#define F_SETLK64 34
+#define F_SETLKW64 35
+
+struct compat_flock64 {
+ short l_type;
+ short l_whence;
+ compat_loff_t l_start;
+ compat_loff_t l_len;
compat_pid_t l_pid;
- short __unused;
};

struct compat_statfs {
@@ -87,4 +100,7 @@

typedef u32 compat_sigset_word;

+#define COMPAT_OFF_T_MAX 0x7fffffff
+#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
+
#endif /* _ASM_MIPS64_COMPAT_H */
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-mips64/fcntl.h 2.5.64-2003030918-32bit.2/include/asm-mips64/fcntl.h
--- 2.5.64-2003030918-32bit.1/include/asm-mips64/fcntl.h 2001-09-10 03:43:02.000000000 +1000
+++ 2.5.64-2003030918-32bit.2/include/asm-mips64/fcntl.h 2003-03-09 20:34:45.000000000 +1100
@@ -43,12 +43,6 @@
#define F_SETSIG 10 /* for sockets. */
#define F_GETSIG 11 /* for sockets. */

-#ifdef __KERNEL__
-#define F_GETLK64 33 /* using 'struct flock64' */
-#define F_SETLK64 34
-#define F_SETLKW64 35
-#endif
-
/* for F_[GET|SET]FL */
#define FD_CLOEXEC 1 /* actually anything with low bit set goes */

@@ -86,10 +80,6 @@
long pad[4]; /* ZZZZZZZZZZZZZZZZZZZZZZZZZZ */
} flock_t;

-#ifdef __KERNEL__
-#define flock64 flock
-#endif
-
#define F_LINUX_SPECIFIC_BASE 1024

#endif /* _ASM_FCNTL_H */

2003-03-11 00:46:38

by Stephen Rothwell

[permalink] [raw]
Subject: [PATCH][COMPAT] compat_sys_fcntl{,64} 6/9 s390x part

Hi Linus,

Here is the s390x part of the patch with Martin's blessing. Please apply.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003030918-32bit.1/arch/s390x/kernel/entry.S 2.5.64-2003030918-32bit.2/arch/s390x/kernel/entry.S
--- 2.5.64-2003030918-32bit.1/arch/s390x/kernel/entry.S 2003-02-25 12:59:29.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/s390x/kernel/entry.S 2003-03-09 20:34:44.000000000 +1100
@@ -452,7 +452,7 @@
.long SYSCALL(sys_umount,sys32_umount_wrapper)
.long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* old lock syscall */
.long SYSCALL(sys_ioctl,sys32_ioctl_wrapper)
- .long SYSCALL(sys_fcntl,sys32_fcntl_wrapper) /* 55 */
+ .long SYSCALL(sys_fcntl,compat_sys_fcntl_wrapper) /* 55 */
.long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* intel mpx syscall */
.long SYSCALL(sys_setpgid,sys32_setpgid_wrapper)
.long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* old ulimit syscall */
@@ -618,7 +618,7 @@
.long SYSCALL(sys_mincore,sys32_mincore_wrapper)
.long SYSCALL(sys_madvise,sys32_madvise_wrapper)
.long SYSCALL(sys_getdents64,sys32_getdents64_wrapper)/* 220 */
- .long SYSCALL(sys_ni_syscall,sys32_fcntl64_wrapper)
+ .long SYSCALL(sys_ni_syscall,compat_sys_fcntl64_wrapper)
.long SYSCALL(sys_readahead,sys32_readahead)
.long SYSCALL(sys_ni_syscall,sys32_sendfile64)
.long SYSCALL(sys_setxattr,sys32_setxattr_wrapper)
diff -ruN 2.5.64-2003030918-32bit.1/arch/s390x/kernel/linux32.c 2.5.64-2003030918-32bit.2/arch/s390x/kernel/linux32.c
--- 2.5.64-2003030918-32bit.1/arch/s390x/kernel/linux32.c 2003-02-25 12:59:30.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/s390x/kernel/linux32.c 2003-03-09 20:34:44.000000000 +1100
@@ -834,57 +834,6 @@
return err;
}

-extern asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
-
-asmlinkage long sys32_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- switch (cmd) {
- case F_GETLK:
- {
- struct flock f;
- mm_segment_t old_fs;
- long ret;
-
- if(get_compat_flock(&f, (struct compat_flock *)A(arg)))
- return -EFAULT;
- old_fs = get_fs(); set_fs (KERNEL_DS);
- ret = sys_fcntl(fd, cmd, (unsigned long)&f);
- set_fs (old_fs);
- if (ret) return ret;
- if (f.l_start >= 0x7fffffffUL ||
- f.l_start + f.l_len >= 0x7fffffffUL)
- return -EOVERFLOW;
- if(put_compat_flock(&f, (struct compat_flock *)A(arg)))
- return -EFAULT;
- return 0;
- }
- case F_SETLK:
- case F_SETLKW:
- {
- struct flock f;
- mm_segment_t old_fs;
- long ret;
-
- if(get_compat_flock(&f, (struct compat_flock *)A(arg)))
- return -EFAULT;
- old_fs = get_fs(); set_fs (KERNEL_DS);
- ret = sys_fcntl(fd, cmd, (unsigned long)&f);
- set_fs (old_fs);
- if (ret) return ret;
- return 0;
- }
- default:
- return sys_fcntl(fd, cmd, (unsigned long)arg);
- }
-}
-
-asmlinkage long sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- if (cmd >= F_GETLK64 && cmd <= F_SETLKW64)
- return sys_fcntl(fd, cmd + F_GETLK - F_GETLK64, arg);
- return sys32_fcntl(fd, cmd, arg);
-}
-
extern asmlinkage long sys_truncate(const char * path, unsigned long length);
extern asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);

diff -ruN 2.5.64-2003030918-32bit.1/arch/s390x/kernel/linux32.h 2.5.64-2003030918-32bit.2/arch/s390x/kernel/linux32.h
--- 2.5.64-2003030918-32bit.1/arch/s390x/kernel/linux32.h 2003-01-17 14:01:01.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/s390x/kernel/linux32.h 2003-03-09 20:34:45.000000000 +1100
@@ -21,10 +21,6 @@
__s32 msgtyp;
};

-#define F_GETLK64 12
-#define F_SETLK64 13
-#define F_SETLKW64 14
-
struct old_sigaction32 {
__u32 sa_handler; /* Really a pointer, but need to deal with 32 bits */
compat_old_sigset_t sa_mask; /* A 32 bit mask */
diff -ruN 2.5.64-2003030918-32bit.1/arch/s390x/kernel/wrapper32.S 2.5.64-2003030918-32bit.2/arch/s390x/kernel/wrapper32.S
--- 2.5.64-2003030918-32bit.1/arch/s390x/kernel/wrapper32.S 2003-02-25 12:59:30.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/s390x/kernel/wrapper32.S 2003-03-09 20:34:45.000000000 +1100
@@ -227,12 +227,12 @@
llgfr %r4,%r4 # unsigned int
jg sys32_ioctl # branch to system call

- .globl sys32_fcntl_wrapper
-sys32_fcntl_wrapper:
+ .globl compat_sys_fcntl_wrapper
+compat_sys_fcntl_wrapper:
llgfr %r2,%r2 # unsigned int
llgfr %r3,%r3 # unsigned int
llgfr %r4,%r4 # unsigned long
- jg sys32_fcntl # branch to system call
+ jg compat_sys_fcntl # branch to system call

.globl sys32_setpgid_wrapper
sys32_setpgid_wrapper:
@@ -1050,12 +1050,12 @@
llgfr %r4,%r4 # unsigned int
jg sys_getdents64 # branch to system call

- .globl sys32_fcntl64_wrapper
-sys32_fcntl64_wrapper:
+ .globl compat_sys_fcntl64_wrapper
+compat_sys_fcntl64_wrapper:
llgfr %r2,%r2 # unsigned int
llgfr %r3,%r3 # unsigned int
llgfr %r4,%r4 # unsigned long
- jg sys32_fcntl64 # branch to system call
+ jg compat_sys_fcntl64 # branch to system call

.globl sys32_stat64_wrapper
sys32_stat64_wrapper:
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-s390x/compat.h 2.5.64-2003030918-32bit.2/include/asm-s390x/compat.h
--- 2.5.64-2003030918-32bit.1/include/asm-s390x/compat.h 2003-02-25 12:59:57.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-s390x/compat.h 2003-03-09 20:34:45.000000000 +1100
@@ -64,7 +64,18 @@
compat_off_t l_start;
compat_off_t l_len;
compat_pid_t l_pid;
- short __unused;
+};
+
+#define F_GETLK64 12
+#define F_SETLK64 13
+#define F_SETLKW64 14
+
+struct compat_flock64 {
+ short l_type;
+ short l_whence;
+ compat_loff_t l_start;
+ compat_loff_t l_len;
+ compat_pid_t l_pid;
};

struct compat_statfs {
@@ -87,4 +98,7 @@

typedef u32 compat_sigset_word;

+#define COMPAT_OFF_T_MAX 0x7fffffff
+#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
+
#endif /* _ASM_S390X_COMPAT_H */
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-s390x/fcntl.h 2.5.64-2003030918-32bit.2/include/asm-s390x/fcntl.h
--- 2.5.64-2003030918-32bit.1/include/asm-s390x/fcntl.h 2001-11-10 09:11:15.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-s390x/fcntl.h 2003-03-09 20:34:45.000000000 +1100
@@ -80,6 +80,4 @@

#define F_LINUX_SPECIFIC_BASE 1024

-#define flock64 flock
-
#endif

2003-03-11 00:51:26

by Stephen Rothwell

[permalink] [raw]
Subject: [PATCH][COMPAT] compat_sys_fcntl{,64} 8/9 parisc part

Hi Linus,

Here is the parisc part of the patch with Willy's blessing. Please apply.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003030918-32bit.1/arch/parisc/kernel/sys_parisc32.c 2.5.64-2003030918-32bit.2/arch/parisc/kernel/sys_parisc32.c
--- 2.5.64-2003030918-32bit.1/arch/parisc/kernel/sys_parisc32.c 2003-02-18 11:46:33.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/parisc/kernel/sys_parisc32.c 2003-03-09 20:34:44.000000000 +1100
@@ -316,35 +316,6 @@
return -ENOSYS;
}

-extern asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
-
-asmlinkage long sys32_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- switch (cmd) {
- case F_GETLK:
- case F_SETLK:
- case F_SETLKW:
- {
- struct flock f;
- long ret;
-
- if (get_compat_flock(&f, (struct compat_flock *)arg))
- return -EFAULT;
- KERNEL_SYSCALL(ret, sys_fcntl, fd, cmd, (unsigned long)&f);
- if (ret) return ret;
- if (f.l_start >= 0x7fffffffUL ||
- f.l_len >= 0x7fffffffUL ||
- f.l_start + f.l_len >= 0x7fffffffUL)
- return -EOVERFLOW;
- if (put_compat_flock(&f, (struct compat_flock *)arg))
- return -EFAULT;
- return 0;
- }
- default:
- return sys_fcntl(fd, cmd, (unsigned long)arg);
- }
-}
-
#ifdef CONFIG_SYSCTL

struct __sysctl_args32 {
@@ -2043,28 +2014,6 @@
return err;
}

-/* LFS */
-
-extern asmlinkage long sys_fcntl(unsigned int, unsigned int, unsigned long);
-
-asmlinkage long sys32_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- switch (cmd) {
- case F_GETLK64:
- cmd = F_GETLK;
- break;
- case F_SETLK64:
- cmd = F_SETLK;
- break;
- case F_SETLKW64:
- cmd = F_SETLKW;
- break;
- default:
- break;
- }
- return sys32_fcntl(fd, cmd, arg);
-}
-
/* EXPORT/UNEXPORT */
struct nfsctl_export32 {
char ex_client[NFSCLNT_IDMAX+1];
diff -ruN 2.5.64-2003030918-32bit.1/arch/parisc/kernel/syscall.S 2.5.64-2003030918-32bit.2/arch/parisc/kernel/syscall.S
--- 2.5.64-2003030918-32bit.1/arch/parisc/kernel/syscall.S 2003-02-18 11:46:33.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/arch/parisc/kernel/syscall.S 2003-03-09 20:34:44.000000000 +1100
@@ -409,8 +409,7 @@
ENTRY_SAME(getpeername)
/* This one's a huge ugly mess */
ENTRY_DIFF(ioctl)
- /* struct flock? */
- ENTRY_DIFF(fcntl) /* 55 */
+ ENTRY_COMP(fcntl) /* 55 */
ENTRY_SAME(socketpair)
ENTRY_SAME(setpgid)
ENTRY_SAME(send)
@@ -589,7 +588,7 @@
ENTRY_OURS(truncate64)
ENTRY_OURS(ftruncate64) /* 200 */
ENTRY_SAME(getdents64)
- ENTRY_DIFF(fcntl64)
+ ENTRY_COMP(fcntl64)
ENTRY_SAME(ni_syscall)
ENTRY_SAME(ni_syscall)
ENTRY_SAME(ni_syscall) /* 205 */
diff -ruN 2.5.64-2003030918-32bit.1/include/asm-parisc/compat.h 2.5.64-2003030918-32bit.2/include/asm-parisc/compat.h
--- 2.5.64-2003030918-32bit.1/include/asm-parisc/compat.h 2003-02-11 09:39:59.000000000 +1100
+++ 2.5.64-2003030918-32bit.2/include/asm-parisc/compat.h 2003-03-09 20:34:45.000000000 +1100
@@ -72,6 +72,14 @@
compat_pid_t l_pid;
};

+struct compat_flock64 {
+ short l_type;
+ short l_whence;
+ compat_loff_t l_start;
+ compat_loff_t l_len;
+ compat_pid_t l_pid;
+};
+
struct compat_statfs {
s32 f_type;
s32 f_bsize;
@@ -92,4 +100,7 @@

typedef u32 compat_sigset_word;

+#define COMPAT_OFF_T_MAX 0x7fffffff
+#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
+
#endif /* _ASM_PARISC_COMPAT_H */

2003-03-11 00:58:00

by Stephen Rothwell

[permalink] [raw]
Subject: [PATCH][COMPAT] compat_sys_fcntl{,64} 9/9 Aalpha part

Hi Richard,

This is only partly to do with the other parts of this patch set. All it
does is remove struct flock64 from the Alpha port. Please apply after
Linus has applied the generic part of the patch.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003030918-32bit.1/include/asm-alpha/fcntl.h 2.5.64-2003030918-32bit.2/include/asm-alpha/fcntl.h
--- 2.5.64-2003030918-32bit.1/include/asm-alpha/fcntl.h 2001-09-18 06:16:30.000000000 +1000
+++ 2.5.64-2003030918-32bit.2/include/asm-alpha/fcntl.h 2003-03-09 20:34:45.000000000 +1100
@@ -69,9 +69,6 @@
__kernel_pid_t l_pid;
};

-#ifdef __KERNEL__
-#define flock64 flock
-#endif
#define F_LINUX_SPECIFIC_BASE 1024

#endif

2003-03-11 10:18:23

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH][COMPAT] compat_sys_fcntl{,64} 1/9 Generic part

Stephen Rothwell wrote:
+asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
+ unsigned long arg)
+{
+ mm_segment_t old_fs;
+ struct flock f;
+ long ret;
+
+ switch (cmd) {
+ case F_GETLK:
+ case F_SETLK:
+ case F_SETLKW:
+ ret = get_compat_flock(&f, (struct compat_flock *)arg);

and

-asmlinkage long sys32_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- switch (cmd) {
- case F_GETLK:
- {
- struct flock f;
- mm_segment_t old_fs;
- long ret;
-
- if(get_compat_flock(&f, (struct compat_flock *)A(arg)))
^^^^^^^^

Did you notice the use of the address conversion macro? Maybe I missed
something myself, but I suppose this will fail on s390 if the msb of arg
is not cleared.

Arnd <><

2003-03-11 12:11:38

by Martin Schwidefsky

[permalink] [raw]
Subject: Re: [PATCH][COMPAT] compat_sys_fcntl{,64} 1/9 Generic part


> Did you notice the use of the address conversion macro? Maybe I missed
> something myself, but I suppose this will fail on s390 if the msb of arg
> is not cleared.

True. A(arg) removes the high order bit from arg. This can't be done
in the system call wrapper because in general arg is a 32 bit parameter.

blue skies,
Martin


2003-03-11 23:31:52

by David Miller

[permalink] [raw]
Subject: Re: [PATCH][COMPAT] compat_sys_fcntl{,64} 3/9 sparc64 part

From: Stephen Rothwell <[email protected]>
Date: Tue, 11 Mar 2003 11:50:00 +1100

Here is the sparc64 part of the patch. Please apply after Linus applies
the gerneic part.

Thanks Stephen.

You know, you're doing such a good job with this, that you can
just stick the sparc64 parts into your main patch if you want.
You don't need to push it through me each time if you don't want.

2003-03-12 04:34:03

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH][COMPAT] compat_sys_fcntl{,64} 1/9 Generic part

Hi Martin, Arnd,

On Tue, 11 Mar 2003 13:20:39 +0100 "Martin Schwidefsky" <[email protected]> wrote:
>
>
> > Did you notice the use of the address conversion macro? Maybe I missed
> > something myself, but I suppose this will fail on s390 if the msb of arg
> > is not cleared.
>
> True. A(arg) removes the high order bit from arg. This can't be done
> in the system call wrapper because in general arg is a 32 bit parameter.

I did notice :-) Does the following look OK to you?

This patch also (goes some way) to fixing the net/compat.c as pointers
are used there as well.

Linus, if Martin says this is OK, please apply. This patch is relative
to my previous patch, but applies to recent BK with some fuzz in the
architectures that haven't merged my previous patch yet.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003031211-32bit.1/fs/compat.c 2.5.64-2003031211-32bit.2/fs/compat.c
--- 2.5.64-2003031211-32bit.1/fs/compat.c 2003-03-12 11:55:17.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/fs/compat.c 2003-03-12 15:11:27.000000000 +1100
@@ -191,7 +191,7 @@
case F_GETLK:
case F_SETLK:
case F_SETLKW:
- ret = get_compat_flock(&f, (struct compat_flock *)arg);
+ ret = get_compat_flock(&f, COMPAT_UPTR_TO_PTR(arg));
if (ret != 0)
break;
old_fs = get_fs();
@@ -204,14 +204,14 @@
ret = -EOVERFLOW;
if (ret == 0)
ret = put_compat_flock(&f,
- (struct compat_flock *)arg);
+ COMPAT_UPTR_TO_PTR(arg));
}
break;

case F_GETLK64:
case F_SETLK64:
case F_SETLKW64:
- ret = get_compat_flock64(&f, (struct compat_flock64 *)arg);
+ ret = get_compat_flock64(&f, COMPAT_UPTR_TO_PTR(arg));
if (ret != 0)
break;
old_fs = get_fs();
@@ -227,7 +227,7 @@
ret = -EOVERFLOW;
if (ret == 0)
ret = put_compat_flock64(&f,
- (struct compat_flock64 *)arg);
+ COMPAT_UPTR_TO_PTR(arg));
}
break;

diff -ruN 2.5.64-2003031211-32bit.1/include/asm-ia64/compat.h 2.5.64-2003031211-32bit.2/include/asm-ia64/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-ia64/compat.h 2003-03-09 20:34:45.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-ia64/compat.h 2003-03-12 15:36:14.000000000 +1100
@@ -107,4 +107,13 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+#define COMPAT_UPTR_TO_PTR(ptr) ((void *)(unsigned long)(x))
+
#endif /* _ASM_IA64_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-mips64/compat.h 2.5.64-2003031211-32bit.2/include/asm-mips64/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-mips64/compat.h 2003-03-09 20:34:45.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-mips64/compat.h 2003-03-12 15:36:28.000000000 +1100
@@ -103,4 +103,13 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+#define COMPAT_UPTR_TO_PTR(ptr) ((void *)(unsigned long)(x))
+
#endif /* _ASM_MIPS64_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-parisc/compat.h 2.5.64-2003031211-32bit.2/include/asm-parisc/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-parisc/compat.h 2003-03-12 11:55:19.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-parisc/compat.h 2003-03-12 15:36:42.000000000 +1100
@@ -103,4 +103,13 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+#define COMPAT_UPTR_TO_PTR(ptr) ((void *)(unsigned long)(x))
+
#endif /* _ASM_PARISC_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-ppc64/compat.h 2.5.64-2003031211-32bit.2/include/asm-ppc64/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-ppc64/compat.h 2003-03-09 20:34:45.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-ppc64/compat.h 2003-03-12 15:36:52.000000000 +1100
@@ -98,4 +98,13 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+#define COMPAT_UPTR_TO_PTR(ptr) ((void *)(unsigned long)(x))
+
#endif /* _ASM_PPC64_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-s390x/compat.h 2.5.64-2003031211-32bit.2/include/asm-s390x/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-s390x/compat.h 2003-03-12 11:55:20.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-s390x/compat.h 2003-03-12 15:37:03.000000000 +1100
@@ -101,4 +101,13 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+#define COMPAT_UPTR_TO_PTR(ptr) ((void *)(unsigned long)((x) & 0x7fffffffUL))
+
#endif /* _ASM_S390X_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-sparc64/compat.h 2.5.64-2003031211-32bit.2/include/asm-sparc64/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-sparc64/compat.h 2003-03-09 20:34:45.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-sparc64/compat.h 2003-03-12 15:37:12.000000000 +1100
@@ -100,4 +100,13 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+#define COMPAT_UPTR_TO_PTR(ptr) ((void *)(unsigned long)(x))
+
#endif /* _ASM_SPARC64_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-x86_64/compat.h 2.5.64-2003031211-32bit.2/include/asm-x86_64/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-x86_64/compat.h 2003-03-12 11:55:21.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-x86_64/compat.h 2003-03-12 15:37:19.000000000 +1100
@@ -107,4 +107,13 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffff

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+#define COMPAT_UPTR_TO_PTR(ptr) ((void *)(unsigned long)(x))
+
#endif /* _ASM_X86_64_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/net/compat.c 2.5.64-2003031211-32bit.2/net/compat.c
--- 2.5.64-2003031211-32bit.1/net/compat.c 2003-03-12 11:55:24.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/net/compat.c 2003-03-12 15:29:48.000000000 +1100
@@ -27,7 +27,6 @@
#include <asm/uaccess.h>
#include <net/compat_socket.h>

-#define A(__x) ((unsigned long)(__x))
#define AA(__x) ((unsigned long)(__x))

extern asmlinkage long sys_getsockopt(int fd, int level, int optname,
@@ -49,7 +48,7 @@
break;
}
tot_len += len;
- kiov->iov_base = (void *)A(buf);
+ kiov->iov_base = COMPAT_UPTR_TO_PTR(buf);
kiov->iov_len = (__kernel_size_t) len;
uiov32++;
kiov++;
@@ -69,9 +68,9 @@
if (err)
return -EFAULT;

- kmsg->msg_name = (void *)A(tmp1);
- kmsg->msg_iov = (struct iovec *)A(tmp2);
- kmsg->msg_control = (void *)A(tmp3);
+ kmsg->msg_name = COMPAT_UPTR_TO_PTR(tmp1);
+ kmsg->msg_iov = COMPAT_UPTR_TO_PTR(tmp2);
+ kmsg->msg_control = COMPAT_UPTR_TO_PTR(tmp3);

err = get_user(kmsg->msg_namelen, &umsg->msg_namelen);
err |= get_user(kmsg->msg_iovlen, &umsg->msg_iovlen);
@@ -458,7 +457,7 @@
__get_user(uptr, &fprog32->filter))
return -EFAULT;

- kfprog.filter = (struct sock_filter *)A(uptr);
+ kfprog.filter = COMPAT_UPTR_TO_PTR(uptr);
fsize = kfprog.len * sizeof(struct sock_filter);

kfilter = (struct sock_filter *)kmalloc(fsize, GFP_KERNEL);
@@ -639,36 +638,37 @@
ret = sys_socket(a0, a1, a[2]);
break;
case SYS_BIND:
- ret = sys_bind(a0, (struct sockaddr *)A(a1), a[2]);
+ ret = sys_bind(a0, COMPAT_UPTR_TO_PTR(a1), a[2]);
break;
case SYS_CONNECT:
- ret = sys_connect(a0, (struct sockaddr *)A(a1), a[2]);
+ ret = sys_connect(a0, COMPAT_UPTR_TO_PTR(a1), a[2]);
break;
case SYS_LISTEN:
ret = sys_listen(a0, a1);
break;
case SYS_ACCEPT:
- ret = sys_accept(a0, (struct sockaddr *)A(a1), (int *)A(a[2]));
+ ret = sys_accept(a0, COMPAT_UPTR_TO_PTR(a1),
+ COMPAT_UPTR_TO_PTR(a[2]));
break;
case SYS_GETSOCKNAME:
- ret = sys_getsockname(a0, (struct sockaddr *)A(a1),
- (int *)A(a[2]));
+ ret = sys_getsockname(a0, COMPAT_UPTR_TO_PTR(a1),
+ COMPAT_UPTR_TO_PTR(a[2]));
break;
case SYS_GETPEERNAME:
- ret = sys_getpeername(a0, (struct sockaddr *)A(a1),
- (int *)A(a[2]));
+ ret = sys_getpeername(a0, COMPAT_UPTR_TO_PTR(a1),
+ COMPAT_UPTR_TO_PTR(a[2]));
break;
case SYS_SOCKETPAIR:
- ret = sys_socketpair(a0, a1, a[2], (int *)A(a[3]));
+ ret = sys_socketpair(a0, a1, a[2], COMPAT_UPTR_TO_PTR(a[3]));
break;
case SYS_SEND:
- ret = sys_send(a0, (void *)A(a1), a[2], a[3]);
+ ret = sys_send(a0, COMPAT_UPTR_TO_PTR(a1), a[2], a[3]);
break;
case SYS_SENDTO:
ret = sys_sendto(a0, a1, a[2], a[3], a[4], a[5]);
break;
case SYS_RECV:
- ret = sys_recv(a0, (void *)A(a1), a[2], a[3]);
+ ret = sys_recv(a0, COMPAT_UPTR_TO_PTR(a1), a[2], a[3]);
break;
case SYS_RECVFROM:
ret = sys_recvfrom(a0, a1, a[2], a[3], a[4], a[5]);
@@ -677,19 +677,20 @@
ret = sys_shutdown(a0,a1);
break;
case SYS_SETSOCKOPT:
- ret = compat_sys_setsockopt(a0, a1, a[2], (char *)A(a[3]),
- a[4]);
+ ret = compat_sys_setsockopt(a0, a1, a[2],
+ COMPAT_UPTR_TO_PTR(a[3]), a[4]);
break;
case SYS_GETSOCKOPT:
- ret = compat_sys_getsockopt(a0, a1, a[2], (char *)(u64)a[3],
- (int *)(u64)a[4]);
+ ret = compat_sys_getsockopt(a0, a1, a[2],
+ COMPAT_UPTR_TO_PTR(a[3]),
+ COMPAT_UPTR_TO_PTR(a[4]));
break;
case SYS_SENDMSG:
- ret = compat_sys_sendmsg(a0, (struct compat_msghdr *)A(a1),
+ ret = compat_sys_sendmsg(a0, COMPAT_UPTR_TO_PTR(a1),
a[2]);
break;
case SYS_RECVMSG:
- ret = compat_sys_recvmsg(a0, (struct compat_msghdr *)A(a1),
+ ret = compat_sys_recvmsg(a0, COMPAT_UPTR_TO_PTR(a1),
a[2]);
break;
default:

2003-03-12 04:44:42

by Anton Blanchard

[permalink] [raw]
Subject: Re: [PATCH][COMPAT] compat_sys_fcntl{,64} 3/9 sparc64 part


> You know, you're doing such a good job with this, that you can
> just stick the sparc64 parts into your main patch if you want.
> You don't need to push it through me each time if you don't want.

Likewise for ppc64 :)

Anton

2003-03-12 04:53:37

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH][COMPAT] compat_sys_fcntl{,64} 1/9 Generic part


On Wed, 12 Mar 2003, Stephen Rothwell wrote:
>
> Linus, if Martin says this is OK, please apply. This patch is relative
> to my previous patch, but applies to recent BK with some fuzz in the
> architectures that haven't merged my previous patch yet.

This is just too much CRAP, in my opinion. It's just unacceptably ugly,
and I don't think the compat layer is worth it if it just keeps on growing
barnacles that are as horrible as this.

Why do you have to shout in the code with macro names from hell?

Make the code _look_ good. Not look like SOMEBODY WHO CANNOT TYPE WITHOUT
THE SHIFT KEY. Make the thing take properly typed arguments, instead of
casting stuff two ways and backwards inside macros.

Linus

2003-03-12 05:12:24

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH][COMPAT] compat_sys_fcntl{,64} 1/9 Generic part

On Tue, 11 Mar 2003 21:02:09 -0800 (PST) Linus Torvalds <[email protected]> wrote:
>
> Why do you have to shout in the code with macro names from hell?

At least it is descriptive as opposed to an uncommented macro
called A ...

> Make the code _look_ good. Not look like SOMEBODY WHO CANNOT TYPE WITHOUT
> THE SHIFT KEY. Make the thing take properly typed arguments, instead of
> casting stuff two ways and backwards inside macros.

you mean like this?

static inline void *compat_ptr(compat_uptr_t uptr)
{
return (void *)uptr;
}

and (for s390x)

static inline void *compat_ptr(compat_uptr_t uptr)
{
return (void *)(uptr & 0x7fffffffUL);
}

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

2003-03-12 05:17:32

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH][COMPAT] compat_sys_fcntl{,64} 1/9 Generic part


On Wed, 12 Mar 2003, Stephen Rothwell wrote:
>
> > Make the code _look_ good. Not look like SOMEBODY WHO CANNOT TYPE WITHOUT
> > THE SHIFT KEY. Make the thing take properly typed arguments, instead of
> > casting stuff two ways and backwards inside macros.
>
> you mean like this?

Yes, this looks much more sane. If you _really_ want to be anal about
typechecking (and also checking that nobody can possibly use a user
pointer incorrectly), you make

typedef struct {
unsigned int val;
} compat_uptr_t;

and then use

static inline void *compat_ptr(compat_uptr_t uptr)
{
return (void *)uptr.val;
}

which should still result in readable code.

Linus

2003-03-12 05:46:57

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH][COMPAT] compat_sys_fcntl{,64} 1/9 Generic part

Hi Linus,

OK, next attempt. I have left our the anal type checking for now.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

diff -ruN 2.5.64-2003031211-32bit.1/fs/compat.c 2.5.64-2003031211-32bit.2/fs/compat.c
--- 2.5.64-2003031211-32bit.1/fs/compat.c 2003-03-12 11:55:17.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/fs/compat.c 2003-03-12 16:49:01.000000000 +1100
@@ -191,7 +191,7 @@
case F_GETLK:
case F_SETLK:
case F_SETLKW:
- ret = get_compat_flock(&f, (struct compat_flock *)arg);
+ ret = get_compat_flock(&f, compat_ptr(arg));
if (ret != 0)
break;
old_fs = get_fs();
@@ -203,15 +203,14 @@
((f.l_start + f.l_len) >= COMPAT_OFF_T_MAX))
ret = -EOVERFLOW;
if (ret == 0)
- ret = put_compat_flock(&f,
- (struct compat_flock *)arg);
+ ret = put_compat_flock(&f, compat_ptr(arg));
}
break;

case F_GETLK64:
case F_SETLK64:
case F_SETLKW64:
- ret = get_compat_flock64(&f, (struct compat_flock64 *)arg);
+ ret = get_compat_flock64(&f, compat_ptr(arg));
if (ret != 0)
break;
old_fs = get_fs();
@@ -226,8 +225,7 @@
((f.l_start + f.l_len) >= COMPAT_LOFF_T_MAX))
ret = -EOVERFLOW;
if (ret == 0)
- ret = put_compat_flock64(&f,
- (struct compat_flock64 *)arg);
+ ret = put_compat_flock64(&f, compat_ptr(arg));
}
break;

diff -ruN 2.5.64-2003031211-32bit.1/include/asm-ia64/compat.h 2.5.64-2003031211-32bit.2/include/asm-ia64/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-ia64/compat.h 2003-03-09 20:34:45.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-ia64/compat.h 2003-03-12 16:41:42.000000000 +1100
@@ -107,4 +107,17 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+
+static inline void *compat_ptr(compat_ptr_t uptr)
+{
+ return (void *)uptr;
+}
+
#endif /* _ASM_IA64_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-mips64/compat.h 2.5.64-2003031211-32bit.2/include/asm-mips64/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-mips64/compat.h 2003-03-09 20:34:45.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-mips64/compat.h 2003-03-12 16:41:56.000000000 +1100
@@ -103,4 +103,17 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+
+static inline void *compat_ptr(compat_ptr_t uptr)
+{
+ return (void *)uptr;
+}
+
#endif /* _ASM_MIPS64_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-parisc/compat.h 2.5.64-2003031211-32bit.2/include/asm-parisc/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-parisc/compat.h 2003-03-12 11:55:19.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-parisc/compat.h 2003-03-12 16:42:07.000000000 +1100
@@ -103,4 +103,17 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+
+static inline void *compat_ptr(compat_ptr_t uptr)
+{
+ return (void *)uptr;
+}
+
#endif /* _ASM_PARISC_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-ppc64/compat.h 2.5.64-2003031211-32bit.2/include/asm-ppc64/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-ppc64/compat.h 2003-03-09 20:34:45.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-ppc64/compat.h 2003-03-12 16:43:27.000000000 +1100
@@ -98,4 +98,17 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+
+static inline void *compat_ptr(compat_ptr_t uptr)
+{
+ return (void *)uptr;
+}
+
#endif /* _ASM_PPC64_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-s390x/compat.h 2.5.64-2003031211-32bit.2/include/asm-s390x/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-s390x/compat.h 2003-03-12 11:55:20.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-s390x/compat.h 2003-03-12 16:42:53.000000000 +1100
@@ -101,4 +101,17 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+
+static inline void *compat_ptr(compat_ptr_t uptr)
+{
+ return (void *)(uptr & 0x7fffffffUL);
+}
+
#endif /* _ASM_S390X_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-sparc64/compat.h 2.5.64-2003031211-32bit.2/include/asm-sparc64/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-sparc64/compat.h 2003-03-09 20:34:45.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-sparc64/compat.h 2003-03-12 16:43:12.000000000 +1100
@@ -100,4 +100,17 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+
+static inline void *compat_ptr(compat_ptr_t uptr)
+{
+ return (void *)uptr;
+}
+
#endif /* _ASM_SPARC64_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/include/asm-x86_64/compat.h 2.5.64-2003031211-32bit.2/include/asm-x86_64/compat.h
--- 2.5.64-2003031211-32bit.1/include/asm-x86_64/compat.h 2003-03-12 11:55:21.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/include/asm-x86_64/compat.h 2003-03-12 16:43:56.000000000 +1100
@@ -107,4 +107,17 @@
#define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffff

+/*
+ * A pointer passed in from user mode. This should not
+ * be used for syscall parameters, just declare them
+ * as pointers because the syscall entry code will have
+ * appropriately comverted them already.
+ */
+typedef u32 compat_uptr_t;
+
+static inline void *compat_ptr(compat_ptr_t uptr)
+{
+ return (void *)uptr;
+}
+
#endif /* _ASM_X86_64_COMPAT_H */
diff -ruN 2.5.64-2003031211-32bit.1/net/compat.c 2.5.64-2003031211-32bit.2/net/compat.c
--- 2.5.64-2003031211-32bit.1/net/compat.c 2003-03-12 11:55:24.000000000 +1100
+++ 2.5.64-2003031211-32bit.2/net/compat.c 2003-03-12 16:48:01.000000000 +1100
@@ -27,7 +27,6 @@
#include <asm/uaccess.h>
#include <net/compat_socket.h>

-#define A(__x) ((unsigned long)(__x))
#define AA(__x) ((unsigned long)(__x))

extern asmlinkage long sys_getsockopt(int fd, int level, int optname,
@@ -49,7 +48,7 @@
break;
}
tot_len += len;
- kiov->iov_base = (void *)A(buf);
+ kiov->iov_base = compat_ptr(buf);
kiov->iov_len = (__kernel_size_t) len;
uiov32++;
kiov++;
@@ -60,7 +59,7 @@

int msghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct compat_msghdr *umsg)
{
- u32 tmp1, tmp2, tmp3;
+ compat_uptr_t tmp1, tmp2, tmp3;
int err;

err = get_user(tmp1, &umsg->msg_name);
@@ -69,9 +68,9 @@
if (err)
return -EFAULT;

- kmsg->msg_name = (void *)A(tmp1);
- kmsg->msg_iov = (struct iovec *)A(tmp2);
- kmsg->msg_control = (void *)A(tmp3);
+ kmsg->msg_name = compat_ptr(tmp1);
+ kmsg->msg_iov = compat_ptr(tmp2);
+ kmsg->msg_control = compat_ptr(tmp3);

err = get_user(kmsg->msg_namelen, &umsg->msg_namelen);
err |= get_user(kmsg->msg_iovlen, &umsg->msg_iovlen);
@@ -451,14 +450,14 @@
struct sock_filter *kfilter;
unsigned int fsize;
mm_segment_t old_fs;
- __u32 uptr;
+ compat_uptr_t uptr;
int ret;

if (get_user(kfprog.len, &fprog32->len) ||
__get_user(uptr, &fprog32->filter))
return -EFAULT;

- kfprog.filter = (struct sock_filter *)A(uptr);
+ kfprog.filter = compat_ptr(uptr);
fsize = kfprog.len * sizeof(struct sock_filter);

kfilter = (struct sock_filter *)kmalloc(fsize, GFP_KERNEL);
@@ -639,36 +638,34 @@
ret = sys_socket(a0, a1, a[2]);
break;
case SYS_BIND:
- ret = sys_bind(a0, (struct sockaddr *)A(a1), a[2]);
+ ret = sys_bind(a0, compat_ptr(a1), a[2]);
break;
case SYS_CONNECT:
- ret = sys_connect(a0, (struct sockaddr *)A(a1), a[2]);
+ ret = sys_connect(a0, compat_ptr(a1), a[2]);
break;
case SYS_LISTEN:
ret = sys_listen(a0, a1);
break;
case SYS_ACCEPT:
- ret = sys_accept(a0, (struct sockaddr *)A(a1), (int *)A(a[2]));
+ ret = sys_accept(a0, compat_ptr(a1), compat_ptr(a[2]));
break;
case SYS_GETSOCKNAME:
- ret = sys_getsockname(a0, (struct sockaddr *)A(a1),
- (int *)A(a[2]));
+ ret = sys_getsockname(a0, compat_ptr(a1), compat_ptr(a[2]));
break;
case SYS_GETPEERNAME:
- ret = sys_getpeername(a0, (struct sockaddr *)A(a1),
- (int *)A(a[2]));
+ ret = sys_getpeername(a0, compat_ptr(a1), compat_ptr(a[2]));
break;
case SYS_SOCKETPAIR:
- ret = sys_socketpair(a0, a1, a[2], (int *)A(a[3]));
+ ret = sys_socketpair(a0, a1, a[2], compat_ptr(a[3]));
break;
case SYS_SEND:
- ret = sys_send(a0, (void *)A(a1), a[2], a[3]);
+ ret = sys_send(a0, compat_ptr(a1), a[2], a[3]);
break;
case SYS_SENDTO:
ret = sys_sendto(a0, a1, a[2], a[3], a[4], a[5]);
break;
case SYS_RECV:
- ret = sys_recv(a0, (void *)A(a1), a[2], a[3]);
+ ret = sys_recv(a0, compat_ptr(a1), a[2], a[3]);
break;
case SYS_RECVFROM:
ret = sys_recvfrom(a0, a1, a[2], a[3], a[4], a[5]);
@@ -677,20 +674,18 @@
ret = sys_shutdown(a0,a1);
break;
case SYS_SETSOCKOPT:
- ret = compat_sys_setsockopt(a0, a1, a[2], (char *)A(a[3]),
- a[4]);
+ ret = compat_sys_setsockopt(a0, a1, a[2],
+ compat_ptr(a[3]), a[4]);
break;
case SYS_GETSOCKOPT:
- ret = compat_sys_getsockopt(a0, a1, a[2], (char *)(u64)a[3],
- (int *)(u64)a[4]);
+ ret = compat_sys_getsockopt(a0, a1, a[2],
+ compat_ptr(a[3]), compat_ptr(a[4]));
break;
case SYS_SENDMSG:
- ret = compat_sys_sendmsg(a0, (struct compat_msghdr *)A(a1),
- a[2]);
+ ret = compat_sys_sendmsg(a0, compat_ptr(a1), a[2]);
break;
case SYS_RECVMSG:
- ret = compat_sys_recvmsg(a0, (struct compat_msghdr *)A(a1),
- a[2]);
+ ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]);
break;
default:
ret = -EINVAL;

2003-03-12 11:36:14

by David Miller

[permalink] [raw]
Subject: Re: [PATCH][COMPAT] compat_sys_fcntl{,64} 1/9 Generic part

On Tue, 2003-03-11 at 21:26, Linus Torvalds wrote:

> Yes, this looks much more sane. If you _really_ want to be anal about
> typechecking (and also checking that nobody can possibly use a user
> pointer incorrectly), you make
>
> typedef struct {
> unsigned int val;
> } compat_uptr_t;

Be careful, these kind of "int in a struct" things end up being
passed to functions on the stack instead of registers :-(

This is why we don't do any of the fancy type-checking
page table types on Sparc unless you edit the header files.