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>] [thread-next>] [day] [month] [year] [list]
Message-ID: <bdd6f570-f387-0371-09fb-d7b8c9993e8b@virtuozzo.com>
Date:   Fri, 17 Dec 2021 14:23:59 +0300
From:   Vasily Averin <vvs@...tuozzo.com>
To:     Namjae Jeon <linkinjeon@...nel.org>,
        Sergey Senozhatsky <senozhatsky@...omium.org>,
        Steve French <sfrench@...ba.org>,
        Hyunchul Lee <hyc.lee@...il.com>
Cc:     Bruce Fields <bfields@...hat.com>,
        Jeff Layton <jlayton@...nel.org>, kernel@...nvz.org,
        linux-cifs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] ksmbd: force "fail immediately" flag on fs with its own
 ->lock

Like nfsd and lockd, ksmbd can cause deadlock if the exported
file system does not support asynchronous processing of blocking locks:
if all ksmbd worker threads handles such requests,
they can never finish and the server will not be able to handle
any other incoming requests.

Any filesystem that leaves ->lock NULL will use posix_lock_file(), which
does the right thing. Simplest is just to assume that any filesystem
that defines its own ->lock is not safe to request a blocking lock from.

To work around the problem we need to drop fl->fl_flag FL_SLEEP before
vfs_lock_file() execution, it forces affected functions to avoid blocking.

Signed-off-by: Vasily Averin <vvs@...tuozzo.com>
---
 fs/ksmbd/smb2pdu.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index 121f8e8c70ac..f2225491af02 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -6634,6 +6634,12 @@ static int smb2_set_flock_flags(struct file_lock *flock, int flags)
 {
 	int cmd = -EINVAL;
 
+	if ((flock->fl_file->f_op->lock) &&
+	    ((flags == SMB2_LOCKFLAG_SHARED) ||
+	     (flags == SMB2_LOCKFLAG_EXCLUSIVE))) {
+		ksmbd_debug(SMB, "force fail immediately request\n");
+		flags |= SMB2_LOCKFLAG_FAIL_IMMEDIATELY;
+	}
 	/* Checking for wrong flag combination during lock request*/
 	switch (flags) {
 	case SMB2_LOCKFLAG_SHARED:
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ