From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 314A81DE4EF; Sat, 30 May 2026 16:38:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780159086; cv=none; b=IpG41UFMFfYYPAjdcGw566GTbefs+ILHW/CHpUpWxoC7MAPb5lm1p+X3TTkzW9BI6KjGq79ETpl1wWKYqvi38dfziA1exKan8B9JbBO1QGKjLHEqmMfzpeM5fK1MRPOQh/fO9l/IZ5RfFZjSTl70+qNWauSshSmRKxy4dd69e40= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780159086; c=relaxed/simple; bh=bxdxVJhNOQH5YGXn/QnSxTM4XIW//9QDH98rs9etwEg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r6LWHsW5FMtPqtljnu8wmDV9Bsg7512pZVa0LiNug/hlaOc83a59g38eUXJsSrRGQUqHAR4EYvPDCK9XwJ6QwWOjPHOD1wsbfjxKrz4ZzmrEbzUSjUo6iVulvwvfPE39UJl+lvrm1J4ZFObjJtXSYNi80+d71L90p8SUHs9Dfkg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JYUxNnV3; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="JYUxNnV3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 862DD1F00893; Sat, 30 May 2026 16:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780159084; bh=ke9M0qJ+lRZMS+YELa5ZnoFoIoNp2jlUXrm8XrY8WrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JYUxNnV3pQX9RmW9rkoUVbeVm+hZM/+2gjud431M+XRK7Iu0PKBgUW7iuzkpjfG7E sb6XdmaROUzfjo5HbT+UxZjCYCMFnhxKpzFfnHRuZLMej7K8P3pzRauZ2Zf+zq6Ozv 8JkjxPaP4EVHC6bn/oJkbrRwSUukpWdzCikva4YE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Namjae Jeon , Steve French , Sergey Senozhatsky , Tom Talpey , linux-cifs@vger.kernel.org, stable@kernel.org, Steve French Subject: [PATCH 6.1 070/969] ksmbd: validate EaNameLength in smb2_get_ea() Date: Sat, 30 May 2026 17:53:14 +0200 Message-ID: <20260530160302.301811276@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Greg Kroah-Hartman commit 66751841212c2cc196577453c37f7774ff363f02 upstream. smb2_get_ea() reads ea_req->EaNameLength from the client request and passes it directly to strncmp() as the comparison length without verifying that the length of the name really is the size of the input buffer received. Fix this up by properly checking the size of the name based on the value received and the overall size of the request, to prevent a later strncmp() call to use the length as a "trusted" size of the buffer. Without this check, uninitialized heap values might be slowly leaked to the client. Cc: Namjae Jeon Cc: Steve French Cc: Sergey Senozhatsky Cc: Tom Talpey Cc: linux-cifs@vger.kernel.org Cc: Assisted-by: gregkh_clanker_t1000 Signed-off-by: Greg Kroah-Hartman Acked-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/smb/server/smb2pdu.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -4390,6 +4390,11 @@ static int smb2_get_ea(struct ksmbd_work ea_req = (struct smb2_ea_info_req *)((char *)req + le16_to_cpu(req->InputBufferOffset)); + + if (le32_to_cpu(req->InputBufferLength) < + offsetof(struct smb2_ea_info_req, name) + + ea_req->EaNameLength) + return -EINVAL; } else { /* need to send all EAs, if no specific EA is requested*/ if (le32_to_cpu(req->Flags) & SL_RETURN_SINGLE_ENTRY)