From 2ffab1838ec5ac6cc0bb7c2103a47e1eb5bb528e Mon Sep 17 00:00:00 2001 From: Andrei Tatar Date: Tue, 20 Jun 2023 13:19:42 +0200 Subject: [PATCH] lib/vfscore: Fix double-lock bug in symlink This change fixes an issue where the lock of the destination parent directory was being taken more than once in the symlink syscall by using the locked variant of namei_last_nofollow. Signed-off-by: Andrei Tatar Reviewed-by: Maria Sfiraiala Approved-by: Razvan Deaconescu Tested-by: Unikraft CI GitHub-Closes: #952 --- lib/vfscore/syscalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vfscore/syscalls.c b/lib/vfscore/syscalls.c index 4b203ccd8..21d2ac6a7 100644 --- a/lib/vfscore/syscalls.c +++ b/lib/vfscore/syscalls.c @@ -908,7 +908,7 @@ sys_symlink(const char *oldpath, const char *newpath) vn_lock(newdirdp->d_vnode); /* newpath should not already exist */ - if (unlikely(namei_last_nofollow(np, newdirdp, &newdp) == 0)) { + if (unlikely(namei_last_nofollow_locked(np, newdirdp, &newdp) == 0)) { drele(newdp); error = EEXIST; goto out_unlock; -- 2.39.5