News for hackers. Stuff that matters.
Re:Git Security Vulnerabilities Announced by xxpor on Tuesday January 17, 2023 @02:26PM (#34417367)
>It's unclear to me why our languages still default to modulo arithmetic semantics.

Because that's what processors do? (leaving aside backwards compatibility issues)

Re:Git Security Vulnerabilities Announced by hyperhopper on Tuesday January 17, 2023 @03:14PM (#34418202)
Our processors also require manually manipulating registers.

The whole point of higher level programming languages is to abstract away the fiddly bits of dealing with processors that we don't want to have to deal with.

This is one of those cases.

Re:Git Security Vulnerabilities Announced by xxpor on Tuesday January 17, 2023 @03:41PM (#34418661)
In cases where you're willing to take the perf hit, you can just use languages like Python which abstract over integer size entirely.
Re:Git Security Vulnerabilities Announced by hansvm on Tuesday January 17, 2023 @04:42PM (#34419722)
Which used to, but at least for parsing ints they've snuck in the perf hit as a "security vulnerability."
Re:Git Security Vulnerabilities Announced by robmccoll on Tuesday January 17, 2023 @03:23PM (#34418356)
In this case it's really that the cost of determining if an overflow did occur or will occur on modern architectures is too high and the likelihood too low for it to be reasonable to perform the checks in most cases in native code. Might be different for interpreted languages depending on a lot of things (whether or not they even use integer arithmetic, whether or not they default to some arbitrary precision integers by default, etc.). If common architectures automatically interrupted on overflow rather than setting a flag at no additional cost, I'd think you'd see safety guarantees instantly.
Re:Git Security Vulnerabilities Announced by FatActor on Tuesday January 17, 2023 @04:13PM (#34419253)
Saturated arithmetic instructions do not do this.
Re:Git Security Vulnerabilities Announced by xxpor on Tuesday January 17, 2023 @04:33PM (#34419578)
And on the platforms where the ADD instruction uses saturated arithmetic I bet assert(UINT32_MAX + 1 == UINT32_MAX) in C passes.
Re:Git Security Vulnerabilities Announced by FatActor on Tuesday January 17, 2023 @04:39PM (#34419681)
It had better!

Have you considered assert(x == UINT_MAX - 1) instead?

Re:Git Security Vulnerabilities Announced by astrange on Tuesday January 17, 2023 @05:10PM (#34420143)
Unsigned integers in C are defined to wrap on overflow, so they shouldn't be affected by what the underlying processor wants to do. And just because signed overflows are undefined doesn't mean you get what the processor provides either.

So basically, don't forget to test with UBSan.

(I don't like -fno-strict-overflow as a solution, because defining incorrect behavior isn't much better than undefined behavior.)

Re:Git Security Vulnerabilities Announced by xxpor on Thursday January 19, 2023 @12:03PM (#34442664)
TIL modulo wrapping for unsigned ints is actually in the standard, I could have sworn it was implementation defined (as opposed to signed wrapping, which is undefined).
Re:Git Security Vulnerabilities Announced by hot_gril on Tuesday January 17, 2023 @08:21PM (#34422164)
Don't processors also emit a signal when there's an over/underflow?