linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] um: vector: fix return value check in vector_mmsg_rx
@ 2023-10-07  0:51 Ma Ke
  2023-10-07  6:12 ` Anton Ivanov
  2023-10-09  7:31 ` Johannes Berg
  0 siblings, 2 replies; 3+ messages in thread
From: Ma Ke @ 2023-10-07  0:51 UTC (permalink / raw)
  To: richard, anton.ivanov, johannes, xiangyang3, make_ruc2021
  Cc: linux-um, linux-kernel

In vector_mmsg_rx, to avoid an unexpected result returned by
pskb_trim, we should check the return value of pskb_trim().

Signed-off-by: Ma Ke <make_ruc2021@163.com>
---
 arch/um/drivers/vector_kern.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 131b7cb29576..c280ce5ea6ce 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -1013,8 +1013,8 @@ static int vector_mmsg_rx(struct vector_private *vp, int budget)
 					skb->ip_summed = CHECKSUM_UNNECESSARY;
 				}
 			}
-			pskb_trim(skb,
-				mmsg_vector->msg_len - vp->rx_header_size);
+			if (pskb_trim(skb, mmsg_vector->msg_len - vp->rx_header_size))
+				return 0;
 			skb->protocol = eth_type_trans(skb, skb->dev);
 			/*
 			 * We do not need to lock on updating stats here
-- 
2.37.2


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] um: vector: fix return value check in vector_mmsg_rx
  2023-10-07  0:51 [PATCH] um: vector: fix return value check in vector_mmsg_rx Ma Ke
@ 2023-10-07  6:12 ` Anton Ivanov
  2023-10-09  7:31 ` Johannes Berg
  1 sibling, 0 replies; 3+ messages in thread
From: Anton Ivanov @ 2023-10-07  6:12 UTC (permalink / raw)
  To: Ma Ke, richard, johannes, xiangyang3; +Cc: linux-um, linux-kernel

On 07/10/2023 01:51, Ma Ke wrote:
> In vector_mmsg_rx, to avoid an unexpected result returned by
> pskb_trim, we should check the return value of pskb_trim().
> 
> Signed-off-by: Ma Ke <make_ruc2021@163.com>
> ---
>   arch/um/drivers/vector_kern.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 131b7cb29576..c280ce5ea6ce 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -1013,8 +1013,8 @@ static int vector_mmsg_rx(struct vector_private *vp, int budget)
>   					skb->ip_summed = CHECKSUM_UNNECESSARY;
>   				}
>   			}
> -			pskb_trim(skb,
> -				mmsg_vector->msg_len - vp->rx_header_size);
> +			if (pskb_trim(skb, mmsg_vector->msg_len - vp->rx_header_size))
> +				return 0;
>   			skb->protocol = eth_type_trans(skb, skb->dev);
>   			/*
>   			 * We do not need to lock on updating stats here

That does not look right. You can have errors when processing an 
individual packet. That is not a reason to bail and you should process 
the next ones. This way you just dropped the rest of the RX vector (up 
to 64 packets at default settings).

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] um: vector: fix return value check in vector_mmsg_rx
  2023-10-07  0:51 [PATCH] um: vector: fix return value check in vector_mmsg_rx Ma Ke
  2023-10-07  6:12 ` Anton Ivanov
@ 2023-10-09  7:31 ` Johannes Berg
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2023-10-09  7:31 UTC (permalink / raw)
  To: Ma Ke, richard, anton.ivanov, xiangyang3; +Cc: linux-um, linux-kernel

On Sat, 2023-10-07 at 08:51 +0800, Ma Ke wrote:
> In vector_mmsg_rx, to avoid an unexpected result returned by
> pskb_trim, we should check the return value of pskb_trim().

And how exactly do you propose pskb_trim() will return anything but 0 in
this scenario?

Please. If you have a static checker, _think_ about it's output before
blindly sending patches.

johannes


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-09  7:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-07  0:51 [PATCH] um: vector: fix return value check in vector_mmsg_rx Ma Ke
2023-10-07  6:12 ` Anton Ivanov
2023-10-09  7:31 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).