Broadening compiler checks for buffer overflows in _FORTIFY_SOURCE (2021)
developers.redhat.com
developers.redhat.com
Nowadays Arch uploads package symbols to debug packages and servers accessible by debuginfod (https://wiki.archlinux.org/title/Debugging/Getting_traces), but I've observed debuginfod greatly slows down gdb and valgrind and strace (so I don't set the DEBUGINFOD_URLS environment variable by default, only when actually debugging).
I guess I'll keep using -fsanitize=address (ASan) in my debug builds.
Any stats on the coverage increase?
I mean, this is the kind of stuff that needs to be taken care of at the language level. But I guess that's impossible, so we have this instead. Still, progress! I guess.
- Does this falsely raise buffer overflow errors for T with flexible array members where the actual allocation is bigger than the T?
- On a related note, is it even legal to memcpy more than a T's worth of data into a T? (IMO you shouldn't be doing that, but I think it's legal in C, and not with my template trick.)
- You can't take the address of a template function. What happens when you try to take &wmemcpy? Do you get a non-inlined wmemcpy with a failing branch which never knows the object size? A call to __builtin_dynamic_object_size? Or &__original_wmemcpy?
How can you know if it's a single `T` or an array of `T` objects? You can memcpy into an array of `T` through a `T*` with no limitation on the size. I don't see anything inherently wrong with that either.
Obviously C and C++ are dumpster fires for these sorts of bugs, but this seems like a reasonable approach.
It might be unwise to use this in systemd (as triggering these traps would crash the system), but it would be helpful in many other places, especially in processes that have called listen() to be network servers.
"Some people are not happy to find that previously reliable programs suddenly start crashing. However, as one person put it, they would rather have an application crash than introduce a subtle but undetected corruption in some mission critical database that does not get detected until three months down the road. One such application is X(7), the graphics interface for nearly any UNIX based platforms, including Linux, Solaris, and the other BSD distributions. It was discovered that the X server would crash in several different ways."