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 0DCD532D42B; Sat, 30 May 2026 16:53:25 +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=1780160007; cv=none; b=hCLBE0MlJ+FXmunm/Yu2zh5yu6rk2h7wqbS7caJg3qXeNx8RKjfM9R8+MrdjrHzmULWv38EBtcspO/ca7i/hgJxwLstRUNPxQc8HthaDVmRu3hufMNUhiETfG5/TaGcBJ35v1ssVdLl6YWHiq5qmSamjDQNg8JaynL9Wv3qiB/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780160007; c=relaxed/simple; bh=xsu/jpr94rgEtIRLXsbmMq+9Om8zj+CxC7kySM9nhDI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rBwJIVwDE+vS+3GoLb9yUo3FGtzus4dEU+ToFKBsx5zRbTBxy7ec04kxrzJh/Jj7dVhfrphVzDrtBhnnJ7MhVCgKJ3buEEDAnVsPYNoyDGloyfqrghxqSRHm5lV6W1A6K0mtcm7VuzCV7DAOGeO9Wq9NKHKPw8l9abqLCl8BeGc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HQ6FptbW; 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="HQ6FptbW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F00C1F00893; Sat, 30 May 2026 16:53:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780160005; bh=a/2QXxnYOgw0enw6Bgpwq9ZJVLh8rKLed8jsCD+ELmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HQ6FptbWCO3InXzsBZK7dVjizVi0t7Njn4HSDxVDSQVFCh9+Czx43K9NWrL1hVEiR hDx1fM/ajew/0b0Q3jGGml5z4Tr7bDojbLhnz4vQEy8vMQprU+bKoQie4DN6NiHmXT YR6Cp5Fm2HnhRSMVXAlDaUNXl3ZifMzLEu34c2/w= 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.1 219/969] RDMA/rxe: Validate pad and ICRC before payload_size() in rxe_rcv Date: Sat, 30 May 2026 17:55:43 +0200 Message-ID: <20260530160306.500435961@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: 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 @@ -322,7 +322,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);