fdescfs: allow chown/utime etc on fdescfs fd for underlying files opened with O_PATH

Reported and tested by:	dchagin
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D35410
This commit is contained in:
Konstantin Belousov 2022-06-05 21:49:09 +03:00
parent 559de8eedb
commit 156745b42d

View File

@ -492,9 +492,15 @@ fdesc_setattr(struct vop_setattr_args *ap)
/*
* Allow setattr where there is an underlying vnode.
* For O_PATH descriptors, disallow truncate.
*/
error = getvnode(td, fd,
cap_rights_init_one(&rights, CAP_EXTATTR_SET), &fp);
if (vap->va_size != VNOVAL) {
error = getvnode(td, fd,
cap_rights_init_one(&rights, CAP_EXTATTR_SET), &fp);
} else {
error = getvnode_path(td, fd,
cap_rights_init_one(&rights, CAP_EXTATTR_SET), &fp);
}
if (error) {
/*
* getvnode() returns EINVAL if the file descriptor is not