diff options
author | David Howells <dhowells@redhat.com> | 2010-08-11 06:26:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-13 19:53:13 -0400 |
commit | c7887325230aec47d47a32562a6e26014a0fafca (patch) | |
tree | 10535943dace59ddb01d3440aa582bc4640e8016 /fs | |
parent | b84ae4a1401a731ef5fee987c0cb08743838dda7 (diff) |
Mark arguments to certain syscalls as being const
Mark arguments to certain system calls as being const where they should be but
aren't. The list includes:
(*) The filename arguments of various stat syscalls, execve(), various utimes
syscalls and some mount syscalls.
(*) The filename arguments of some syscall helpers relating to the above.
(*) The buffer argument of various write syscalls.
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/compat.c | 23 | ||||
-rw-r--r-- | fs/stat.c | 29 | ||||
-rw-r--r-- | fs/utimes.c | 7 |
3 files changed, 35 insertions, 24 deletions
diff --git a/fs/compat.c b/fs/compat.c index e6d5d70cf3cf..718c7062aec1 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -77,7 +77,8 @@ int compat_printk(const char *fmt, ...) | |||
77 | * Not all architectures have sys_utime, so implement this in terms | 77 | * Not all architectures have sys_utime, so implement this in terms |
78 | * of sys_utimes. | 78 | * of sys_utimes. |
79 | */ | 79 | */ |
80 | asmlinkage long compat_sys_utime(char __user *filename, struct compat_utimbuf __user *t) | 80 | asmlinkage long compat_sys_utime(const char __user *filename, |
81 | struct compat_utimbuf __user *t) | ||
81 | { | 82 | { |
82 | struct timespec tv[2]; | 83 | struct timespec tv[2]; |
83 | 84 | ||
@@ -91,7 +92,7 @@ asmlinkage long compat_sys_utime(char __user *filename, struct compat_utimbuf __ | |||
91 | return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0); | 92 | return do_utimes(AT_FDCWD, filename, t ? tv : NULL, 0); |
92 | } | 93 | } |
93 | 94 | ||
94 | asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename, struct compat_timespec __user *t, int flags) | 95 | asmlinkage long compat_sys_utimensat(unsigned int dfd, const char __user *filename, struct compat_timespec __user *t, int flags) |
95 | { | 96 | { |
96 | struct timespec tv[2]; | 97 | struct timespec tv[2]; |
97 | 98 | ||
@@ -106,7 +107,7 @@ asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename, st | |||
106 | return do_utimes(dfd, filename, t ? tv : NULL, flags); | 107 | return do_utimes(dfd, filename, t ? tv : NULL, flags); |
107 | } | 108 | } |
108 | 109 | ||
109 | asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename, struct compat_timeval __user *t) | 110 | asmlinkage long compat_sys_futimesat(unsigned int dfd, const char __user *filename, struct compat_timeval __user *t) |
110 | { | 111 | { |
111 | struct timespec tv[2]; | 112 | struct timespec tv[2]; |
112 | 113 | ||
@@ -125,7 +126,7 @@ asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename, st | |||
125 | return do_utimes(dfd, filename, t ? tv : NULL, 0); | 126 | return do_utimes(dfd, filename, t ? tv : NULL, 0); |
126 | } | 127 | } |
127 | 128 | ||
128 | asmlinkage long compat_sys_utimes(char __user *filename, struct compat_timeval __user *t) | 129 | asmlinkage long compat_sys_utimes(const char __user *filename, struct compat_timeval __user *t) |
129 | { | 130 | { |
130 | return compat_sys_futimesat(AT_FDCWD, filename, t); | 131 | return compat_sys_futimesat(AT_FDCWD, filename, t); |
131 | } | 132 | } |
@@ -169,7 +170,7 @@ static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf) | |||
169 | return err; | 170 | return err; |
170 | } | 171 | } |
171 | 172 | ||
172 | asmlinkage long compat_sys_newstat(char __user * filename, | 173 | asmlinkage long compat_sys_newstat(const char __user * filename, |
173 | struct compat_stat __user *statbuf) | 174 | struct compat_stat __user *statbuf) |
174 | { | 175 | { |
175 | struct kstat stat; | 176 | struct kstat stat; |
@@ -181,7 +182,7 @@ asmlinkage long compat_sys_newstat(char __user * filename, | |||
181 | return cp_compat_stat(&stat, statbuf); | 182 | return cp_compat_stat(&stat, statbuf); |
182 | } | 183 | } |
183 | 184 | ||
184 | asmlinkage long compat_sys_newlstat(char __user * filename, | 185 | asmlinkage long compat_sys_newlstat(const char __user * filename, |
185 | struct compat_stat __user *statbuf) | 186 | struct compat_stat __user *statbuf) |
186 | { | 187 | { |
187 | struct kstat stat; | 188 | struct kstat stat; |
@@ -194,7 +195,8 @@ asmlinkage long compat_sys_newlstat(char __user * filename, | |||
194 | } | 195 | } |
195 | 196 | ||
196 | #ifndef __ARCH_WANT_STAT64 | 197 | #ifndef __ARCH_WANT_STAT64 |
197 | asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename, | 198 | asmlinkage long compat_sys_newfstatat(unsigned int dfd, |
199 | const char __user *filename, | ||
198 | struct compat_stat __user *statbuf, int flag) | 200 | struct compat_stat __user *statbuf, int flag) |
199 | { | 201 | { |
200 | struct kstat stat; | 202 | struct kstat stat; |
@@ -837,9 +839,10 @@ static int do_nfs4_super_data_conv(void *raw_data) | |||
837 | #define NCPFS_NAME "ncpfs" | 839 | #define NCPFS_NAME "ncpfs" |
838 | #define NFS4_NAME "nfs4" | 840 | #define NFS4_NAME "nfs4" |
839 | 841 | ||
840 | asmlinkage long compat_sys_mount(char __user * dev_name, char __user * dir_name, | 842 | asmlinkage long compat_sys_mount(const char __user * dev_name, |
841 | char __user * type, unsigned long flags, | 843 | const char __user * dir_name, |
842 | void __user * data) | 844 | const char __user * type, unsigned long flags, |
845 | const void __user * data) | ||
843 | { | 846 | { |
844 | char *kernel_type; | 847 | char *kernel_type; |
845 | unsigned long data_page; | 848 | unsigned long data_page; |
@@ -68,7 +68,8 @@ int vfs_fstat(unsigned int fd, struct kstat *stat) | |||
68 | } | 68 | } |
69 | EXPORT_SYMBOL(vfs_fstat); | 69 | EXPORT_SYMBOL(vfs_fstat); |
70 | 70 | ||
71 | int vfs_fstatat(int dfd, char __user *filename, struct kstat *stat, int flag) | 71 | int vfs_fstatat(int dfd, const char __user *filename, struct kstat *stat, |
72 | int flag) | ||
72 | { | 73 | { |
73 | struct path path; | 74 | struct path path; |
74 | int error = -EINVAL; | 75 | int error = -EINVAL; |
@@ -91,13 +92,13 @@ out: | |||
91 | } | 92 | } |
92 | EXPORT_SYMBOL(vfs_fstatat); | 93 | EXPORT_SYMBOL(vfs_fstatat); |
93 | 94 | ||
94 | int vfs_stat(char __user *name, struct kstat *stat) | 95 | int vfs_stat(const char __user *name, struct kstat *stat) |
95 | { | 96 | { |
96 | return vfs_fstatat(AT_FDCWD, name, stat, 0); | 97 | return vfs_fstatat(AT_FDCWD, name, stat, 0); |
97 | } | 98 | } |
98 | EXPORT_SYMBOL(vfs_stat); | 99 | EXPORT_SYMBOL(vfs_stat); |
99 | 100 | ||
100 | int vfs_lstat(char __user *name, struct kstat *stat) | 101 | int vfs_lstat(const char __user *name, struct kstat *stat) |
101 | { | 102 | { |
102 | return vfs_fstatat(AT_FDCWD, name, stat, AT_SYMLINK_NOFOLLOW); | 103 | return vfs_fstatat(AT_FDCWD, name, stat, AT_SYMLINK_NOFOLLOW); |
103 | } | 104 | } |
@@ -147,7 +148,8 @@ static int cp_old_stat(struct kstat *stat, struct __old_kernel_stat __user * sta | |||
147 | return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0; | 148 | return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0; |
148 | } | 149 | } |
149 | 150 | ||
150 | SYSCALL_DEFINE2(stat, char __user *, filename, struct __old_kernel_stat __user *, statbuf) | 151 | SYSCALL_DEFINE2(stat, const char __user *, filename, |
152 | struct __old_kernel_stat __user *, statbuf) | ||
151 | { | 153 | { |
152 | struct kstat stat; | 154 | struct kstat stat; |
153 | int error; | 155 | int error; |
@@ -159,7 +161,8 @@ SYSCALL_DEFINE2(stat, char __user *, filename, struct __old_kernel_stat __user * | |||
159 | return cp_old_stat(&stat, statbuf); | 161 | return cp_old_stat(&stat, statbuf); |
160 | } | 162 | } |
161 | 163 | ||
162 | SYSCALL_DEFINE2(lstat, char __user *, filename, struct __old_kernel_stat __user *, statbuf) | 164 | SYSCALL_DEFINE2(lstat, const char __user *, filename, |
165 | struct __old_kernel_stat __user *, statbuf) | ||
163 | { | 166 | { |
164 | struct kstat stat; | 167 | struct kstat stat; |
165 | int error; | 168 | int error; |
@@ -234,7 +237,8 @@ static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf) | |||
234 | return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0; | 237 | return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0; |
235 | } | 238 | } |
236 | 239 | ||
237 | SYSCALL_DEFINE2(newstat, char __user *, filename, struct stat __user *, statbuf) | 240 | SYSCALL_DEFINE2(newstat, const char __user *, filename, |
241 | struct stat __user *, statbuf) | ||
238 | { | 242 | { |
239 | struct kstat stat; | 243 | struct kstat stat; |
240 | int error = vfs_stat(filename, &stat); | 244 | int error = vfs_stat(filename, &stat); |
@@ -244,7 +248,8 @@ SYSCALL_DEFINE2(newstat, char __user *, filename, struct stat __user *, statbuf) | |||
244 | return cp_new_stat(&stat, statbuf); | 248 | return cp_new_stat(&stat, statbuf); |
245 | } | 249 | } |
246 | 250 | ||
247 | SYSCALL_DEFINE2(newlstat, char __user *, filename, struct stat __user *, statbuf) | 251 | SYSCALL_DEFINE2(newlstat, const char __user *, filename, |
252 | struct stat __user *, statbuf) | ||
248 | { | 253 | { |
249 | struct kstat stat; | 254 | struct kstat stat; |
250 | int error; | 255 | int error; |
@@ -257,7 +262,7 @@ SYSCALL_DEFINE2(newlstat, char __user *, filename, struct stat __user *, statbuf | |||
257 | } | 262 | } |
258 | 263 | ||
259 | #if !defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_SYS_NEWFSTATAT) | 264 | #if !defined(__ARCH_WANT_STAT64) || defined(__ARCH_WANT_SYS_NEWFSTATAT) |
260 | SYSCALL_DEFINE4(newfstatat, int, dfd, char __user *, filename, | 265 | SYSCALL_DEFINE4(newfstatat, int, dfd, const char __user *, filename, |
261 | struct stat __user *, statbuf, int, flag) | 266 | struct stat __user *, statbuf, int, flag) |
262 | { | 267 | { |
263 | struct kstat stat; | 268 | struct kstat stat; |
@@ -355,7 +360,8 @@ static long cp_new_stat64(struct kstat *stat, struct stat64 __user *statbuf) | |||
355 | return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0; | 360 | return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0; |
356 | } | 361 | } |
357 | 362 | ||
358 | SYSCALL_DEFINE2(stat64, char __user *, filename, struct stat64 __user *, statbuf) | 363 | SYSCALL_DEFINE2(stat64, const char __user *, filename, |
364 | struct stat64 __user *, statbuf) | ||
359 | { | 365 | { |
360 | struct kstat stat; | 366 | struct kstat stat; |
361 | int error = vfs_stat(filename, &stat); | 367 | int error = vfs_stat(filename, &stat); |
@@ -366,7 +372,8 @@ SYSCALL_DEFINE2(stat64, char __user *, filename, struct stat64 __user *, statbuf | |||
366 | return error; | 372 | return error; |
367 | } | 373 | } |
368 | 374 | ||
369 | SYSCALL_DEFINE2(lstat64, char __user *, filename, struct stat64 __user *, statbuf) | 375 | SYSCALL_DEFINE2(lstat64, const char __user *, filename, |
376 | struct stat64 __user *, statbuf) | ||
370 | { | 377 | { |
371 | struct kstat stat; | 378 | struct kstat stat; |
372 | int error = vfs_lstat(filename, &stat); | 379 | int error = vfs_lstat(filename, &stat); |
@@ -388,7 +395,7 @@ SYSCALL_DEFINE2(fstat64, unsigned long, fd, struct stat64 __user *, statbuf) | |||
388 | return error; | 395 | return error; |
389 | } | 396 | } |
390 | 397 | ||
391 | SYSCALL_DEFINE4(fstatat64, int, dfd, char __user *, filename, | 398 | SYSCALL_DEFINE4(fstatat64, int, dfd, const char __user *, filename, |
392 | struct stat64 __user *, statbuf, int, flag) | 399 | struct stat64 __user *, statbuf, int, flag) |
393 | { | 400 | { |
394 | struct kstat stat; | 401 | struct kstat stat; |
diff --git a/fs/utimes.c b/fs/utimes.c index e4c75db5d373..179b58690657 100644 --- a/fs/utimes.c +++ b/fs/utimes.c | |||
@@ -126,7 +126,8 @@ out: | |||
126 | * must be owner or have write permission. | 126 | * must be owner or have write permission. |
127 | * Else, update from *times, must be owner or super user. | 127 | * Else, update from *times, must be owner or super user. |
128 | */ | 128 | */ |
129 | long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags) | 129 | long do_utimes(int dfd, const char __user *filename, struct timespec *times, |
130 | int flags) | ||
130 | { | 131 | { |
131 | int error = -EINVAL; | 132 | int error = -EINVAL; |
132 | 133 | ||
@@ -170,7 +171,7 @@ out: | |||
170 | return error; | 171 | return error; |
171 | } | 172 | } |
172 | 173 | ||
173 | SYSCALL_DEFINE4(utimensat, int, dfd, char __user *, filename, | 174 | SYSCALL_DEFINE4(utimensat, int, dfd, const char __user *, filename, |
174 | struct timespec __user *, utimes, int, flags) | 175 | struct timespec __user *, utimes, int, flags) |
175 | { | 176 | { |
176 | struct timespec tstimes[2]; | 177 | struct timespec tstimes[2]; |
@@ -188,7 +189,7 @@ SYSCALL_DEFINE4(utimensat, int, dfd, char __user *, filename, | |||
188 | return do_utimes(dfd, filename, utimes ? tstimes : NULL, flags); | 189 | return do_utimes(dfd, filename, utimes ? tstimes : NULL, flags); |
189 | } | 190 | } |
190 | 191 | ||
191 | SYSCALL_DEFINE3(futimesat, int, dfd, char __user *, filename, | 192 | SYSCALL_DEFINE3(futimesat, int, dfd, const char __user *, filename, |
192 | struct timeval __user *, utimes) | 193 | struct timeval __user *, utimes) |
193 | { | 194 | { |
194 | struct timeval times[2]; | 195 | struct timeval times[2]; |