Re: [PATCH] autofs sparse fixes

From: Linus Torvalds
Date: Mon Sep 29 2003 - 11:46:36 EST



For cases like this, where we use a kernel pointer and do the
"set_fs(KERNEL_DS)" thing to mak ea user-pointer routing write to kernel
space, I suggest casting the pointer instead of the function, along with a
comment on the "set_fs()".

Basically, something like this instead:

static int autofs_write(struct file *file, const void *addr, int bytes)
{
const void __user *data;
...

set_fs(KERNEL_DS);
/* This cast is legal due to the set_fs()! */
data = (const void __user *) addr;

...->write(file, data, bytes);
set_fs(old_fs);
}

See? That makes the cast more obvious, and it also makes it obvious _why_
the cast from kernel->user pointer is ok in this case.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/