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 B547D3BE642; Wed, 30 Sep 2026 18:20:23 +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=1790792424; cv=none; b=tkV1N92cTJtCQNZy412J6JqgwAfjp/LqRqHKXs7zXNgVHBx4vtMn17pr5sHf8IF7E7PpIvtrZC76XNca3zHlTLjFM8O5GjjnmFsD1BWhOzZDBzVAssHaNRWH7UEIxLUMguQlOeQdrENHhxuLvVEOqUTm6sgTgkF9OV7fdZ1DBb0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790792424; c=relaxed/simple; bh=gq8RfWTqIwf/RFLZslrQHPz8WCcJRrLq55k3HUBqsvk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rIAOwoWZNP4I3ewEYfUjUeujqRlDGNfxk+uxHbrZ8GLMPQ05CH65dUbTJ7/dhqqvUC31Bl2h1cKQ5HENGMf9No1MnZCeXR00NFd8Ia90HNfGofeJEWqoaGzoCKvxnclNqVNH78UXE1EnkQ2+GO+xEy9kh7K+9Q2N3i9+gs4w//Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CwQdhdwd; 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="CwQdhdwd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BBD11F000FF; Wed, 30 Sep 2026 18:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790792423; bh=UXum8n40GFlgwGpbjdFk1jhtvf5mM/QUWn87xZGkLAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CwQdhdwdjcx4SYoiA4wRTL0Bz1xNfLyPX//NJeDuLNvKHeQOgDGN7Nbd35mvCx1FT miqStSnJhF3Izn82RTaUdPAxNvG/aP1r2IFdiyKKoLaQn0PUKkk57NpYvhPgJpy+9o Miaorkl5JwkwgWvUOqfNFPOXKj+xqb/uvjaa2cMU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pengpeng Hou , David Heidelberg , Sasha Levin Subject: [PATCH 5.15 648/752] nfc: nfcmrvl: validate helper command length before pull Date: Wed, 30 Sep 2026 17:28:38 +0200 Message-ID: <20260930152412.284267746@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152358.131179731@linuxfoundation.org> References: <20260930152358.131179731@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pengpeng Hou [ Upstream commit 686f942332b1667f13f3b8d6a2f50bcfbf42e277 ] The firmware download receive path removes the NCI data header and reads the helper command before validating the remaining packet length. A short frame can therefore reach the data access before the malformed packet is rejected. Validate the complete helper command length before stripping the NCI data header. Fixes: 3194c6870158 ("NFC: nfcmrvl: add firmware download support") Signed-off-by: Pengpeng Hou Link: https://patch.msgid.link/20260715084325.40276-1-pengpeng@iscas.ac.cn Signed-off-by: David Heidelberg Signed-off-by: Sasha Levin --- drivers/nfc/nfcmrvl/fw_dnld.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/nfc/nfcmrvl/fw_dnld.c b/drivers/nfc/nfcmrvl/fw_dnld.c index edac56b01fd13..bb4ed02a618f0 100644 --- a/drivers/nfc/nfcmrvl/fw_dnld.c +++ b/drivers/nfc/nfcmrvl/fw_dnld.c @@ -264,9 +264,14 @@ static int process_state_fw_dnld(struct nfcmrvl_private *priv, * B8..N: payload */ - /* Remove NCI HDR */ - skb_pull(skb, 3); - if (skb->data[0] != HELPER_CMD_PACKET_FORMAT || skb->len != 5) { + if (skb->len != NCI_DATA_HDR_SIZE + 5) { + nfc_err(priv->dev, "bad command"); + return -EINVAL; + } + + /* Remove NCI header */ + skb_pull(skb, NCI_DATA_HDR_SIZE); + if (skb->data[0] != HELPER_CMD_PACKET_FORMAT) { nfc_err(priv->dev, "bad command"); return -EINVAL; } -- 2.53.0