All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alice Michael <alice.michael@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [next PATCH S3 7/9] i40e: remove out-of-range comparisions in i40e_validate_cloud_filter
Date: Thu, 28 Feb 2019 09:52:53 -0800	[thread overview]
Message-ID: <20190228175255.54754-7-alice.michael@intel.com> (raw)
In-Reply-To: <20190228175255.54754-1-alice.michael@intel.com>

From: Jacob Keller <jacob.e.keller@intel.com>

The function i40e_validate_cloud_filter checks that the destination and
source port numbers are valid by attempting to ensure that the number is
non-zero and no larger than 0xFFFF. However, the types for the dst_port
and src_port variable are __be16 which by definition cannot be larger
than 0xFFFF

Since these values cannot be larger than 2 bytes, the check to see if
they exceed 0xFFFF is meaningless.

One might consider these checks as some sort of defensive coding, in
case the type was later changed. However, these checks also byte-swap
the value before comparision using be16_to_cpu, which will truncate the
values to 16bits anyways. Additionally, changing the type would require
updating the opcodes to support new data layout of these virtchnl
commands.

Remove the check to silence the -Wtype-limits warning that was added to
GCC 8.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 24628de8e624..925ca880bea3 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -3129,7 +3129,7 @@ static int i40e_validate_cloud_filter(struct i40e_vf *vf,
 	}
 
 	if (mask.dst_port & data.dst_port) {
-		if (!data.dst_port || be16_to_cpu(data.dst_port) > 0xFFFF) {
+		if (!data.dst_port) {
 			dev_info(&pf->pdev->dev, "VF %d: Invalid Dest port\n",
 				 vf->vf_id);
 			goto err;
@@ -3137,7 +3137,7 @@ static int i40e_validate_cloud_filter(struct i40e_vf *vf,
 	}
 
 	if (mask.src_port & data.src_port) {
-		if (!data.src_port || be16_to_cpu(data.src_port) > 0xFFFF) {
+		if (!data.src_port) {
 			dev_info(&pf->pdev->dev, "VF %d: Invalid Source port\n",
 				 vf->vf_id);
 			goto err;
-- 
2.19.2


  parent reply	other threads:[~2019-02-28 17:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28 17:52 [Intel-wired-lan] [next PATCH S3 1/9] i40e: Fix for allowing too many MDD events on VF Alice Michael
2019-02-28 17:52 ` [Intel-wired-lan] [next PATCH S3 2/9] i40e: change behavior on PF in response to MDD event Alice Michael
2019-03-02  0:22   ` Bowers, AndrewX
2019-02-28 17:52 ` [Intel-wired-lan] [next PATCH S3 3/9] i40e: remove error msg when vf with port vlan tries to remove vlan 0 Alice Michael
2019-02-28 17:57   ` Loktionov, Aleksandr
2019-03-02  0:22   ` Bowers, AndrewX
2019-02-28 17:52 ` [Intel-wired-lan] [next PATCH S3 4/9] i40e: ShadowRAM checksum calculation change Alice Michael
2019-03-02  0:23   ` Bowers, AndrewX
2019-02-28 17:52 ` [Intel-wired-lan] [next PATCH S3 5/9] i40e: Report advertised link modes on 40GBase_LR4, CR4 and fibre Alice Michael
2019-03-02  0:23   ` Bowers, AndrewX
2019-03-04  9:11   ` Ludkiewicz, Adam
2019-02-28 17:52 ` [Intel-wired-lan] [next PATCH S3 6/9] i40e: Further implementation of LLDP Alice Michael
2019-02-28 17:56   ` Loktionov, Aleksandr
2019-03-02  0:24   ` Bowers, AndrewX
2019-02-28 17:52 ` Alice Michael [this message]
2019-03-02  0:24   ` [Intel-wired-lan] [next PATCH S3 7/9] i40e: remove out-of-range comparisions in i40e_validate_cloud_filter Bowers, AndrewX
2019-02-28 17:52 ` [Intel-wired-lan] [next PATCH S3 8/9] i40e: update version number Alice Michael
2019-03-02  0:25   ` Bowers, AndrewX
2019-02-28 17:52 ` [Intel-wired-lan] [next PATCH S3 9/9] i40e: fix misleading message about promisc setting on un-trusted VF Alice Michael
2019-03-02  0:26   ` Bowers, AndrewX
2019-03-02  0:21 ` [Intel-wired-lan] [next PATCH S3 1/9] i40e: Fix for allowing too many MDD events on VF Bowers, AndrewX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190228175255.54754-7-alice.michael@intel.com \
    --to=alice.michael@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.