aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2023-02-12 23:20:25 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2023-02-13 23:16:38 +0000
commit3a3450eda6d4616df51a30f84a872d9d43669d78 (patch)
tree74b0af59cbd23cf70de65941685ba6f0b1386b65
parentadc3506d56d76981a0e251080b186c26edb843b4 (diff)
downloadsrc-3a3450eda6d4616df51a30f84a872d9d43669d78.tar.gz
src-3a3450eda6d4616df51a30f84a872d9d43669d78.zip
tmpfs_rename(): use tmpfs_access_locked instead of VOP_ACCESS()
Protect the call with the node lock. We cannot lock the fvp vnode sleepable there, because we already own other participating vnode's locks. Taking it without sleeping require unwinding the whole locking state in one more place. Note that the liveness of the node is guaranteed by the lock on the parent directory vnode. Reported and tested by: pho Fixes: cbac1f3464956185cf95955344b6009e2cc3ae40ESC Reviewed by: markj, mjg Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D38557
-rw-r--r--sys/fs/tmpfs/tmpfs_vnops.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c
index cd460636b647..b1d6bce6754f 100644
--- a/sys/fs/tmpfs/tmpfs_vnops.c
+++ b/sys/fs/tmpfs/tmpfs_vnops.c
@@ -1129,7 +1129,10 @@ tmpfs_rename(struct vop_rename_args *v)
if (de->td_node->tn_type == VDIR) {
struct tmpfs_node *n;
- error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, curthread);
+ TMPFS_NODE_LOCK(fnode);
+ error = tmpfs_access_locked(fvp, fnode, VWRITE,
+ tcnp->cn_cred);
+ TMPFS_NODE_UNLOCK(fnode);
if (error) {
if (newname != NULL)
free(newname, M_TMPFSNAME);