1 |
On April 20, 2004 05:11 pm, pageexec@××××××××.hu wrote: |
2 |
> > The attached glibc patch uses the frandom sysctl interface, and has a bug |
3 |
> > fix (/4). I removed some #ifdefs that I thought should always be defined |
4 |
> > (maybe someone can double check it, should be okay though). |
5 |
> |
6 |
> a few issues: |
7 |
> |
8 |
> 1. don't initialize __guard[] to all 0s, on some compilers it will force |
9 |
> it into the .data section (instead of .bss), it's a slight waste... |
10 |
|
11 |
I have read the stack value can be used here with zero preformance loss. Just |
12 |
to set initial values. |
13 |
|
14 |
> 2. you have a nice buffer overflow on 64 bit archs where sizeof long = 8 |
15 |
> but in your loop you access twice as many elements (you divide by 4 |
16 |
> instead of sizeof long). |
17 |
|
18 |
The /4 is to prevent a bug. Only multiples of 4 and 16 can be used, its a |
19 |
double check. |
20 |
|
21 |
> 3. for that matter, don't make __guard an array at all, i see no point in |
22 |
> it if only the very first element is used. |
23 |
> |
24 |
> 4. don't bother casting __guard when you fill in the terminator canary, |
25 |
> simply: __guard[0] = 0xff000d0aUL; (or __guard = 0xff000d0aUL; ). |
26 |
> endianess is of no concern here. you can also choose any permutation |
27 |
> of these 4 bytes (i note that the original ssp terminator didn't contain |
28 |
> 0x0d, however stackguard's does, probably doesn't hurt). |
29 |
|
30 |
This libc code is from Etoh & friends. I understand how it works, but not how |
31 |
to make it work in a different way. |
32 |
|
33 |
|
34 |
-- |
35 |
gentoo-hardened@g.o mailing list |