Messages in this thread | | | Subject | Re: [PATCH] net: optimize cmpxchg in ip_idents_reserve | From | Eric Dumazet <> | Date | Fri, 17 Jan 2020 10:16:45 -0800 |
| |
On 1/17/20 10:03 AM, Arvind Sankar wrote: > On Fri, Jan 17, 2020 at 08:35:07AM -0800, Eric Dumazet wrote: >> >> >> On 1/17/20 4:32 AM, Peter Zijlstra wrote: >> >>> >>> That's crazy, just accept that UBSAN is taking bonghits and ignore it. >>> Use atomic_add_return() unconditionally. >>> >> >> Yes, we might simply add a comment so that people do not bug us if >> their compiler is too old. >> >> /* If UBSAN reports an error there, please make sure your compiler >> * supports -fno-strict-overflow before reporting it. >> */ >> return atomic_add_return(segs + delta, p_id) - segs; >> > > Do we need that comment any more? The flag was apparently introduced in > gcc-4.2 and we only support 4.6+ anyway?
Wasńt it the case back in 2016 already for linux-4.8 ?
What will prevent someone to send another report to netdev/lkml ?
-fno-strict-overflow support is not a prereq for CONFIG_UBSAN.
Fact that we kept in lib/ubsan.c and lib/test_ubsan.c code for test_ubsan_add_overflow() and test_ubsan_sub_overflow() is disturbing.
commit adb03115f4590baa280ddc440a8eff08a6be0cb7 Author: Eric Dumazet <edumazet@google.com> Date: Tue Sep 20 18:06:17 2016 -0700
net: get rid of an signed integer overflow in ip_idents_reserve()
Jiri Pirko reported an UBSAN warning happening in ip_idents_reserve()
[] UBSAN: Undefined behaviour in ./arch/x86/include/asm/atomic.h:156:11 [] signed integer overflow: [] -2117905507 + -695755206 cannot be represented in type 'int'
Since we do not have uatomic_add_return() yet, use atomic_cmpxchg() so that the arithmetics can be done using unsigned int.
Fixes: 04ca6973f7c1 ("ip: make IP identifiers less predictable") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net>
| |