Chinaunix

标题: filp_open不需要set_fs么 [打印本页]

作者: mordorwww    时间: 2013-10-29 13:36
标题: filp_open不需要set_fs么
看到网上的例子和别人写的代码都没有,只是把read write给set_fs了

但是看内核里的一些驱动源码, filp_open也是放在set_fs里的
作者: 瀚海书香    时间: 2013-10-29 15:55
回复 1# mordorwww
看到网上的例子和别人写的代码都没有,只是把read write给set_fs了

但是看内核里的一些驱动源码, filp_open也是放在set_fs里的


You should know the meaning of set_fs():

          The value of the addr_limit.seg field can be dynamically changed by the get_fs and set_fs macros; this allows the kernel to bypass the security checks made by               access_ok( ), so that it can invoke system call service routines, directly passing to them addresses in the kernel data segment.

So, if you want to directly  call filp_open in kernel space, set_fs will be needed!
   




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2