Skip to content

Commit 2ed7c03

Browse files
committed
[CVE-2009-0029] Convert all system calls to return a long
Convert all system calls to return a long. This should be a NOP since all converted types should have the same size anyway. With the exception of sys_exit_group which returned void. But that doesn't matter since the system call doesn't return. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
1 parent 4c696ba commit 2ed7c03

11 files changed

Lines changed: 64 additions & 63 deletions

File tree

‎fs/read_write.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ loff_t vfs_llseek(struct file *file, loff_t offset, int origin)
147147
}
148148
EXPORT_SYMBOL(vfs_llseek);
149149

150-
asmlinkage off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
150+
asmlinkage long sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
151151
{
152152
off_t retval;
153153
struct file * file;
@@ -369,7 +369,7 @@ static inline void file_pos_write(struct file *file, loff_t pos)
369369
file->f_pos = pos;
370370
}
371371

372-
asmlinkage ssize_t sys_read(unsigned int fd, char __user * buf, size_t count)
372+
asmlinkage long sys_read(unsigned int fd, char __user * buf, size_t count)
373373
{
374374
struct file *file;
375375
ssize_t ret = -EBADF;
@@ -386,7 +386,7 @@ asmlinkage ssize_t sys_read(unsigned int fd, char __user * buf, size_t count)
386386
return ret;
387387
}
388388

389-
asmlinkage ssize_t sys_write(unsigned int fd, const char __user * buf, size_t count)
389+
asmlinkage long sys_write(unsigned int fd, const char __user * buf, size_t count)
390390
{
391391
struct file *file;
392392
ssize_t ret = -EBADF;
@@ -403,7 +403,7 @@ asmlinkage ssize_t sys_write(unsigned int fd, const char __user * buf, size_t co
403403
return ret;
404404
}
405405

406-
asmlinkage ssize_t sys_pread64(unsigned int fd, char __user *buf,
406+
asmlinkage long sys_pread64(unsigned int fd, char __user *buf,
407407
size_t count, loff_t pos)
408408
{
409409
struct file *file;
@@ -424,7 +424,7 @@ asmlinkage ssize_t sys_pread64(unsigned int fd, char __user *buf,
424424
return ret;
425425
}
426426

427-
asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char __user *buf,
427+
asmlinkage long sys_pwrite64(unsigned int fd, const char __user *buf,
428428
size_t count, loff_t pos)
429429
{
430430
struct file *file;
@@ -672,7 +672,7 @@ ssize_t vfs_writev(struct file *file, const struct iovec __user *vec,
672672

673673
EXPORT_SYMBOL(vfs_writev);
674674

675-
asmlinkage ssize_t
675+
asmlinkage long
676676
sys_readv(unsigned long fd, const struct iovec __user *vec, unsigned long vlen)
677677
{
678678
struct file *file;
@@ -693,7 +693,7 @@ sys_readv(unsigned long fd, const struct iovec __user *vec, unsigned long vlen)
693693
return ret;
694694
}
695695

696-
asmlinkage ssize_t
696+
asmlinkage long
697697
sys_writev(unsigned long fd, const struct iovec __user *vec, unsigned long vlen)
698698
{
699699
struct file *file;
@@ -812,7 +812,7 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
812812
return retval;
813813
}
814814

815-
asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t __user *offset, size_t count)
815+
asmlinkage long sys_sendfile(int out_fd, int in_fd, off_t __user *offset, size_t count)
816816
{
817817
loff_t pos;
818818
off_t off;
@@ -831,7 +831,7 @@ asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t __user *offset, siz
831831
return do_sendfile(out_fd, in_fd, NULL, count, 0);
832832
}
833833

834-
asmlinkage ssize_t sys_sendfile64(int out_fd, int in_fd, loff_t __user *offset, size_t count)
834+
asmlinkage long sys_sendfile64(int out_fd, int in_fd, loff_t __user *offset, size_t count)
835835
{
836836
loff_t pos;
837837
ssize_t ret;

‎fs/xattr.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ getxattr(struct dentry *d, const char __user *name, void __user *value,
349349
return error;
350350
}
351351

352-
asmlinkage ssize_t
352+
asmlinkage long
353353
sys_getxattr(const char __user *pathname, const char __user *name,
354354
void __user *value, size_t size)
355355
{
@@ -364,7 +364,7 @@ sys_getxattr(const char __user *pathname, const char __user *name,
364364
return error;
365365
}
366366

367-
asmlinkage ssize_t
367+
asmlinkage long
368368
sys_lgetxattr(const char __user *pathname, const char __user *name, void __user *value,
369369
size_t size)
370370
{
@@ -379,7 +379,7 @@ sys_lgetxattr(const char __user *pathname, const char __user *name, void __user
379379
return error;
380380
}
381381

382-
asmlinkage ssize_t
382+
asmlinkage long
383383
sys_fgetxattr(int fd, const char __user *name, void __user *value, size_t size)
384384
{
385385
struct file *f;
@@ -424,7 +424,7 @@ listxattr(struct dentry *d, char __user *list, size_t size)
424424
return error;
425425
}
426426

427-
asmlinkage ssize_t
427+
asmlinkage long
428428
sys_listxattr(const char __user *pathname, char __user *list, size_t size)
429429
{
430430
struct path path;
@@ -438,7 +438,7 @@ sys_listxattr(const char __user *pathname, char __user *list, size_t size)
438438
return error;
439439
}
440440

441-
asmlinkage ssize_t
441+
asmlinkage long
442442
sys_llistxattr(const char __user *pathname, char __user *list, size_t size)
443443
{
444444
struct path path;
@@ -452,7 +452,7 @@ sys_llistxattr(const char __user *pathname, char __user *list, size_t size)
452452
return error;
453453
}
454454

455-
asmlinkage ssize_t
455+
asmlinkage long
456456
sys_flistxattr(int fd, char __user *list, size_t size)
457457
{
458458
struct file *f;

‎include/linux/syscalls.h‎

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ asmlinkage long sys_times(struct tms __user *tbuf);
7777

7878
asmlinkage long sys_gettid(void);
7979
asmlinkage long sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp);
80-
asmlinkage unsigned long sys_alarm(unsigned int seconds);
80+
asmlinkage long sys_alarm(unsigned int seconds);
8181
asmlinkage long sys_getpid(void);
8282
asmlinkage long sys_getppid(void);
8383
asmlinkage long sys_getuid(void);
@@ -166,7 +166,7 @@ asmlinkage long sys_kexec_load(unsigned long entry, unsigned long nr_segments,
166166
unsigned long flags);
167167

168168
asmlinkage long sys_exit(int error_code);
169-
asmlinkage void sys_exit_group(int error_code);
169+
asmlinkage long sys_exit_group(int error_code);
170170
asmlinkage long sys_wait4(pid_t pid, int __user *stat_addr,
171171
int options, struct rusage __user *ru);
172172
asmlinkage long sys_waitid(int which, pid_t pid,
@@ -196,7 +196,7 @@ asmlinkage long sys_tkill(int pid, int sig);
196196
asmlinkage long sys_rt_sigqueueinfo(int pid, int sig, siginfo_t __user *uinfo);
197197
asmlinkage long sys_sgetmask(void);
198198
asmlinkage long sys_ssetmask(int newmask);
199-
asmlinkage unsigned long sys_signal(int sig, __sighandler_t handler);
199+
asmlinkage long sys_signal(int sig, __sighandler_t handler);
200200
asmlinkage long sys_pause(void);
201201

202202
asmlinkage long sys_sync(void);
@@ -246,29 +246,29 @@ asmlinkage long sys_lsetxattr(const char __user *path, const char __user *name,
246246
const void __user *value, size_t size, int flags);
247247
asmlinkage long sys_fsetxattr(int fd, const char __user *name,
248248
const void __user *value, size_t size, int flags);
249-
asmlinkage ssize_t sys_getxattr(const char __user *path, const char __user *name,
250-
void __user *value, size_t size);
251-
asmlinkage ssize_t sys_lgetxattr(const char __user *path, const char __user *name,
252-
void __user *value, size_t size);
253-
asmlinkage ssize_t sys_fgetxattr(int fd, const char __user *name,
254-
void __user *value, size_t size);
255-
asmlinkage ssize_t sys_listxattr(const char __user *path, char __user *list,
256-
size_t size);
257-
asmlinkage ssize_t sys_llistxattr(const char __user *path, char __user *list,
258-
size_t size);
259-
asmlinkage ssize_t sys_flistxattr(int fd, char __user *list, size_t size);
249+
asmlinkage long sys_getxattr(const char __user *path, const char __user *name,
250+
void __user *value, size_t size);
251+
asmlinkage long sys_lgetxattr(const char __user *path, const char __user *name,
252+
void __user *value, size_t size);
253+
asmlinkage long sys_fgetxattr(int fd, const char __user *name,
254+
void __user *value, size_t size);
255+
asmlinkage long sys_listxattr(const char __user *path, char __user *list,
256+
size_t size);
257+
asmlinkage long sys_llistxattr(const char __user *path, char __user *list,
258+
size_t size);
259+
asmlinkage long sys_flistxattr(int fd, char __user *list, size_t size);
260260
asmlinkage long sys_removexattr(const char __user *path,
261261
const char __user *name);
262262
asmlinkage long sys_lremovexattr(const char __user *path,
263263
const char __user *name);
264264
asmlinkage long sys_fremovexattr(int fd, const char __user *name);
265265

266-
asmlinkage unsigned long sys_brk(unsigned long brk);
266+
asmlinkage long sys_brk(unsigned long brk);
267267
asmlinkage long sys_mprotect(unsigned long start, size_t len,
268268
unsigned long prot);
269-
asmlinkage unsigned long sys_mremap(unsigned long addr,
270-
unsigned long old_len, unsigned long new_len,
271-
unsigned long flags, unsigned long new_addr);
269+
asmlinkage long sys_mremap(unsigned long addr,
270+
unsigned long old_len, unsigned long new_len,
271+
unsigned long flags, unsigned long new_addr);
272272
asmlinkage long sys_remap_file_pages(unsigned long start, unsigned long size,
273273
unsigned long prot, unsigned long pgoff,
274274
unsigned long flags);
@@ -321,10 +321,10 @@ asmlinkage long sys_io_submit(aio_context_t, long,
321321
struct iocb __user * __user *);
322322
asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb __user *iocb,
323323
struct io_event __user *result);
324-
asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd,
325-
off_t __user *offset, size_t count);
326-
asmlinkage ssize_t sys_sendfile64(int out_fd, int in_fd,
327-
loff_t __user *offset, size_t count);
324+
asmlinkage long sys_sendfile(int out_fd, int in_fd,
325+
off_t __user *offset, size_t count);
326+
asmlinkage long sys_sendfile64(int out_fd, int in_fd,
327+
loff_t __user *offset, size_t count);
328328
asmlinkage long sys_readlink(const char __user *path,
329329
char __user *buf, int bufsiz);
330330
asmlinkage long sys_creat(const char __user *pathname, int mode);
@@ -368,26 +368,25 @@ asmlinkage long sys_utime(char __user *filename,
368368
struct utimbuf __user *times);
369369
asmlinkage long sys_utimes(char __user *filename,
370370
struct timeval __user *utimes);
371-
asmlinkage off_t sys_lseek(unsigned int fd, off_t offset,
372-
unsigned int origin);
371+
asmlinkage long sys_lseek(unsigned int fd, off_t offset,
372+
unsigned int origin);
373373
asmlinkage long sys_llseek(unsigned int fd, unsigned long offset_high,
374374
unsigned long offset_low, loff_t __user *result,
375375
unsigned int origin);
376-
asmlinkage ssize_t sys_read(unsigned int fd, char __user *buf,
377-
size_t count);
378-
asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count);
379-
asmlinkage ssize_t sys_readv(unsigned long fd,
380-
const struct iovec __user *vec,
381-
unsigned long vlen);
382-
asmlinkage ssize_t sys_write(unsigned int fd, const char __user *buf,
383-
size_t count);
384-
asmlinkage ssize_t sys_writev(unsigned long fd,
385-
const struct iovec __user *vec,
386-
unsigned long vlen);
387-
asmlinkage ssize_t sys_pread64(unsigned int fd, char __user *buf,
388-
size_t count, loff_t pos);
389-
asmlinkage ssize_t sys_pwrite64(unsigned int fd, const char __user *buf,
390-
size_t count, loff_t pos);
376+
asmlinkage long sys_read(unsigned int fd, char __user *buf, size_t count);
377+
asmlinkage long sys_readahead(int fd, loff_t offset, size_t count);
378+
asmlinkage long sys_readv(unsigned long fd,
379+
const struct iovec __user *vec,
380+
unsigned long vlen);
381+
asmlinkage long sys_write(unsigned int fd, const char __user *buf,
382+
size_t count);
383+
asmlinkage long sys_writev(unsigned long fd,
384+
const struct iovec __user *vec,
385+
unsigned long vlen);
386+
asmlinkage long sys_pread64(unsigned int fd, char __user *buf,
387+
size_t count, loff_t pos);
388+
asmlinkage long sys_pwrite64(unsigned int fd, const char __user *buf,
389+
size_t count, loff_t pos);
391390
asmlinkage long sys_getcwd(char __user *buf, unsigned long size);
392391
asmlinkage long sys_mkdir(const char __user *pathname, int mode);
393392
asmlinkage long sys_chdir(const char __user *filename);
@@ -476,7 +475,7 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
476475
asmlinkage long sys_mq_open(const char __user *name, int oflag, mode_t mode, struct mq_attr __user *attr);
477476
asmlinkage long sys_mq_unlink(const char __user *name);
478477
asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec __user *abs_timeout);
479-
asmlinkage ssize_t sys_mq_timedreceive(mqd_t mqdes, char __user *msg_ptr, size_t msg_len, unsigned int __user *msg_prio, const struct timespec __user *abs_timeout);
478+
asmlinkage long sys_mq_timedreceive(mqd_t mqdes, char __user *msg_ptr, size_t msg_len, unsigned int __user *msg_prio, const struct timespec __user *abs_timeout);
480479
asmlinkage long sys_mq_notify(mqd_t mqdes, const struct sigevent __user *notification);
481480
asmlinkage long sys_mq_getsetattr(mqd_t mqdes, const struct mq_attr __user *mqstat, struct mq_attr __user *omqstat);
482481

‎ipc/mqueue.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,
907907
return ret;
908908
}
909909

910-
asmlinkage ssize_t sys_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
910+
asmlinkage long sys_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
911911
size_t msg_len, unsigned int __user *u_msg_prio,
912912
const struct timespec __user *u_abs_timeout)
913913
{

‎kernel/exit.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,9 +1182,11 @@ do_group_exit(int exit_code)
11821182
* wait4()-ing process will get the correct exit code - even if this
11831183
* thread is not the thread group leader.
11841184
*/
1185-
asmlinkage void sys_exit_group(int error_code)
1185+
asmlinkage long sys_exit_group(int error_code)
11861186
{
11871187
do_group_exit((error_code & 0xff) << 8);
1188+
/* NOTREACHED */
1189+
return 0;
11881190
}
11891191

11901192
static struct pid *task_pid_type(struct task_struct *task, enum pid_type type)

‎kernel/signal.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,7 @@ sys_ssetmask(int newmask)
25592559
/*
25602560
* For backwards compatibility. Functionality superseded by sigaction.
25612561
*/
2562-
asmlinkage unsigned long
2562+
asmlinkage long
25632563
sys_signal(int sig, __sighandler_t handler)
25642564
{
25652565
struct k_sigaction new_sa, old_sa;

‎kernel/timer.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ void do_timer(unsigned long ticks)
11291129
* For backwards compatibility? This can be done in libc so Alpha
11301130
* and all newer ports shouldn't need it.
11311131
*/
1132-
asmlinkage unsigned long sys_alarm(unsigned int seconds)
1132+
asmlinkage long sys_alarm(unsigned int seconds)
11331133
{
11341134
return alarm_setitimer(seconds);
11351135
}

‎mm/filemap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ do_readahead(struct address_space *mapping, struct file *filp,
13741374
return 0;
13751375
}
13761376

1377-
asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count)
1377+
asmlinkage long sys_readahead(int fd, loff_t offset, size_t count)
13781378
{
13791379
ssize_t ret;
13801380
struct file *file;

‎mm/mmap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
245245
return next;
246246
}
247247

248-
asmlinkage unsigned long sys_brk(unsigned long brk)
248+
asmlinkage long sys_brk(unsigned long brk)
249249
{
250250
unsigned long rlim, retval;
251251
unsigned long newbrk, oldbrk;

‎mm/mremap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ unsigned long do_mremap(unsigned long addr,
420420
return ret;
421421
}
422422

423-
asmlinkage unsigned long sys_mremap(unsigned long addr,
423+
asmlinkage long sys_mremap(unsigned long addr,
424424
unsigned long old_len, unsigned long new_len,
425425
unsigned long flags, unsigned long new_addr)
426426
{

0 commit comments

Comments
 (0)