Skip to content

Commit 562f5e6

Browse files
namhyungtorvalds
authored andcommitted
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 <[email protected]> Cc: Phillip Lougher <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent f0cfec1 commit 562f5e6

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

init/do_mounts.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ static int __init do_mount_root(char *name, char *fs, int flags, void *data)
291291
if (err)
292292
return err;
293293

294-
sys_chdir("/root");
294+
sys_chdir((const char __user __force *)"/root");
295295
ROOT_DEV = current->fs->pwd.mnt->mnt_sb->s_dev;
296296
printk("VFS: Mounted root (%s filesystem)%s on device %u:%u.\n",
297297
current->fs->pwd.mnt->mnt_sb->s_type->name,
@@ -488,5 +488,5 @@ void __init prepare_namespace(void)
488488
out:
489489
devtmpfs_mount("dev");
490490
sys_mount(".", "/", NULL, MS_MOVE, NULL);
491-
sys_chroot(".");
491+
sys_chroot((const char __user __force *)".");
492492
}

init/do_mounts_md.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static void __init autodetect_raid(void)
283283

284284
wait_for_device_probe();
285285

286-
fd = sys_open("/dev/md0", 0, 0);
286+
fd = sys_open((const char __user __force *) "/dev/md0", 0, 0);
287287
if (fd >= 0) {
288288
sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
289289
sys_close(fd);

init/do_mounts_rd.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ int __init rd_load_image(char *from)
168168
char rotator[4] = { '|' , '/' , '-' , '\\' };
169169
#endif
170170

171-
out_fd = sys_open("/dev/ram", O_RDWR, 0);
171+
out_fd = sys_open((const char __user __force *) "/dev/ram", O_RDWR, 0);
172172
if (out_fd < 0)
173173
goto out;
174174

@@ -267,7 +267,7 @@ int __init rd_load_image(char *from)
267267
sys_close(out_fd);
268268
out:
269269
kfree(buf);
270-
sys_unlink("/dev/ram");
270+
sys_unlink((const char __user __force *) "/dev/ram");
271271
return res;
272272
}
273273

init/initramfs.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ static void __init clean_rootfs(void)
528528
struct linux_dirent64 *dirp;
529529
int num;
530530

531-
fd = sys_open("/", O_RDONLY, 0);
531+
fd = sys_open((const char __user __force *) "/", O_RDONLY, 0);
532532
WARN_ON(fd < 0);
533533
if (fd < 0)
534534
return;
@@ -590,7 +590,8 @@ static int __init populate_rootfs(void)
590590
}
591591
printk(KERN_INFO "rootfs image is not initramfs (%s)"
592592
"; 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);
594595
if (fd >= 0) {
595596
sys_write(fd, (char *)initrd_start,
596597
initrd_end - initrd_start);

init/noinitramfs.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ static int __init default_rootfs(void)
2929
{
3030
int err;
3131

32-
err = sys_mkdir("/dev", 0755);
32+
err = sys_mkdir((const char __user __force *) "/dev", 0755);
3333
if (err < 0)
3434
goto out;
3535

36-
err = sys_mknod((const char __user *) "/dev/console",
36+
err = sys_mknod((const char __user __force *) "/dev/console",
3737
S_IFCHR | S_IRUSR | S_IWUSR,
3838
new_encode_dev(MKDEV(5, 1)));
3939
if (err < 0)
4040
goto out;
4141

42-
err = sys_mkdir("/root", 0700);
42+
err = sys_mkdir((const char __user __force *) "/root", 0700);
4343
if (err < 0)
4444
goto out;
4545

0 commit comments

Comments
 (0)