git: 156745b42d9e - main - fdescfs: allow chown/utime etc on fdescfs fd for underlying files opened with O_PATH
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Jun 2022 19:28:05 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=156745b42d9e6dfa3d9c6dc480db7836683850cf commit 156745b42d9e6dfa3d9c6dc480db7836683850cf Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-06-05 18:49:09 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-06-06 19:27:36 +0000 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 --- sys/fs/fdescfs/fdesc_vnops.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 2fbdcac34583..ae6d60d0fc55 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -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