lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Thu, 23 Dec 2021 21:00:28 +0300
From:   Vasily Averin <vvs@...tuozzo.com>
To:     Steve French <sfrench@...ba.org>
Cc:     kernel@...nvz.org, linux-cifs@...r.kernel.org,
        samba-technical@...ts.samba.org, linux-kernel@...r.kernel.org
Subject: [PATCH] cifs: handle async processing of F_SETLK with FL_SLEEP flag

kernel export thread (nfsd/lockd/ksmbd) uses F_SETLK cmd with the
FL_SLEEP flag set to request asynchronous processing of blocking locks.

Currently cifs does not support such requests, it ignores F_SETLK cmd
and handles the FL_SLEEP flag as an usual blocking lock request.

To work around the problem let's detect such request, drop FL_SLEEP and
wait_flag flags before cifs_setlk() execution.

Dropped FL_SLEEP flag should be restored back because some calling function
(nfsd4_lock) require it.

https://bugzilla.kernel.org/show_bug.cgi?id=215383
Signed-off-by: Vasily Averin <vvs@...tuozzo.com>
---
 fs/cifs/file.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 9fee3af83a73..6835458ee845 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1847,6 +1847,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock)
 	int lock = 0, unlock = 0;
 	bool wait_flag = false;
 	bool posix_lck = false;
+	bool async = false;
 	struct cifs_sb_info *cifs_sb;
 	struct cifs_tcon *tcon;
 	struct cifsFileInfo *cfile;
@@ -1890,8 +1891,17 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock)
 		return -EOPNOTSUPP;
 	}
 
+	async = (flock->fl_flags & FL_SLEEP) && IS_SETLK(cmd);
+	if (async) {
+		flock->fl_flags &= ~FL_SLEEP;
+		wait_flag = false;
+	}
+
 	rc = cifs_setlk(file, flock, type, wait_flag, posix_lck, lock, unlock,
 			xid);
+	if (async)
+		flock->fl_flags |= FL_SLEEP;
+
 	free_xid(xid);
 	return rc;
 }
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ