Re: libkern stack_protector

看板DFBSD_kernel作者時間21年前 (2005/01/30 04:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
:On Fri, Jan 28, 2005 at 05:29:03PM -0500, Robert Connolly wrote: :> Hello. In regards to your: :> src/sys/libkern/stack_protector.c :> :> You have: :> #if BYTE_ORDER == LITTLE_ENDIAN :> int __guard = 0x00000aff; :> #else :> int __guard = 0xff0a0000; :> #endif :> :> Why do you check for endianness? : :Because the order of the cookie bytes changes the meaning of :how overflowing buffers are used. : :Joerg : :> :> robert Right. The idea of the cookie is to catch an overflow. Catching an overflow means emplacing the cookie such that a one-byte overflow is likely to be caught. We'd rather have a non-zero byte for the first byte of the overflow area rather then a zero byte. Why aren't all the bytes non-zero? Because we also want the guard to provide at least one zero byte for string termination. And there are a few other reasons too. It's mostly inconsequential but there is a method behind the madness. -Matt Matthew Dillon <dillon@backplane.com>
文章代碼(AID): #11--k500 (DFBSD_kernel)
文章代碼(AID): #11--k500 (DFBSD_kernel)