[Bug 266885] [FUSEFS] fcntl(F_GETLK) overwrites flock->l_pid even if unlocked

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 07 Oct 2022 10:18:13 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266885

            Bug ID: 266885
           Summary: [FUSEFS] fcntl(F_GETLK) overwrites flock->l_pid even
                    if unlocked
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: jmillikin@gmail.com

The documentation for fcntl(F_GETLK) says:

  If no lock is found that would prevent this lock from being created,
  the structure is left unchanged by this system call except for
  the lock type which is set to F_UNLCK.

However, the code is currently overwriting the flock structure's `l_pid` field:

        /* sys/fs/fuse/fuse_vnops.c :: fuse_vnop_advlock() */
        if (err == 0 && op == FUSE_GETLK) {
                flo = fdi.answ;
                fl->l_type = flo->lk.type;
                fl->l_pid = flo->lk.pid;            /* <- here */
                if (flo->lk.type != F_UNLCK) {
                        fl->l_start = flo->lk.start;

I think that assignment should be moved down a line, into the `!= F_UNLCK`
branch.

-- 
You are receiving this mail because:
You are the assignee for the bug.