Date: Sun, 14 Feb 2021 11:25:33 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 253500] fusefs: F_SETLKW fcntl gets corrupted by kern_fcntl() Message-ID: <bug-253500-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D253500 Bug ID: 253500 Summary: fusefs: F_SETLKW fcntl gets corrupted by kern_fcntl() Product: Base System Version: 12.2-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: jmillikin@gmail.com Created attachment 222425 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D222425&action= =3Dedit quick-n-dirty patch to fix fcntl locking in FUSE There's at least two bugs in fcntl lock handling that get tickled by FUSE: 1. Calls to `fcntl(fd, F_SETLKW, &lock)` are showing up in the FUSE serve= r as a FUSE_SETLK (should be FUSE_SETLKW). 2. fcntl calls to _clear_ a lock, by using F_SETLK with `l_type =3D F_UNL= CK`, never get passed to userspace at all. It looks like both incorrect behaviors are caused by `kern_fcntl()`: * F_SETLKW is handled by a switch-case fallthrough to the F_SETLK path, b= ut the `VOP_ADVLOCK()' call is hardcoded to use `F_SETLK'. * In the nested switch over the lock type, several calls to `VOP_ADVLOCK(= )' are performed using the lock type (e.g. `F_UNLCK') where they should use the fcntl opcode. This causes `fuse_vnop_advlock()' to return EINVAL. Attached is a patch that fixes both issues according to my test suite. I'm = not very familiar with the FreeBSD kernel, so note that this patch might not do= the right thing for other filesystem drivers. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-253500-227>