[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20131104.200144.759235525186812439.davem@davemloft.net>
Date: Mon, 04 Nov 2013 20:01:44 -0500 (EST)
From: David Miller <davem@...emloft.net>
To: brouer@...hat.com
Cc: netdev@...r.kernel.org, eric.dumazet@...il.com,
paulmck@...ux.vnet.ibm.com, dave.taht@...il.com
Subject: Re: [net-next PATCH V2] net: codel: Avoid undefined behavior from
signed overflow
From: Jesper Dangaard Brouer <brouer@...hat.com>
Date: Thu, 31 Oct 2013 22:10:55 +0100
> From: Jesper Dangaard Brouer <netoptimizer@...uer.com>
>
> As described in commit 5a581b367 (jiffies: Avoid undefined
> behavior from signed overflow), according to the C standard
> 3.4.3p3, overflow of a signed integer results in undefined
> behavior.
>
> To fix this, do as the above commit, and do an unsigned
> subtraction, and interpreting the result as a signed
> two's-complement number. This is based on the theory from
> RFC 1982 and is nicely described in wikipedia here:
> https://en.wikipedia.org/wiki/Serial_number_arithmetic#General_Solution
>
> A side-note, I have seen practical issues with the previous logic
> when dealing with 16-bit, on a 64-bit machine (gcc version
> 4.4.5). This were 32-bit, which I have not observed issues with.
>
> Cc: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
> Signed-off-by: Jesper Dangaard Brouer <netoptimizer@...uer.com>
Applied, thanks for working through this Jesper.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists