]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb/server: fix potential null-ptr-deref of lease_ctx_info in smb2_open()
authorChenXiaoSong <chenxiaosong@kylinos.cn>
Thu, 22 Aug 2024 08:20:51 +0000 (08:20 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:44:03 +0000 (10:44 +0200)
commit 4e8771a3666c8f216eefd6bd2fd50121c6c437db upstream.

null-ptr-deref will occur when (req_op_level == SMB2_OPLOCK_LEVEL_LEASE)
and parse_lease_state() return NULL.

Fix this by check if 'lease_ctx_info' is NULL.

Additionally, remove the redundant parentheses in
parse_durable_handle_context().

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: Steve French <stfrench@microsoft.com>
[ Drop the parentheses clean-up since the parentheses was introduced by
  c8efcc786146 ("ksmbd: add support for durable handles v1/v2") in v6.9
  Minor context change fixed ]
Signed-off-by: Jianqi Ren <jianqi.ren.cn@windriver.com>
Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/server/oplock.c
fs/smb/server/smb2pdu.c

index a3c016a11e2715702f95fe71f98d8651d79d9147..2fcfabc35b06beaa50f290397ded234bb61849de 100644 (file)
@@ -1515,7 +1515,7 @@ void create_lease_buf(u8 *rbuf, struct lease *lease)
  * @open_req:  buffer containing smb2 file open(create) request
  * @is_dir:    whether leasing file is directory
  *
- * Return:  oplock state, -ENOENT if create lease context not found
+ * Return: allocated lease context object on success, otherwise NULL
  */
 struct lease_ctx_info *parse_lease_state(void *open_req, bool is_dir)
 {
index c0e159592655a0050c15df0e10bb76ec8628e262..8c9857b36addb81c0949cc0da13602391765a5b7 100644 (file)
@@ -3243,7 +3243,7 @@ int smb2_open(struct ksmbd_work *work)
                        goto err_out1;
                }
        } else {
-               if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE) {
+               if (req_op_level == SMB2_OPLOCK_LEVEL_LEASE && lc) {
                        /*
                         * Compare parent lease using parent key. If there is no
                         * a lease that has same parent key, Send lease break