[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230425170406.2522523-1-anthony.l.nguyen@intel.com>
Date: Tue, 25 Apr 2023 10:04:06 -0700
From: Tony Nguyen <anthony.l.nguyen@...el.com>
To: davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
edumazet@...gle.com, netdev@...r.kernel.org
Cc: Andrii Staikov <andrii.staikov@...el.com>,
anthony.l.nguyen@...el.com, richardcochran@...il.com,
Sunitha Mekala <sunithax.d.mekala@...el.com>
Subject: [PATCH net 1/1] i40e: fix PTP pins verification
From: Andrii Staikov <andrii.staikov@...el.com>
Fix PTP pins verification not to contain tainted arguments. As a new PTP
pins configuration is provided by a user, it may contain tainted
arguments that are out of bounds for the list of possible values that can
lead to a potential security threat. Change pin's state name from 'invalid'
to 'empty' for more clarification.
Fixes: 1050713026a0 ("i40e: add support for PTP external synchronization clock")
Signed-off-by: Andrii Staikov <andrii.staikov@...el.com>
Tested-by: Sunitha Mekala <sunithax.d.mekala@...el.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@...el.com>
---
drivers/net/ethernet/intel/i40e/i40e_ptp.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
index c37abbb3cd06..78e7c705cd89 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
@@ -49,7 +49,7 @@ static struct ptp_pin_desc sdp_desc[] = {
enum i40e_ptp_gpio_pin_state {
end = -2,
- invalid,
+ empty,
off,
in_A,
in_B,
@@ -1078,11 +1078,19 @@ static int i40e_ptp_set_pins(struct i40e_pf *pf,
else if (pin_caps == CAN_DO_PINS)
return 0;
- if (pins->sdp3_2 == invalid)
+ if ((pins->sdp3_2 < empty || pins->sdp3_2 > out_B) ||
+ (pins->sdp3_3 < empty || pins->sdp3_3 > out_B) ||
+ (pins->gpio_4 < empty || pins->gpio_4 > out_B)) {
+ dev_warn(&pf->pdev->dev,
+ "The provided PTP configuration set contains meaningless values that may potentially pose a safety threat.\n");
+ return -EPERM;
+ }
+
+ if (pins->sdp3_2 == empty)
pins->sdp3_2 = pf->ptp_pins->sdp3_2;
- if (pins->sdp3_3 == invalid)
+ if (pins->sdp3_3 == empty)
pins->sdp3_3 = pf->ptp_pins->sdp3_3;
- if (pins->gpio_4 == invalid)
+ if (pins->gpio_4 == empty)
pins->gpio_4 = pf->ptp_pins->gpio_4;
while (i40e_ptp_pin_led_allowed_states[i].sdp3_2 != end) {
if (pins->sdp3_2 == i40e_ptp_pin_led_allowed_states[i].sdp3_2 &&
--
2.38.1
Powered by blists - more mailing lists