From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387007; b=ncm+C3NaW/6Dflkm4++tXiGqHfYeZD8vnnkdN8o2VX3FSj2CJSArzNjzdMtUH3GY24yd 4Z/LnSExUVB0ONZaZuSzynNV/nSMTzmqKgXQvMFTGiO10SgUceswzAtcJu9iLGhzWOWm3 4VShH1dR5/9SXRM49c0y6ykdOhGnc4OEl+jqy2MPqemsoMbAW41IssOLmUk6N228aHK8w Ale2iqeJcdwEDKap6BOZEbMhhJCNTmEpKqmrZW7fu1/PyWhBwEgoh4dqy9uHtlCHTQ8qD 4CLC7mf13NCnxOvSBMmCNYo0AFGd5JDyPXVv1jRHI/R0fhVTbbykTZJX4/s1aKxNmbA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387007; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=ucreCu+ipgjymvHS0b322aeDeU7tW0ZflKefyq7UXPE=; b=zuXI8Jv/t/YfehZQUmiSyyfl8ULO+e2qmLqIj6f+fYKgTB4gHWGkj21CwFE+IenGvViu n+oQopUtXnj3KbUh9Af27M0PfYLfefixICaUL7TXcF2M6IRvDBdLbcwFbXVatyY64umrc ZJrcKY9B8I2M7Qwt8RNwg4c5eWzHSD778cjeaXdeC9Q3ji5rCcMK5K4vf9ERrxjKJ2T0r ZSK7gUO7U7CFCyA7SX1dO3xpLUB2+DHUA715VPv5zTvMy0PFVFlIMGDcjMUgQRS0NUzQO qIhesfiuYLDg62HDoYDGD2FtEf+aJ7NE2HqMUTXxekFj1CtDcDbicYVORCc9oWmIkhg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=wG59vYDO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3A0B606A322; Fri, 4 Dec 2026 12:23:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=wG59vYDO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EA821F000C2; Fri, 4 Dec 2026 12:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387007; bh=ucreCu+ipgjymvHS0b322aeDeU7tW0ZflKefyq7UXPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wG59vYDOJxcv8gq0yyGXAmShoDCEhXBerfVaGCtfTJq33+neXSEP3RedhM05FZvnU q6KV2WOGEj7olos69uemDtlbsoxkHswNnwlDtiTxwd+EtiODk9wY7ZOp+B/LB8Zwk0 EQ1tpHvWnZF3gSHMvzLkqC0iaCEoSMlVp3GaIzHI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Namjae Jeon , Yifan Zhang , Sasha Levin Subject: [PATCH 6.1 0093/1059] ksmbd: require NUL-terminated EA names Date: Fri, 4 Dec 2026 18:53:44 +0900 Message-ID: <20261204100646.522907632@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yifan Zhang [ Upstream commit e49296d51ccbf2ad0ed0484db1382f1d7217bd6e ] smb2_set_ea() verifies that the byte reserved for the declared EA-name terminator lies inside the request, but it does not verify that the byte is zero. With SMB debug logging enabled, the name is passed to %s and the diagnostic reads beyond the request allocation. KASAN reports: BUG: KASAN: slab-out-of-bounds in string Read of size 1 string vsnprintf _printk smb2_set_ea smb2_set_info Reject an EA entry whose declared terminator byte is nonzero. Return -EBADMSG for the malformed buffer, and map that error to STATUS_EA_LIST_INCONSISTENT for both SET_INFO and CREATE. Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3") Suggested-by: Namjae Jeon Signed-off-by: Yifan Zhang Signed-off-by: Namjae Jeon Signed-off-by: Sasha Levin --- fs/smb/server/smb2pdu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index b00a575cd9fb6..5f9b9deb8b819 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -2446,6 +2446,11 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, if (!eabuf->EaNameLength) goto next; + if (eabuf->name[eabuf->EaNameLength]) { + rc = -EBADMSG; + break; + } + ksmbd_debug(SMB, "name : <%s>, name_len : %u, value_len : %u, next : %u\n", eabuf->name, eabuf->EaNameLength, @@ -3603,6 +3608,8 @@ int smb2_open(struct ksmbd_work *work) if (rc) { if (rc == -EINVAL) rsp->hdr.Status = STATUS_INVALID_PARAMETER; + else if (rc == -EBADMSG) + rsp->hdr.Status = STATUS_EA_LIST_INCONSISTENT; else if (rc == -EOPNOTSUPP) rsp->hdr.Status = STATUS_NOT_SUPPORTED; else if (rc == -EACCES || rc == -ESTALE || rc == -EXDEV) { @@ -6429,6 +6436,8 @@ int smb2_set_info(struct ksmbd_work *work) rsp->hdr.Status = STATUS_ACCESS_DENIED; else if (rc == -EINVAL) rsp->hdr.Status = STATUS_INVALID_PARAMETER; + else if (rc == -EBADMSG) + rsp->hdr.Status = STATUS_EA_LIST_INCONSISTENT; else if (rc == -EMSGSIZE) rsp->hdr.Status = STATUS_INFO_LENGTH_MISMATCH; else if (rc == -ESHARE) -- 2.53.0