]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/vfscore: Fix double-lock bug in symlink
authorAndrei Tatar <andrei@unikraft.io>
Tue, 20 Jun 2023 11:19:42 +0000 (13:19 +0200)
committerUnikraft <monkey@unikraft.io>
Mon, 7 Aug 2023 17:55:21 +0000 (17:55 +0000)
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 <andrei@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #952

lib/vfscore/syscalls.c

index 4b203ccd8e83e8dc46b6bd677cd2c708b368df28..21d2ac6a760deef805cc2f52c0b9de6476222494 100644 (file)
@@ -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;