git: 9ad2d4c4907d - main - Fix pjfstest issue tests/rename/19.t
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 29 Jan 2023 08:19:30 UTC
The branch main has been updated by fsu: URL: https://cgit.FreeBSD.org/src/commit/?id=9ad2d4c4907da9c9edd4826219f6fa08544d31c4 commit 9ad2d4c4907da9c9edd4826219f6fa08544d31c4 Author: Fedor Uporov <fsu@FreeBSD.org> AuthorDate: 2023-01-26 10:17:48 +0000 Commit: Fedor Uporov <fsu@FreeBSD.org> CommitDate: 2023-01-29 08:11:23 +0000 Fix pjfstest issue tests/rename/19.t The rename call with args like: "./dir0/dir1/.." "./dir2" will cause MPASS failure. The tmpfs_dir_lookup() does not accept names like '.' and '..' for lookup. Move the '.' and '..' entry check before tmpfs_dir_lookup() call. Reviewed by: kib MFC after: 2 week Differential revision: https://reviews.freebsd.org/D38051 --- sys/fs/tmpfs/tmpfs_vnops.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 1e3a4ac68f3f..da934338948b 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -1029,6 +1029,15 @@ tmpfs_rename(struct vop_rename_args *v) } } + /* + * Avoid manipulating '.' and '..' entries. + */ + if ((fcnp->cn_flags & ISDOTDOT) != 0 || + (fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.')) { + error = EINVAL; + goto out_locked; + } + if (tvp != NULL) vn_seqc_write_begin(tvp); vn_seqc_write_begin(tdvp); @@ -1044,8 +1053,7 @@ tmpfs_rename(struct vop_rename_args *v) de = tmpfs_dir_lookup(fdnode, fnode, fcnp); /* - * Entry can disappear before we lock fdvp, - * also avoid manipulating '.' and '..' entries. + * Entry can disappear before we lock fdvp. */ if (de == NULL) { if ((fcnp->cn_flags & ISDOTDOT) != 0 ||