[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-kernel
Subject:    Re: [PATCH] autofs sparse fixes
From:       Linus Torvalds <torvalds () osdl ! org>
Date:       2003-09-30 23:54:50
[Download RAW message or body]


On Mon, 29 Sep 2003 Andries.Brouwer@cwi.nl wrote:
> 
> I think I prefer two rights above two wrongs - the declaration
> already gives addr the right type - it really does point to kernel space -
> but we inherit an incorrect type for file->f_op->write, so have to cast
> that.

No, the type for file->f_op->write is of the _rigth_ type.

It literally _does_ get the data from user space.

The thing is, what "set_fs(KERNEL_DS)" does is to say "kernel space is now 
user space". So the _caller_ will have made user space and kernel space be 
the same mapping, exactly so that the write will do the right thing.

[ Yeah, we long since renamed all the "get_fs_byte()" calls to a much more
  natural "get_user()" macro, and the "set_fs()" thing should be renamed
  too. It obviously makes no sense any more, since we don't use the '%fs'
  segment register even on x86 these days, and on other architectures it
  never made any sense in the first place. ]

So as a result of the "set_fs()" the kernel pointer literally _becomes_ a 
user-pointer. That's what set_fs() is all about. And that's why it is 
correct to cast the pointer - but not the function. The function still 
takes a user pointer.

			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/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic