From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 EE73D17C220; Fri, 15 May 2026 15:59:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778860777; cv=none; b=il7/sv3tmwmcedmO/cNGHHaWsu8KMpgSkRF7kuBKxd+QCSSq8yXXZhFwtLunX5Rh8kH1rtJpBQqJfykr1oSzU41rQ0JrHj2EKOHAWe2VvV7bAu5pg+M/25bG2gVgB2zvxsnMdk1BcNICcGCs9QRaOz2lpHHbU01o5uy7uYtWRN4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778860777; c=relaxed/simple; bh=VcHPbsDKNuDcsWaAIciI4CX48iQuiflNq4HqdeplSbY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vv1CjiCYA4woG8uolgpyHCh1zUL0tVTJVImtKj8/y0DFZe2Rnm1qdiNUZPtp0v9+YKdYF4/6XLRO9LawBA/g2Y0EbNuDXWUCTziFR/f0IPBFYzfWIZEMzgFfIATP04ZAM9ajlqhT/qHSt5euDmsWQ2SlPZD92ozce8t3Gh8yeD0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oDbh8f0A; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="oDbh8f0A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81A05C2BCB0; Fri, 15 May 2026 15:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778860776; bh=VcHPbsDKNuDcsWaAIciI4CX48iQuiflNq4HqdeplSbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oDbh8f0ATqevMTdgSqE8Hl/xzWmgp30fxbQW7sUFPDvbuHL1gjQpvmarDosEhkzk/ a9M6Pox24u/pbIteLKfj7LEOqGxon61veIzsjelE3RVsifEZr3fTQaVwBOC0uoOxHM jjBF9Um6W/0Fv8iwsyusTKAcRW66H8DF0gDfQNcA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, hkbinbin , Zhu Yanjun , Jason Gunthorpe Subject: [PATCH 6.6 076/474] RDMA/rxe: Validate pad and ICRC before payload_size() in rxe_rcv Date: Fri, 15 May 2026 17:43:05 +0200 Message-ID: <20260515154716.685214197@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154715.053014143@linuxfoundation.org> References: <20260515154715.053014143@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: hkbinbin commit 7244491dab347f648e661da96dc0febadd9daec3 upstream. rxe_rcv() currently checks only that the incoming packet is at least header_size(pkt) bytes long before payload_size() is used. However, payload_size() subtracts both the attacker-controlled BTH pad field and RXE_ICRC_SIZE from pkt->paylen: payload_size = pkt->paylen - offset[RXE_PAYLOAD] - bth_pad(pkt) - RXE_ICRC_SIZE This means a short packet can still make payload_size() underflow even if it includes enough bytes for the fixed headers. Simply requiring header_size(pkt) + RXE_ICRC_SIZE is not sufficient either, because a packet with a forged non-zero BTH pad can still leave payload_size() negative and pass an underflowed value to later receive-path users. Fix this by validating pkt->paylen against the full minimum length required by payload_size(): header_size(pkt) + bth_pad(pkt) + RXE_ICRC_SIZE. Cc: stable@vger.kernel.org Fixes: 8700e3e7c485 ("Soft RoCE driver") Link: https://patch.msgid.link/r/20260401121907.1468366-1-hkbinbinbin@gmail.com Signed-off-by: hkbinbin Reviewed-by: Zhu Yanjun Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/sw/rxe/rxe_recv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/infiniband/sw/rxe/rxe_recv.c +++ b/drivers/infiniband/sw/rxe/rxe_recv.c @@ -330,7 +330,8 @@ void rxe_rcv(struct sk_buff *skb) pkt->qp = NULL; pkt->mask |= rxe_opcode[pkt->opcode].mask; - if (unlikely(skb->len < header_size(pkt))) + if (unlikely(pkt->paylen < header_size(pkt) + bth_pad(pkt) + + RXE_ICRC_SIZE)) goto drop; err = hdr_check(pkt);