Skip to contentSkip to conversation

ksmbd: fix uninitialized pointer read in ksmbd_vfs_rename()

PATCH New Namjae Jeon 1 participant 3 messages May 14, 2023

Subsystems (2)
lore
Share & tools
lore

Namjae Jeon

author maintainer
#0 lore raw

PATCH 1/1 ksmbd: fix uninitialized pointer read in ksmbd_vfs_rename()

Uninitialized rd.delegated_inode can be used in vfs_rename(). Fix this by setting rd.delegated_inode to NULL to avoid the uninitialized read.

---
 fs/ksmbd/vfs.c | 1 +
 1 file changed, 1 insertion(+)
fs/ksmbd/vfs.c +1 -0
index 778c152708e4..9bdb01c5b201 100644
@@ -743,6 +743,7 @@ int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,
 	rd.new_dir		= new_path.dentry->d_inode,
 	rd.new_dentry		= new_dentry,
 	rd.flags		= flags,
+	rd.delegated_inode	= NULL,
 	err = vfs_rename(&rd);
 	if (err)
 		ksmbd_debug(VFS, "vfs_rename failed err %d\n", err);
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH 1/1 ksmbd: fix uninitialized pointer read in smb2_create_link()

There is a case that file_present is true and path is uninitialized. This patch change file_present is set to false by default and set to true when patch is initialized.

---
 fs/ksmbd/smb2pdu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ksmbd/smb2pdu.c +3 -3
index 717bcd20545b..1632b2a1e516 100644
@@ -5506,7 +5506,7 @@ static int smb2_create_link(struct ksmbd_work *work,
 {
 	char *link_name = NULL, *target_name = NULL, *pathname = NULL;
 	struct path path;
-	bool file_present = true;
+	bool file_present = false;
 	int rc;
 
 	if (buf_len < (u64)sizeof(struct smb2_file_link_info) +
@@ -5539,8 +5539,8 @@ static int smb2_create_link(struct ksmbd_work *work,
 	if (rc) {
 		if (rc != -ENOENT)
 			goto out;
-		file_present = false;
-	}
+	} else
+		file_present = true;
 
 	if (file_info->ReplaceIfExists) {
 		if (file_present) {
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

PATCH 1/1 ksmbd: fix credit count leakage

In reply to Namjae Jeon

This patch fix the failure from smb2.credits.single_req_credits_granted test. When client send 8192 credit request, ksmbd return 8191 credit granted. ksmbd should give maximum possible credits that must be granted within the range of not exceeding the max credit to client.

---
 fs/ksmbd/smb2pdu.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
fs/ksmbd/smb2pdu.c +1 -5
index 1632b2a1e516..bec885c007ce 100644
@@ -326,13 +326,9 @@ int smb2_set_rsp_credits(struct ksmbd_work *work)
 	if (hdr->Command == SMB2_NEGOTIATE)
 		aux_max = 1;
 	else
-		aux_max = conn->vals->max_credits - credit_charge;
+		aux_max = conn->vals->max_credits - conn->total_credits;
 	credits_granted = min_t(unsigned short, credits_requested, aux_max);
 
-	if (conn->vals->max_credits - conn->total_credits < credits_granted)
-		credits_granted = conn->vals->max_credits -
-			conn->total_credits;
-
 	conn->total_credits += credits_granted;
 	work->credits_granted += credits_granted;
 
Signature · 1 line
2.25.1