Re: kernel vs user file name by Skywing
Skywing
Thu Mar 09 13:05:26 CST 2006
It depends on how (and when) you open the file in the driver whether the
user would be able to do this - but making the user supply the file handle
makes sure that in all cases the driver cannot be tricked into doing
something "bad" by a nonprivileged user.
If you needed to convert the handle to a PFILE_OBJECT for what you are doing
with it in kernel mode (i.e. instead of using the ZwXxxFile APIs with the
handle) you could use ObReferenceObjectByHandle(UserHandle, RequiredAccess,
*IoFileObjectType, UserMode, (PVOID*)&FileObject, 0), where RequiredAccess
is the access that you need the file handle to provide.
<r_konjeti@mailcity.com> wrote in message
news:1141916319.923380.311010@e56g2000cwe.googlegroups.com...
> Can you explain why handle is more secure than file name. Is it becoz,
> for example, user who has no permission to write to a file cannot get a
> file handle with write permission? So he cannot make driver do what he
> is not allowed to do?
>
> Thanks,
> Raj
>