Commit 562f5e638de4ef451226552fe8dd7847bacea24e
Committed by
Linus Torvalds
1 parent
f0cfec1118
Exists in
master
and in
4 other branches
init: mark __user address space on string literals
When calling syscall service routines in kernel, some of arguments should be user pointers but were missing __user markup on string literals. Add it. Removes some sparse warnings. Signed-off-by: Namhyung Kim <namhyung@gmail.com> Cc: Phillip Lougher <phillip@lougher.demon.co.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 5 changed files with 11 additions and 10 deletions Side-by-side Diff
init/do_mounts.c
... | ... | @@ -291,7 +291,7 @@ |
291 | 291 | if (err) |
292 | 292 | return err; |
293 | 293 | |
294 | - sys_chdir("/root"); | |
294 | + sys_chdir((const char __user __force *)"/root"); | |
295 | 295 | ROOT_DEV = current->fs->pwd.mnt->mnt_sb->s_dev; |
296 | 296 | printk("VFS: Mounted root (%s filesystem)%s on device %u:%u.\n", |
297 | 297 | current->fs->pwd.mnt->mnt_sb->s_type->name, |
... | ... | @@ -488,6 +488,6 @@ |
488 | 488 | out: |
489 | 489 | devtmpfs_mount("dev"); |
490 | 490 | sys_mount(".", "/", NULL, MS_MOVE, NULL); |
491 | - sys_chroot("."); | |
491 | + sys_chroot((const char __user __force *)"."); | |
492 | 492 | } |
init/do_mounts_md.c
init/do_mounts_rd.c
... | ... | @@ -168,7 +168,7 @@ |
168 | 168 | char rotator[4] = { '|' , '/' , '-' , '\\' }; |
169 | 169 | #endif |
170 | 170 | |
171 | - out_fd = sys_open("/dev/ram", O_RDWR, 0); | |
171 | + out_fd = sys_open((const char __user __force *) "/dev/ram", O_RDWR, 0); | |
172 | 172 | if (out_fd < 0) |
173 | 173 | goto out; |
174 | 174 | |
... | ... | @@ -267,7 +267,7 @@ |
267 | 267 | sys_close(out_fd); |
268 | 268 | out: |
269 | 269 | kfree(buf); |
270 | - sys_unlink("/dev/ram"); | |
270 | + sys_unlink((const char __user __force *) "/dev/ram"); | |
271 | 271 | return res; |
272 | 272 | } |
273 | 273 |
init/initramfs.c
... | ... | @@ -528,7 +528,7 @@ |
528 | 528 | struct linux_dirent64 *dirp; |
529 | 529 | int num; |
530 | 530 | |
531 | - fd = sys_open("/", O_RDONLY, 0); | |
531 | + fd = sys_open((const char __user __force *) "/", O_RDONLY, 0); | |
532 | 532 | WARN_ON(fd < 0); |
533 | 533 | if (fd < 0) |
534 | 534 | return; |
... | ... | @@ -590,7 +590,8 @@ |
590 | 590 | } |
591 | 591 | printk(KERN_INFO "rootfs image is not initramfs (%s)" |
592 | 592 | "; looks like an initrd\n", err); |
593 | - fd = sys_open("/initrd.image", O_WRONLY|O_CREAT, 0700); | |
593 | + fd = sys_open((const char __user __force *) "/initrd.image", | |
594 | + O_WRONLY|O_CREAT, 0700); | |
594 | 595 | if (fd >= 0) { |
595 | 596 | sys_write(fd, (char *)initrd_start, |
596 | 597 | initrd_end - initrd_start); |
init/noinitramfs.c
... | ... | @@ -29,17 +29,17 @@ |
29 | 29 | { |
30 | 30 | int err; |
31 | 31 | |
32 | - err = sys_mkdir("/dev", 0755); | |
32 | + err = sys_mkdir((const char __user __force *) "/dev", 0755); | |
33 | 33 | if (err < 0) |
34 | 34 | goto out; |
35 | 35 | |
36 | - err = sys_mknod((const char __user *) "/dev/console", | |
36 | + err = sys_mknod((const char __user __force *) "/dev/console", | |
37 | 37 | S_IFCHR | S_IRUSR | S_IWUSR, |
38 | 38 | new_encode_dev(MKDEV(5, 1))); |
39 | 39 | if (err < 0) |
40 | 40 | goto out; |
41 | 41 | |
42 | - err = sys_mkdir("/root", 0700); | |
42 | + err = sys_mkdir((const char __user __force *) "/root", 0700); | |
43 | 43 | if (err < 0) |
44 | 44 | goto out; |
45 | 45 |