diff mbox series

[for-next] RDMA/rxe: Fix packet length checks

Message ID 20230517172242.1806340-1-rpearsonhpe@gmail.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series [for-next] RDMA/rxe: Fix packet length checks | expand

Commit Message

Bob Pearson May 17, 2023, 5:22 p.m. UTC
In rxe_net.c a received packet, from udp or loopback, is passed
to rxe_rcv() in rxe_recv.c as a udp packet. I.e. skb->data is
pointing at the udp header. But rxe_rcv() makes length checks
to verify the packet is long enough to hold the roce headers as
if it were a roce packet. I.e. skb->data pointing at the bth
header. A runt packet would appear to have 8 more bytes than it
actually does which may lead to incorrect behavior.

This patch calls skb_pull() to adjust the skb to point at the
bth header before calling rxe_rcv() which fixes this error.

Fixes: 8700e3e7c485 ("Soft RoCE driver")
Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe_net.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jason Gunthorpe June 1, 2023, 5:33 p.m. UTC | #1
On Wed, May 17, 2023 at 12:22:42PM -0500, Bob Pearson wrote:
> In rxe_net.c a received packet, from udp or loopback, is passed
> to rxe_rcv() in rxe_recv.c as a udp packet. I.e. skb->data is
> pointing at the udp header. But rxe_rcv() makes length checks
> to verify the packet is long enough to hold the roce headers as
> if it were a roce packet. I.e. skb->data pointing at the bth
> header. A runt packet would appear to have 8 more bytes than it
> actually does which may lead to incorrect behavior.
> 
> This patch calls skb_pull() to adjust the skb to point at the
> bth header before calling rxe_rcv() which fixes this error.
> 
> Fixes: 8700e3e7c485 ("Soft RoCE driver")
> Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_net.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Applied to for-rc, thanks

Jason
Bob Pearson June 1, 2023, 5:38 p.m. UTC | #2
On 6/1/23 12:33, Jason Gunthorpe wrote:
> On Wed, May 17, 2023 at 12:22:42PM -0500, Bob Pearson wrote:
>> In rxe_net.c a received packet, from udp or loopback, is passed
>> to rxe_rcv() in rxe_recv.c as a udp packet. I.e. skb->data is
>> pointing at the udp header. But rxe_rcv() makes length checks
>> to verify the packet is long enough to hold the roce headers as
>> if it were a roce packet. I.e. skb->data pointing at the bth
>> header. A runt packet would appear to have 8 more bytes than it
>> actually does which may lead to incorrect behavior.
>>
>> This patch calls skb_pull() to adjust the skb to point at the
>> bth header before calling rxe_rcv() which fixes this error.
>>
>> Fixes: 8700e3e7c485 ("Soft RoCE driver")
>> Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
>> ---
>>  drivers/infiniband/sw/rxe/rxe_net.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
> 
> Applied to for-rc, thanks
> 
> Jason
thanks
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
index 2bc7361152ea..26b90b8607ef 100644
--- a/drivers/infiniband/sw/rxe/rxe_net.c
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -159,6 +159,9 @@  static int rxe_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
 	pkt->mask = RXE_GRH_MASK;
 	pkt->paylen = be16_to_cpu(udph->len) - sizeof(*udph);
 
+	/* remove udp header */
+	skb_pull(skb, sizeof(struct udphdr));
+
 	rxe_rcv(skb);
 
 	return 0;
@@ -401,6 +404,9 @@  static int rxe_loopback(struct sk_buff *skb, struct rxe_pkt_info *pkt)
 		return -EIO;
 	}
 
+	/* remove udp header */
+	skb_pull(skb, sizeof(struct udphdr));
+
 	rxe_rcv(skb);
 
 	return 0;