Skip to contentSkip to conversation

smb: client: reject oversized SMB1 SET_SECURITY_DESC data

PATCH New Abdifatah Suruur 1 participant 1 message Nov 18

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smb: client: reject oversized SMB1 SET_SECURITY_DESC data

CIFSSMBSetCIFSACL() copies acllen bytes into the single cifs_buf_get() request buffer at data_offset without checking that the data fits. The buffer is CIFSMaxBufSize + MAX_SMB2_HDR_SIZE bytes, while acllen comes from the rewritten security descriptor produced by id_mode_to_cifs_acl(). A malicious server can return a descriptor whose rewritten ACL is larger than the buffer, so a chmod()/chown() on a cifsacl mount over SMB1 writes past the cifs_request object.

Reject data that cannot fit before the memcpy(), as the SMB2 path now does.

This is the legacy SMB1 counterpart of the SMB2_set_info_init() bound
check: both paths copy a rewritten security descriptor into a cifs_buf_get() request object without a size limit.

Fixes f5065508897a ("cifs: Retain old ACEs when converting between mode bits and ACL.")

---

fs/smb/client/cifssmb.c +6 -0
index 2936b38de98f9..a5d02ed85877f 100644
@@ -3961,6 +3961,12 @@ CIFSSMBSetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon, __u16 fid,
 	data_offset = param_offset + param_count;
 	byte_count = 3 /* pad */  + param_count;
 
+	/* The single request buffer must hold the ACL after data_offset. */
+	if (acllen > CIFSMaxBufSize + MAX_SMB2_HDR_SIZE - data_offset) {
+		cifs_buf_release(pSMB);
+		return -EINVAL;
+	}
+
 	pSMB->DataCount = cpu_to_le32(data_count);
 	pSMB->TotalDataCount = pSMB->DataCount;
 	pSMB->MaxParameterCount = cpu_to_le32(4);