This changes vn_deallocate() to match the behavior of vn_rdwr() when
picking which ucred to use. That is, vn_deallocate() uses file_cred for
making VOP call if it is non-NULL, or use active_cred otherwise.
Sponsored by: The FreeBSD Foundation
Differential D31712
vfs: Use file_cred for VOP_DEALLOCATE in vn_deallocate if non-NULL khng on Aug 29 2021, 5:00 PM. Authored by Tags None Referenced Files
Subscribers
Details This changes vn_deallocate() to match the behavior of vn_rdwr() when Sponsored by: The FreeBSD Foundation
Diff Detail
Event TimelineComment Actions Why is it correct? fspacectl() is called by usermode, active_cred are current credentials. f_cred AKA file_cred are credentials of the thread that opened the file. So e.g. if root opened a file and passed fd around, fspacectl(fd) would be executed with root credentials. vn_rdwr() is different, it is not called by syscall directly.
Comment Actions
Comment Actions Don't do this either. Right now I see the only place which uses vn_deallocate(), it is md(4). Do you envision any more places which would do that? Comment Actions My change to ctl(4) which translate UNMAP to VOP_DEALLOCATE for file-backed LUNS also calls vn_deallocate().
Comment Actions vn_deallocate_impl takes three kinds of cred so it's the caller to decide which cred to pass to the VOP call. Suggested by kib@.
|