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 06BF3374A16; Wed, 30 Sep 2026 16:41:18 +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=1790786479; cv=none; b=jJ6Y1i6SQXSgdRi1re4v3K40c9/qe8VfJQWCOblwK/fg32llf12UfNfZY8TdiHm8lipKJAR86g3jylITEv+5MHLNQbLcmSauLEw/PWV0rtQb/K7kvZadYBmwZxk6J4RpbJvEHGKlr4iQDh2XtDmTZQ8cndX9Lw1gsfDL8PHmdLc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786479; c=relaxed/simple; bh=VOpL/HUJNBf6edN83xa1rLVLeFU8RQSOBUuQIbJDJwM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i0+ryakkImMCb+R6xUg0CMT8/naZ2RpEvsKUO+pVRclLBA+miNPrMja2GuKLjsWqD5S48BT/FwGPHaquD75sDGKie/NmY6Gh67CCEE4ZVblulyaaQ+uYugQzxoXNHwd6cizrv1C0k/ObrZ+ANJFrGatmV0PyaS0khjEnPeTXu2Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Z0Z6T5eH; 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="Z0Z6T5eH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62CA81F000FF; Wed, 30 Sep 2026 16:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790786477; bh=8AIZn3p5UHBaVliHv2R7eT1dznBQ8yu+fj4v4EuPpGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z0Z6T5eHwnzizaiM1maan0DdXTIBgdxnZUrUYMGaPhtLJE8fcTBxi/+CsNErbxxOG 4MmDJY2Djr8nS9FgXKvqjd45MynwA+yis32WYxeWjaOVLBrp3HBitUm+FXUwpOaQp0 hIXUvamsxJb634H8ZE0q2OM5/rjrdvGWe77V63TU= 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 6.1 874/982] nfc: nfcmrvl: validate helper command length before pull Date: Wed, 30 Sep 2026 17:26:50 +0200 Message-ID: <20260930152435.524923285@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@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: 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 e83f65596a88a..f7191954db4f6 100644 --- a/drivers/nfc/nfcmrvl/fw_dnld.c +++ b/drivers/nfc/nfcmrvl/fw_dnld.c @@ -262,9 +262,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