lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y9os+zttPvt5mlFM@nanopsycho>
Date:   Wed, 1 Feb 2023 10:12:27 +0100
From:   Jiri Pirko <jiri@...nulli.us>
To:     Tony Nguyen <anthony.l.nguyen@...el.com>
Cc:     davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
        edumazet@...gle.com, Tom Rix <trix@...hat.com>,
        netdev@...r.kernel.org, richardcochran@...il.com,
        vinicius.gomes@...el.com, Simon Horman <simon.horman@...igine.com>,
        Sasha Neftin <sasha.neftin@...el.com>,
        Naama Meir <naamax.meir@...ux.intel.com>
Subject: Re: [PATCH net 1/1] igc: return an error if the mac type is unknown
 in igc_ptp_systim_to_hwtstamp()

Tue, Jan 31, 2023 at 10:54:37PM CET, anthony.l.nguyen@...el.com wrote:
>From: Tom Rix <trix@...hat.com>
>
>clang static analysis reports
>drivers/net/ethernet/intel/igc/igc_ptp.c:673:3: warning: The left operand of
>  '+' is a garbage value [core.UndefinedBinaryOperatorResult]
>   ktime_add_ns(shhwtstamps.hwtstamp, adjust);
>   ^            ~~~~~~~~~~~~~~~~~~~~
>
>igc_ptp_systim_to_hwtstamp() silently returns without setting the hwtstamp
>if the mac type is unknown.  This should be treated as an error.
>
>Fixes: 81b055205e8b ("igc: Add support for RX timestamping")
>Signed-off-by: Tom Rix <trix@...hat.com>
>Reviewed-by: Simon Horman <simon.horman@...igine.com>
>Acked-by: Sasha Neftin <sasha.neftin@...el.com>
>Tested-by: Naama Meir <naamax.meir@...ux.intel.com>
>Signed-off-by: Tony Nguyen <anthony.l.nguyen@...el.com>
>---
> drivers/net/ethernet/intel/igc/igc_ptp.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c b/drivers/net/ethernet/intel/igc/igc_ptp.c
>index c34734d432e0..4e10ced736db 100644
>--- a/drivers/net/ethernet/intel/igc/igc_ptp.c
>+++ b/drivers/net/ethernet/intel/igc/igc_ptp.c
>@@ -417,10 +417,12 @@ static int igc_ptp_verify_pin(struct ptp_clock_info *ptp, unsigned int pin,
>  *
>  * We need to convert the system time value stored in the RX/TXSTMP registers
>  * into a hwtstamp which can be used by the upper level timestamping functions.
>+ *
>+ * Returns 0 on success.
>  **/
>-static void igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter,
>-				       struct skb_shared_hwtstamps *hwtstamps,
>-				       u64 systim)
>+static int igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter,
>+				      struct skb_shared_hwtstamps *hwtstamps,
>+				      u64 systim)
> {
> 	switch (adapter->hw.mac.type) {
> 	case igc_i225:
>@@ -430,8 +432,9 @@ static void igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter,
> 						systim & 0xFFFFFFFF);
> 		break;
> 	default:
>-		break;
>+		return -EINVAL;
> 	}
>+	return 0;
> }
> 
> /**
>@@ -652,7 +655,8 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter)
> 
> 	regval = rd32(IGC_TXSTMPL);
> 	regval |= (u64)rd32(IGC_TXSTMPH) << 32;
>-	igc_ptp_systim_to_hwtstamp(adapter, &shhwtstamps, regval);
>+	if (igc_ptp_systim_to_hwtstamp(adapter, &shhwtstamps, regval))

Use variable to store the return value.


>+		return;
> 
> 	switch (adapter->link_speed) {
> 	case SPEED_10:
>-- 
>2.38.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ