3 ms·
Ok so if I have an application that makes a large stack allocation, it's safe as long as that memory is read/written at least once?
by radarsat1 9y ago
Ok so if I have an application that makes a large stack allocation, it's safe as long as that memory is read/written at least once?
- lmm 9y agoOnly if it's accessed at least once in each page (4K), AIUI.
- radarsat1 9y agoRight. If I simply zero the memory with `memset` then I guess it should be ok.
- mnarayan01 9y agoNo: See http://en.cppreference.com/w/c/string/byte/memset#Notes http://en.cppreference.com/w/c/string/byte/memset#Notes -- if you don't read from it, the call may be optimized away.
- clarry 9y agoUnless the compiler decides that zeroing the memory doesn't do anything useful and optimizes it out.
- astrange 9y agoInitializing your stack buffer probably does count as something useful, but in case it doesn't, try memset_s(3).
- dom0 9y agoLike my brethren say it's probably a good idea to use a "secure" memset that won't have an accident ^W ^W ^W be optimized out.
- loeg 9y agoOr keep >4kB objects off stack.
- radarsat1 9y agoI mean, that's probably a good practice. In my case I sort of had this idea that largish objects should be placed on the heap but I couldn't really figure out a good reason why, or what the limit should be, so I guess this vuln proposes both a reason and that the page limit is a good threshold.