* [PATCH] net: mlx5: fix a potential NULL pointer dereference
@ 2019-03-11 6:33 Kangjie Lu
2019-03-11 14:06 ` Jason Gunthorpe
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Kangjie Lu @ 2019-03-11 6:33 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Saeed Mahameed, Leon Romanovsky, David S. Miller,
netdev, linux-rdma, linux-kernel
In case skb_header_pointer fails, the fix issues a warning.
A better fix requires modifying the signature of mlx5e_get_fcs to
pass an error code upstream.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index be396e5e4e39..6ec1c110e4be 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -719,6 +719,8 @@ static u32 mlx5e_get_fcs(const struct sk_buff *skb)
fcs_bytes = skb_header_pointer(skb, skb->len - ETH_FCS_LEN,
ETH_FCS_LEN, &_fcs_bytes);
+ if (unlikely(!fcs_bytes))
+ pr_warn_once("skb_header_pointer returns NULL\n");
return __get_unaligned_cpu32(fcs_bytes);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: mlx5: fix a potential NULL pointer dereference
2019-03-11 6:33 [PATCH] net: mlx5: fix a potential NULL pointer dereference Kangjie Lu
@ 2019-03-11 14:06 ` Jason Gunthorpe
2019-03-11 18:46 ` Saeed Mahameed
2019-03-11 20:38 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2019-03-11 14:06 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, Saeed Mahameed, Leon Romanovsky, David S. Miller,
netdev, linux-rdma, linux-kernel
On Mon, Mar 11, 2019 at 01:33:43AM -0500, Kangjie Lu wrote:
> In case skb_header_pointer fails, the fix issues a warning.
>
> A better fix requires modifying the signature of mlx5e_get_fcs to
> pass an error code upstream.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> index be396e5e4e39..6ec1c110e4be 100644
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> @@ -719,6 +719,8 @@ static u32 mlx5e_get_fcs(const struct sk_buff *skb)
>
> fcs_bytes = skb_header_pointer(skb, skb->len - ETH_FCS_LEN,
> ETH_FCS_LEN, &_fcs_bytes);
> + if (unlikely(!fcs_bytes))
> + pr_warn_once("skb_header_pointer returns NULL\n");
This is really pointless. Fix stuff like this so it doesn't oops or
don't bother.
Jason
> return __get_unaligned_cpu32(fcs_bytes);
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: mlx5: fix a potential NULL pointer dereference
2019-03-11 6:33 [PATCH] net: mlx5: fix a potential NULL pointer dereference Kangjie Lu
2019-03-11 14:06 ` Jason Gunthorpe
@ 2019-03-11 18:46 ` Saeed Mahameed
2019-03-11 20:38 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Saeed Mahameed @ 2019-03-11 18:46 UTC (permalink / raw)
To: kjlu; +Cc: davem, netdev, pakki001, linux-rdma, leon, linux-kernel
On Mon, 2019-03-11 at 01:33 -0500, Kangjie Lu wrote:
> In case skb_header_pointer fails, the fix issues a warning.
>
This case is impossible: mlx5 driver builds this skb itself so we are
sure skb_header_pointer never fails.
What is the motivation behind this fix? static checker or actual issue
?
> A better fix requires modifying the signature of mlx5e_get_fcs to
> pass an error code upstream.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> index be396e5e4e39..6ec1c110e4be 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
> @@ -719,6 +719,8 @@ static u32 mlx5e_get_fcs(const struct sk_buff
> *skb)
>
> fcs_bytes = skb_header_pointer(skb, skb->len - ETH_FCS_LEN,
> ETH_FCS_LEN, &_fcs_bytes);
> + if (unlikely(!fcs_bytes))
> + pr_warn_once("skb_header_pointer returns NULL\n");
>
> return __get_unaligned_cpu32(fcs_bytes);
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: mlx5: fix a potential NULL pointer dereference
2019-03-11 6:33 [PATCH] net: mlx5: fix a potential NULL pointer dereference Kangjie Lu
2019-03-11 14:06 ` Jason Gunthorpe
2019-03-11 18:46 ` Saeed Mahameed
@ 2019-03-11 20:38 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-03-11 20:38 UTC (permalink / raw)
To: kjlu; +Cc: pakki001, saeedm, leon, netdev, linux-rdma, linux-kernel
From: Kangjie Lu <kjlu@umn.edu>
Date: Mon, 11 Mar 2019 01:33:43 -0500
> In case skb_header_pointer fails, the fix issues a warning.
>
> A better fix requires modifying the signature of mlx5e_get_fcs to
> pass an error code upstream.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Saeed, I'll let you take this.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-11 20:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11 6:33 [PATCH] net: mlx5: fix a potential NULL pointer dereference Kangjie Lu
2019-03-11 14:06 ` Jason Gunthorpe
2019-03-11 18:46 ` Saeed Mahameed
2019-03-11 20:38 ` David Miller
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).