DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/iavf: check for NULL pointer before dereference
@ 2026-07-10 12:59 Bruce Richardson
  2026-07-10 13:19 ` Loftus, Ciara
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2026-07-10 12:59 UTC (permalink / raw)
  To: dev; +Cc: ciara.loftus, Bruce Richardson

Static analysis with Coverity flags a possible NULL pointer dereference
of "hdr1" when handling IPv4 or IPv6 fragements in
iavf_fdir_parse_pattern.  This is likely a false positive, since the
flow pattern protocol sequences are checked before this function is
called, so all paths leading to a hdr1 dereference start with an
ethernet protocol, which sets hdr1 to a non-NULL value.

However, this is a rather brittle situation, so to prevent any future
issues if a new set of allowed protocols is added with IP but no
Ethernet matching patterns, add explicit NULL checks for hdr1 before
it's used each time.

Coverity Id: 503768

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/intel/iavf/iavf_fdir.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/intel/iavf/iavf_fdir.c b/drivers/net/intel/iavf/iavf_fdir.c
index 8940132dff..ea620863ca 100644
--- a/drivers/net/intel/iavf/iavf_fdir.c
+++ b/drivers/net/intel/iavf/iavf_fdir.c
@@ -806,6 +806,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 				 * ethertype, if the spec and mask is valid,
 				 * set ethertype into input set.
 				 */
+				/* ETH should be present via pattern pre-validation. */
+				if (hdr1 == NULL) {
+					rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item,
+						   "Missing ETH header before IPv4 fragment.");
+					return -rte_errno;
+				}
 				input_set |= IAVF_INSET_ETHERTYPE;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr1, ETH,
 								 ETHERTYPE);
@@ -911,6 +919,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 				 * ethertype, if the spec and mask is valid,
 				 * set ethertype into input set.
 				 */
+				/* ETH should be present via pattern pre-validation. */
+				if (hdr1 == NULL) {
+					rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item,
+						   "Missing ETH header before IPv6 fragment.");
+					return -rte_errno;
+				}
 				input_set |= IAVF_INSET_ETHERTYPE;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr1, ETH,
 								 ETHERTYPE);
-- 
2.53.0


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

* RE: [PATCH] net/iavf: check for NULL pointer before dereference
  2026-07-10 12:59 [PATCH] net/iavf: check for NULL pointer before dereference Bruce Richardson
@ 2026-07-10 13:19 ` Loftus, Ciara
  2026-07-10 14:16   ` Bruce Richardson
  0 siblings, 1 reply; 3+ messages in thread
From: Loftus, Ciara @ 2026-07-10 13:19 UTC (permalink / raw)
  To: Richardson, Bruce, dev@dpdk.org

> Subject: [PATCH] net/iavf: check for NULL pointer before dereference

check-git-log complains NULL --> null

> 
> Static analysis with Coverity flags a possible NULL pointer dereference
> of "hdr1" when handling IPv4 or IPv6 fragements in
> iavf_fdir_parse_pattern.  This is likely a false positive, since the
> flow pattern protocol sequences are checked before this function is
> called, so all paths leading to a hdr1 dereference start with an
> ethernet protocol, which sets hdr1 to a non-NULL value.
> 
> However, this is a rather brittle situation, so to prevent any future
> issues if a new set of allowed protocols is added with IP but no
> Ethernet matching patterns, add explicit NULL checks for hdr1 before
> it's used each time.
> 
> Coverity Id: 503768

"issue" instead of "id"

> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

Acked-by: Ciara Loftus <ciara.loftus@intel.com>

> ---
>  drivers/net/intel/iavf/iavf_fdir.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/net/intel/iavf/iavf_fdir.c b/drivers/net/intel/iavf/iavf_fdir.c
> index 8940132dff..ea620863ca 100644
> --- a/drivers/net/intel/iavf/iavf_fdir.c
> +++ b/drivers/net/intel/iavf/iavf_fdir.c
> @@ -806,6 +806,14 @@ iavf_fdir_parse_pattern(__rte_unused struct
> iavf_adapter *ad,
>  				 * ethertype, if the spec and mask is valid,
>  				 * set ethertype into input set.
>  				 */
> +				/* ETH should be present via pattern pre-
> validation. */
> +				if (hdr1 == NULL) {
> +					rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ITEM,
> +						   item,
> +						   "Missing ETH header before
> IPv4 fragment.");
> +					return -rte_errno;
> +				}
>  				input_set |= IAVF_INSET_ETHERTYPE;
> 
> 	VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr1, ETH,
>  								 ETHERTYPE);
> @@ -911,6 +919,14 @@ iavf_fdir_parse_pattern(__rte_unused struct
> iavf_adapter *ad,
>  				 * ethertype, if the spec and mask is valid,
>  				 * set ethertype into input set.
>  				 */
> +				/* ETH should be present via pattern pre-
> validation. */
> +				if (hdr1 == NULL) {
> +					rte_flow_error_set(error, EINVAL,
> +
> RTE_FLOW_ERROR_TYPE_ITEM,
> +						   item,
> +						   "Missing ETH header before
> IPv6 fragment.");
> +					return -rte_errno;
> +				}
>  				input_set |= IAVF_INSET_ETHERTYPE;
> 
> 	VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr1, ETH,
>  								 ETHERTYPE);
> --
> 2.53.0


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

* Re: [PATCH] net/iavf: check for NULL pointer before dereference
  2026-07-10 13:19 ` Loftus, Ciara
@ 2026-07-10 14:16   ` Bruce Richardson
  0 siblings, 0 replies; 3+ messages in thread
From: Bruce Richardson @ 2026-07-10 14:16 UTC (permalink / raw)
  To: Loftus, Ciara; +Cc: dev@dpdk.org

On Fri, Jul 10, 2026 at 02:19:34PM +0100, Loftus, Ciara wrote:
> > Subject: [PATCH] net/iavf: check for NULL pointer before dereference
> 
> check-git-log complains NULL --> null
> 
> > 
> > Static analysis with Coverity flags a possible NULL pointer dereference
> > of "hdr1" when handling IPv4 or IPv6 fragements in
> > iavf_fdir_parse_pattern.  This is likely a false positive, since the
> > flow pattern protocol sequences are checked before this function is
> > called, so all paths leading to a hdr1 dereference start with an
> > ethernet protocol, which sets hdr1 to a non-NULL value.
> > 
> > However, this is a rather brittle situation, so to prevent any future
> > issues if a new set of allowed protocols is added with IP but no
> > Ethernet matching patterns, add explicit NULL checks for hdr1 before
> > it's used each time.
> > 
> > Coverity Id: 503768
> 
> "issue" instead of "id"
> 
Fixed on apply
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Acked-by: Ciara Loftus <ciara.loftus@intel.com>
> 

Applied to dpdk-next-net-intel.

/Bruce

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

end of thread, other threads:[~2026-07-10 14:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-10 12:59 [PATCH] net/iavf: check for NULL pointer before dereference Bruce Richardson
2026-07-10 13:19 ` Loftus, Ciara
2026-07-10 14:16   ` Bruce Richardson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox