Glibc change exposing bugs
Glibc change exposing bugs
Posted Nov 11, 2010 1:52 UTC (Thu) by gus3 (guest, #61103)In reply to: Glibc change exposing bugs by jwb
Parent article: Glibc change exposing bugs
if ((p1 + length <= p2) || (p2 + length <= p1)) {
crash_and_burn();
}
It is not a sophisticated test, and the more noise it makes about buggy parameters, the sooner the calling code will get fixed.
Posted Nov 11, 2010 2:05 UTC (Thu)
by gus3 (guest, #61103)
[Link] (10 responses)
if ((p1 + length >= p2) || (p2 + length >= p1)) {
But goofing the test, doesn't mean the test isn't simple.
Posted Nov 11, 2010 2:12 UTC (Thu)
by gus3 (guest, #61103)
[Link] (9 responses)
I see the actual test in my head, but I can't code it right now due to fatigue. But even with all necessary calculations, being integer math, it'll take no more than a few tens of cycles. Even on a register-starved x86, putting a couple temporary variables on the stack will only pollute the cache, before over-writing the temps anyway. It shouldn't take more than a microsecond to check for overlap.
Posted Nov 11, 2010 7:24 UTC (Thu)
by nix (subscriber, #2304)
[Link] (6 responses)
There is absolutely no chance that the glibc devs would ever accept this except in the -lc_g version of the library (which nobody ever uses).
Posted Nov 12, 2010 23:04 UTC (Fri)
by gus3 (guest, #61103)
[Link] (5 responses)
Posted Nov 14, 2010 22:29 UTC (Sun)
by nix (subscriber, #2304)
[Link] (4 responses)
This isn't an obscure or hard-to-interpret part of the Standard. Undefined, bang, that's it. Perhaps you are operating under the misapprehension that the linux manpages project, a descriptive effort, not a prescriptive one, is in some way binding on glibc? It isn't. It really isn't. It isn't binding on anything.
Posted Nov 15, 2010 0:00 UTC (Mon)
by promotion-account (guest, #70778)
[Link] (3 responses)
What on earth? The relevant documentation for memcpy() is ISO C, incorporated by reference into all versions of POSIX.1.
Indeed.
Linux man-pages are only authoritative for the kernel system-calls (more precisely, their glibc thin layer). The rest of the APIs are only included for convenience: they are a secondary source to the primary source references residing in the 'CONFORMING TO' section.
Posted Nov 15, 2010 0:31 UTC (Mon)
by nix (subscriber, #2304)
[Link] (2 responses)
Posted Nov 15, 2010 1:27 UTC (Mon)
by promotion-account (guest, #70778)
[Link] (1 responses)
For good or bad, these manpages are the 'most primary' sources available for such topics, only beside the code.
But unfortunately these man-pages do not always exist. I once had to carefully study the bluez userspace code to know how to best interface with the kernel Bluetooth API (undocumented AF_BLUETOOTH sockets, undocumented netlink interfaces, etc).
Posted Nov 15, 2010 10:38 UTC (Mon)
by nix (subscriber, #2304)
[Link]
Posted Nov 11, 2010 18:52 UTC (Thu)
by oak (guest, #2786)
[Link] (1 responses)
Posted Nov 15, 2010 0:14 UTC (Mon)
by promotion-account (guest, #70778)
[Link]
memmove() has this check you're clamoring for... And if the given areas don't overlap, it calls memcpy().
Sometimes even if the areas do overlap, it calls memcpy(). This happens if the library has an internal knowledge about memcpy()'s copying direction.
A common example is having src > dst, copying is forward, and the CPU block transfer unit is smaller than or equal to (src - dst). x86-64 CPUs support copying up-to 8-byte blocks in one opcode (movsq), assuming no floating-point ops in use, which is usually the case with kernel code.
Posted Nov 12, 2010 6:34 UTC (Fri)
by jmm82 (guest, #59425)
[Link] (1 responses)
Posted Nov 12, 2010 22:56 UTC (Fri)
by gus3 (guest, #61103)
[Link]
Glibc change exposing bugs
crash_and_burn();
}
Glibc change exposing bugs
Glibc change exposing bugs
Glibc change exposing bugs
Glibc change exposing bugs
The GNU people should own up to having violated the documentation on their code.
What on earth? The relevant documentation for memcpy() is ISO C, incorporated by reference into all versions of POSIX.1. This clearly states "If copying takes place between objects that overlap, the behavior is undefined."
Glibc change exposing bugs
Glibc change exposing bugs
Linux man-pages are only authoritative for the kernel system-calls (more precisely, their glibc thin layer).
No, even those are descriptive. Perhaps the glibc texinfo documentation would be authoritative for that, if it was ever maintained by anyone. As it is, I think only Ulrich and Roland's brains are authoritative for glibc.
Glibc change exposing bugs
Glibc change exposing bugs
Glibc change exposing bugs
Glibc change exposing bugs
Glibc change exposing bugs
Glibc change exposing bugs