lkml.org 
[lkml]   [2003]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] autofs sparse fixes

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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2009-11-18 23:46    [W:0.025 / U:1.372 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site