News for hackers. Stuff that matters.
Re:“Shared libraries are not a good thing in general” by aidenn0 on Saturday May 01, 2021 @06:51PM (#27010618)
You also get bugs introduced into a program by changes to shared libraries. I've even seen a vulnerability introduced when glibc was upgraded (glibc changed the direction of memory, and the program was using memcpy on overlapping memory).
Re:“Shared libraries are not a good thing in general” by sherincall on Sunday May 02, 2021 @04:13AM (#27013268)
The memcpy API says that is Undefined Behavior, that program was never valid. Not much different from bitbanging specific virtual addresses and expecting they never change.

For overlapping memory, use memmove()

Re:“Shared libraries are not a good thing in general” by aidenn0 on Sunday May 02, 2021 @10:56AM (#27015811)
Yes, the program was invalid, but it was also accidentally bug free. The two are not mutually exclusive.
Re:“Shared libraries are not a good thing in general” by dooglius on Sunday May 02, 2021 @07:03AM (#27014085)
It was never valid taking in a generic shared interface to libc, but a statically linked version would have been valid.
Re:“Shared libraries are not a good thing in general” by sherincall on Sunday May 02, 2021 @09:55AM (#27015318)
C language makes a difference between Undefined Behavior and Implementation Defined Behavior. In this case it's the former (n1570 section 7.24.2.1).

Any code that invokes UB is not a valid C program, regardless of implemention.

More practically, ignoring the bug that did happen, libc also has multiple implementations of these functions and picks one based on HW it is running on. So even a statically linked glibc could behave differently on different HW. Always read the docs, this is well defined in the standard.

Re:“Shared libraries are not a good thing in general” by dooglius on Sunday May 02, 2021 @11:02AM (#27015878)
The source code may have had UB, but the compiled program could nevertheless have been bug-free.

> Any code that invokes UB is not a valid C program, regardless of implemention.

I disagree. UB is defined (3.4.3) merely as behavior the standard imposes no requirements upon. The definition does not preclude an implementation from having reasonable behavior for situations the standard considers undefined.

This nuance is very important for the topic at had because many programs are written for specific implementations, not specs, and doing this is completely reasonable.

Re:“Shared libraries are not a good thing in general” by account42 on Monday May 03, 2021 @09:55AM (#27025105)
> You also get bugs introduced into a program by changes to shared libraries. I've even seen a vulnerability introduced when glibc was upgraded (glibc changed the direction of memory, and the program was using memcpy on overlapping memory).

Did glibc change the behavior of memcpy (the ABI symbol) or memcpy (the C API symbol) which currently maps to the memcpy@GLIBC_2.14 ABI symbol?