git: rename(2): Fix permission check on cross-parent directory rename

Aaron LI aly at crater.dragonflybsd.org
Tue Nov 17 01:30:56 PST 2026


commit e20053b145eb412de06cef1e65e71579c44fb55b
Author: Aaron LI <aly at aaronly.me>
Date:   Sat Nov 7 21:30:33 2026 +0800

    rename(2): Fix permission check on cross-parent directory rename
    
    Cross-parent directory rename did not require write permission on the
    source directory, although its ".." entry is modified. POSIX requires
    EACCES there. UFS already performs this check, but HAMMER2 and tmpfs
    don't. Fix the bug by adding a generic check in kern_rename().
    
    To reproduce the bug:
    ```
    $ d=$(mktemp -d)
    $ mkdir -p ${d}/p1/dir1 ${d}/p2
    $ touch ${d}/p1/dir1/file1
    $ chmod 0444 ${d}/p1/dir1
    $ mv ${d}/p1/dir1 ${d}/p2
    ```
    
    Before the fix, the last "mv" command succeeded; after the fix, it would
    fail with "Permission denied" (EACCES).
    
    Found-by: pjdfstest (https://github.com/pjd/pjdfstest)
    Assisted-by: DeepSeek-v4.1-flash (with Pi Coding Agent)

Summary of changes:
 sys/kern/vfs_syscalls.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/e20053b145eb412de06cef1e65e71579c44fb55b


-- 
DragonFly BSD source repository


More information about the Commits mailing list