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/>
index | next in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253500 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=222425&action=edit 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 server as a FUSE_SETLK (should be FUSE_SETLKW). 2. fcntl calls to _clear_ a lock, by using F_SETLK with `l_type = F_UNLCK`, 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, but 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. -- You are receiving this mail because: You are the assignee for the bug.help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-253500-227>
