netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] e1000e: fix numeric overflow in phc settime method.
@ 2013-04-22 13:53 Richard Cochran
  2013-04-22 17:53 ` Jeff Kirsher
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Cochran @ 2013-04-22 13:53 UTC (permalink / raw)
  To: netdev
  Cc: David Miller, Jeff Kirsher, Jeroen Van den Keybus, bruce.w.allan,
	e1000-devel

The PTP Hardware Clock settime function in the e1000e driver
computes nanoseconds from a struct timespec. The code converts the
seconds field .tv_sec by multiplying it with NSEC_PER_SEC. However,
both operands are of type long, resulting in an unintended overflow.
The patch fixes the issue by using the helper function from time.h.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/intel/e1000e/ptp.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c
index b477fa5..065f8c8 100644
--- a/drivers/net/ethernet/intel/e1000e/ptp.c
+++ b/drivers/net/ethernet/intel/e1000e/ptp.c
@@ -145,8 +145,7 @@ static int e1000e_phc_settime(struct ptp_clock_info *ptp,
 	unsigned long flags;
 	u64 ns;
 
-	ns = ts->tv_sec * NSEC_PER_SEC;
-	ns += ts->tv_nsec;
+	ns = timespec_to_ns(ts);
 
 	/* reset the timecounter */
 	spin_lock_irqsave(&adapter->systim_lock, flags);
-- 
1.7.2.5

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

* Re: [PATCH net] e1000e: fix numeric overflow in phc settime method.
  2013-04-22 13:53 [PATCH net] e1000e: fix numeric overflow in phc settime method Richard Cochran
@ 2013-04-22 17:53 ` Jeff Kirsher
  2013-04-22 17:56   ` Richard Cochran
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Kirsher @ 2013-04-22 17:53 UTC (permalink / raw)
  To: Richard Cochran
  Cc: netdev, David Miller, Jeroen Van den Keybus, bruce.w.allan,
	e1000-devel

[-- Attachment #1: Type: text/plain, Size: 640 bytes --]

On Mon, 2013-04-22 at 15:53 +0200, Richard Cochran wrote:
> 
> The PTP Hardware Clock settime function in the e1000e driver
> computes nanoseconds from a struct timespec. The code converts the
> seconds field .tv_sec by multiplying it with NSEC_PER_SEC. However,
> both operands are of type long, resulting in an unintended overflow.
> The patch fixes the issue by using the helper function from time.h.
> 
> Signed-off-by: Richard Cochran <richardcochran@gmail.com>
> ---
>  drivers/net/ethernet/intel/e1000e/ptp.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-) 

Thanks Richard, I will add this to my queue.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH net] e1000e: fix numeric overflow in phc settime method.
  2013-04-22 17:53 ` Jeff Kirsher
@ 2013-04-22 17:56   ` Richard Cochran
  2013-04-22 18:17     ` Jeff Kirsher
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Cochran @ 2013-04-22 17:56 UTC (permalink / raw)
  To: Jeff Kirsher
  Cc: netdev, David Miller, Jeroen Van den Keybus, bruce.w.allan,
	e1000-devel

On Mon, Apr 22, 2013 at 10:53:22AM -0700, Jeff Kirsher wrote:
> 
> Thanks Richard, I will add this to my queue.

If it doesn't make it into 3.9, please submit this one to stable, too.

Thanks,
Richard

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

* Re: [PATCH net] e1000e: fix numeric overflow in phc settime method.
  2013-04-22 17:56   ` Richard Cochran
@ 2013-04-22 18:17     ` Jeff Kirsher
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Kirsher @ 2013-04-22 18:17 UTC (permalink / raw)
  To: Richard Cochran
  Cc: e1000-devel, netdev, bruce.w.allan, Jeroen, den Keybus,
	David Miller


[-- Attachment #1.1: Type: text/plain, Size: 308 bytes --]

On Mon, 2013-04-22 at 19:56 +0200, Richard Cochran wrote:
> On Mon, Apr 22, 2013 at 10:53:22AM -0700, Jeff Kirsher wrote:
> > 
> > Thanks Richard, I will add this to my queue.
> 
> If it doesn't make it into 3.9, please submit this one to stable, too.
> 
> Thanks,
> Richard
> 

Got it, will do.

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 416 bytes --]

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter

[-- Attachment #3: Type: text/plain, Size: 257 bytes --]

_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

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

end of thread, other threads:[~2013-04-22 18:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-22 13:53 [PATCH net] e1000e: fix numeric overflow in phc settime method Richard Cochran
2013-04-22 17:53 ` Jeff Kirsher
2013-04-22 17:56   ` Richard Cochran
2013-04-22 18:17     ` Jeff Kirsher

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).