From fe546ffacd0418a5a145be54d7d2ee1e16e65b41 Mon Sep 17 00:00:00 2001 From: Sandy Xu Date: Thu, 30 May 2024 20:07:25 +0800 Subject: [PATCH] vfs: fix the issue that plock may be unlocked by mistake (#4910) --- pkg/vfs/vfs.go | 2 +- pkg/vfs/vfs_unix.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/vfs/vfs.go b/pkg/vfs/vfs.go index fabbe869ad63..7adf706d07f0 100644 --- a/pkg/vfs/vfs.go +++ b/pkg/vfs/vfs.go @@ -564,7 +564,7 @@ func (v *VFS) Release(ctx Context, ino Ino, fh uint64) { v.invalidateAttr(ino) } if locks&1 != 0 { - _ = v.Meta.Flock(ctx, ino, owner, F_UNLCK, false) + _ = v.Meta.Flock(ctx, ino, owner^fh, F_UNLCK, false) } } _ = v.Meta.Close(ctx, ino) diff --git a/pkg/vfs/vfs_unix.go b/pkg/vfs/vfs_unix.go index 701d3e57099d..f2b58e5e0189 100644 --- a/pkg/vfs/vfs_unix.go +++ b/pkg/vfs/vfs_unix.go @@ -292,7 +292,7 @@ func (v *VFS) Flock(ctx Context, ino Ino, fh uint64, owner uint64, typ uint32, b } h.addOp(ctx) defer h.removeOp(ctx) - err = v.Meta.Flock(ctx, ino, owner, typ, block) + err = v.Meta.Flock(ctx, ino, owner^fh, typ, block) if err == 0 { h.Lock() if typ == syscall.F_UNLCK {