diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2006-02-02 00:11:51 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-02 01:04:33 -0500 |
commit | 9ad11ab48b1ad618bf47076e9e579f267f5306c2 (patch) | |
tree | b0b06f4455d9796fc5003add2067f2dbc225fc53 | |
parent | 8aeba3c62a64e0f6527d1a0388b1a6a7060158ba (diff) |
[PATCH] compat: fix compat_sys_openat and friends
Most of the 64 bit architectures will zero extend the first argument to
compat_sys_{openat,newfstatat,futimesat} which will fail if the 32 bit
syscall was passed AT_FDCWD (which is a small negative number). Declare
the first argument to be an unsigned int which will force the correct
sign extension when the internal functions are called in each case.
Also, do some small white space cleanups in fs/compat.c.
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/compat.c | 12 | ||||
-rw-r--r-- | include/linux/syscalls.h | 6 |
2 files changed, 9 insertions, 9 deletions
diff --git a/fs/compat.c b/fs/compat.c index cc58a20df57a..70c5af4cc270 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -73,17 +73,17 @@ asmlinkage long compat_sys_utime(char __user *filename, struct compat_utimbuf __ | |||
73 | return do_utimes(AT_FDCWD, filename, t ? tv : NULL); | 73 | return do_utimes(AT_FDCWD, filename, t ? tv : NULL); |
74 | } | 74 | } |
75 | 75 | ||
76 | asmlinkage long compat_sys_futimesat(int dfd, char __user *filename, struct compat_timeval __user *t) | 76 | asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename, struct compat_timeval __user *t) |
77 | { | 77 | { |
78 | struct timeval tv[2]; | 78 | struct timeval tv[2]; |
79 | 79 | ||
80 | if (t) { | 80 | if (t) { |
81 | if (get_user(tv[0].tv_sec, &t[0].tv_sec) || | 81 | if (get_user(tv[0].tv_sec, &t[0].tv_sec) || |
82 | get_user(tv[0].tv_usec, &t[0].tv_usec) || | 82 | get_user(tv[0].tv_usec, &t[0].tv_usec) || |
83 | get_user(tv[1].tv_sec, &t[1].tv_sec) || | 83 | get_user(tv[1].tv_sec, &t[1].tv_sec) || |
84 | get_user(tv[1].tv_usec, &t[1].tv_usec)) | 84 | get_user(tv[1].tv_usec, &t[1].tv_usec)) |
85 | return -EFAULT; | 85 | return -EFAULT; |
86 | } | 86 | } |
87 | return do_utimes(dfd, filename, t ? tv : NULL); | 87 | return do_utimes(dfd, filename, t ? tv : NULL); |
88 | } | 88 | } |
89 | 89 | ||
@@ -114,7 +114,7 @@ asmlinkage long compat_sys_newlstat(char __user * filename, | |||
114 | return error; | 114 | return error; |
115 | } | 115 | } |
116 | 116 | ||
117 | asmlinkage long compat_sys_newfstatat(int dfd, char __user *filename, | 117 | asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename, |
118 | struct compat_stat __user *statbuf, int flag) | 118 | struct compat_stat __user *statbuf, int flag) |
119 | { | 119 | { |
120 | struct kstat stat; | 120 | struct kstat stat; |
@@ -1326,7 +1326,7 @@ compat_sys_open(const char __user *filename, int flags, int mode) | |||
1326 | * O_LARGEFILE flag. | 1326 | * O_LARGEFILE flag. |
1327 | */ | 1327 | */ |
1328 | asmlinkage long | 1328 | asmlinkage long |
1329 | compat_sys_openat(int dfd, const char __user *filename, int flags, int mode) | 1329 | compat_sys_openat(unsigned int dfd, const char __user *filename, int flags, int mode) |
1330 | { | 1330 | { |
1331 | return do_sys_open(dfd, filename, flags, mode); | 1331 | return do_sys_open(dfd, filename, flags, mode); |
1332 | } | 1332 | } |
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index fdbd436b24cc..3877209d23c3 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
@@ -559,12 +559,12 @@ asmlinkage long sys_newfstatat(int dfd, char __user *filename, | |||
559 | struct stat __user *statbuf, int flag); | 559 | struct stat __user *statbuf, int flag); |
560 | asmlinkage long sys_readlinkat(int dfd, const char __user *path, char __user *buf, | 560 | asmlinkage long sys_readlinkat(int dfd, const char __user *path, char __user *buf, |
561 | int bufsiz); | 561 | int bufsiz); |
562 | asmlinkage long compat_sys_futimesat(int dfd, char __user *filename, | 562 | asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename, |
563 | struct compat_timeval __user *t); | 563 | struct compat_timeval __user *t); |
564 | asmlinkage long compat_sys_newfstatat(int dfd, char __user * filename, | 564 | asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user * filename, |
565 | struct compat_stat __user *statbuf, | 565 | struct compat_stat __user *statbuf, |
566 | int flag); | 566 | int flag); |
567 | asmlinkage long compat_sys_openat(int dfd, const char __user *filename, | 567 | asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename, |
568 | int flags, int mode); | 568 | int flags, int mode); |
569 | 569 | ||
570 | #endif | 570 | #endif |