> : > As my understanding (by reading "LINUX Kernel Internals"), whenever
> : > we call put_user, get_user, memcpy_tofs or memcpy_fromfs, we should call
> : > verify_area() first to make sure we can read/write data from/to user
> : > space. But looking at the source code of linux/drivers/char/mem.c, we
> : > can't find verify_area() there (2.0.27) which should be NECESSARY as
> : > "LINUX Kernel Internals" said. So ...? Do I loss some important stuff?
> : > Need comments and Thanks.
> : The verify_area() is already done by higher VFS layers (see
> : fs/read_write.c:sys_read and sys_write)
> : -Andi
> Hi Andi,
> Yes, you are right. The verify_area() is done in syscall layer or
> as you said, higher VFS layer. Since all the user programs should access
> device driver through syscall interface, looks like we can safely remove
> all verify_area() from device driver code. Is this statement correct?
> There are a lot of verify_area() used in device drivers ... why do this
> kind of check twice? Anyway, thanks.
It is not checked in all cases, e.g. for ioctls the driver is generally
responsible for checking it (because there are far too many and too diverse
ioctls to do it generally). In 2.1 most of the work of verify_area() has
been moved into the exception handler anyways, because the 2.0 way of
verify_area involves races with threads that use munmap() (and with SMP,
although that isn't an issue in 2.0 because of the global kernel lock).