Skip to content

Commit c67e538

Browse files
H Hartley Sweetentorvalds
H Hartley Sweeten
authored andcommitted
init: disable sparse checking of the mount.o source files
The init/mount.o source files produce a number of sparse warnings of the type: warning: incorrect type in argument 1 (different address spaces) expected char [noderef] <asn:1>*dev_name got char *name This is due to the syscalls expecting some of the arguments to be user pointers but they are being passed as kernel pointers. This is harmless but adds a lot of noise to a sparse build. To limit the noise just disable the sparse checking in the relevant source files, but still display a warning so that the user knows this has been done. Since the sparse checking has been disabled we can also remove the __user __force casts that are scattered thru the source. Signed-off-by: H Hartley Sweeten <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 243f380 commit c67e538

File tree

5 files changed

+57
-8
lines changed

5 files changed

+57
-8
lines changed

init/do_mounts.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*
2+
* Many of the syscalls used in this file expect some of the arguments
3+
* to be __user pointers not __kernel pointers. To limit the sparse
4+
* noise, turn off sparse checking for this file.
5+
*/
6+
#ifdef __CHECKER__
7+
#undef __CHECKER__
8+
#warning "Sparse checking disabled for this file"
9+
#endif
10+
111
#include <linux/module.h>
212
#include <linux/sched.h>
313
#include <linux/ctype.h>
@@ -330,7 +340,7 @@ static int __init do_mount_root(char *name, char *fs, int flags, void *data)
330340
if (err)
331341
return err;
332342

333-
sys_chdir((const char __user __force *)"/root");
343+
sys_chdir("/root");
334344
s = current->fs->pwd.dentry->d_sb;
335345
ROOT_DEV = s->s_dev;
336346
printk(KERN_INFO
@@ -556,5 +566,5 @@ void __init prepare_namespace(void)
556566
out:
557567
devtmpfs_mount("dev");
558568
sys_mount(".", "/", NULL, MS_MOVE, NULL);
559-
sys_chroot((const char __user __force *)".");
569+
sys_chroot(".");
560570
}

init/do_mounts_initrd.c

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*
2+
* Many of the syscalls used in this file expect some of the arguments
3+
* to be __user pointers not __kernel pointers. To limit the sparse
4+
* noise, turn off sparse checking for this file.
5+
*/
6+
#ifdef __CHECKER__
7+
#undef __CHECKER__
8+
#warning "Sparse checking disabled for this file"
9+
#endif
10+
111
#include <linux/unistd.h>
212
#include <linux/kernel.h>
313
#include <linux/fs.h>

init/do_mounts_md.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*
2+
* Many of the syscalls used in this file expect some of the arguments
3+
* to be __user pointers not __kernel pointers. To limit the sparse
4+
* noise, turn off sparse checking for this file.
5+
*/
6+
#ifdef __CHECKER__
7+
#undef __CHECKER__
8+
#warning "Sparse checking disabled for this file"
9+
#endif
10+
111
#include <linux/delay.h>
212
#include <linux/raid/md_u.h>
313
#include <linux/raid/md_p.h>
@@ -283,7 +293,7 @@ static void __init autodetect_raid(void)
283293

284294
wait_for_device_probe();
285295

286-
fd = sys_open((const char __user __force *) "/dev/md0", 0, 0);
296+
fd = sys_open("/dev/md0", 0, 0);
287297
if (fd >= 0) {
288298
sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
289299
sys_close(fd);

init/do_mounts_rd.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*
2+
* Many of the syscalls used in this file expect some of the arguments
3+
* to be __user pointers not __kernel pointers. To limit the sparse
4+
* noise, turn off sparse checking for this file.
5+
*/
6+
#ifdef __CHECKER__
7+
#undef __CHECKER__
8+
#warning "Sparse checking disabled for this file"
9+
#endif
110

211
#include <linux/kernel.h>
312
#include <linux/fs.h>
@@ -181,7 +190,7 @@ int __init rd_load_image(char *from)
181190
char rotator[4] = { '|' , '/' , '-' , '\\' };
182191
#endif
183192

184-
out_fd = sys_open((const char __user __force *) "/dev/ram", O_RDWR, 0);
193+
out_fd = sys_open("/dev/ram", O_RDWR, 0);
185194
if (out_fd < 0)
186195
goto out;
187196

@@ -280,7 +289,7 @@ int __init rd_load_image(char *from)
280289
sys_close(out_fd);
281290
out:
282291
kfree(buf);
283-
sys_unlink((const char __user __force *) "/dev/ram");
292+
sys_unlink("/dev/ram");
284293
return res;
285294
}
286295

init/initramfs.c

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*
2+
* Many of the syscalls used in this file expect some of the arguments
3+
* to be __user pointers not __kernel pointers. To limit the sparse
4+
* noise, turn off sparse checking for this file.
5+
*/
6+
#ifdef __CHECKER__
7+
#undef __CHECKER__
8+
#warning "Sparse checking disabled for this file"
9+
#endif
10+
111
#include <linux/init.h>
212
#include <linux/fs.h>
313
#include <linux/slab.h>
@@ -74,7 +84,7 @@ static void __init free_hash(void)
7484
}
7585
}
7686

77-
static long __init do_utime(char __user *filename, time_t mtime)
87+
static long __init do_utime(char *filename, time_t mtime)
7888
{
7989
struct timespec t[2];
8090

@@ -529,7 +539,7 @@ static void __init clean_rootfs(void)
529539
struct linux_dirent64 *dirp;
530540
int num;
531541

532-
fd = sys_open((const char __user __force *) "/", O_RDONLY, 0);
542+
fd = sys_open("/", O_RDONLY, 0);
533543
WARN_ON(fd < 0);
534544
if (fd < 0)
535545
return;
@@ -589,7 +599,7 @@ static int __init populate_rootfs(void)
589599
}
590600
printk(KERN_INFO "rootfs image is not initramfs (%s)"
591601
"; looks like an initrd\n", err);
592-
fd = sys_open((const char __user __force *) "/initrd.image",
602+
fd = sys_open("/initrd.image",
593603
O_WRONLY|O_CREAT, 0700);
594604
if (fd >= 0) {
595605
sys_write(fd, (char *)initrd_start,

0 commit comments

Comments
 (0)