3 ms·
You should really use both, however they are only a tool: I don't have any numbers but I imagine Sanitizers have a good detection rate, but one should still wri
by mhh__ 8y ago
You should really use both, however they are only a tool: I don't have any numbers but I imagine Sanitizers have a good detection rate, but one should still write code defensively. There are too many horror stories, be they lethal or expensive, to be risky about memory.
Not a kernel developer: Can you test Kernel code with a sanitizer (if that sanitizer doesn't work in a compiled kernel) by compiling into and using the code as blob in userspace code with mocks (Or whatever, unless it's just utility that doesn't need anything other than an interface)?
- saagarjha 8y agoYup, Address Sanitizer can hide or fail to catch bugs occasionally.
- wyldfire 8y ago> but one should still write code defensively. I'm not sure what this means. You should not write your code any differently regardless of whether you used a sanitizer to help gain confidence in your implementation. You should not use sanitizers in production (at least not the current generation). > Can you test Kernel code with a sanitizer In fact you can! Both UBSan [1] and ASan [2] are in use to root out bugs in linux. [1] https://www.kernel.org/doc/html/v4.14/dev-tools/ubsan.html https://www.kernel.org/doc/html/v4.14/dev-tools/ubsan.html [2] https://www.kernel.org/doc/html/v4.14/dev-tools/kasan.html https://www.kernel.org/doc/html/v4.14/dev-tools/kasan.html
- muricula 8y agoLinux has support for kernel ASAN and I think UBSAN too. User mode linux is a also thing and does roughly what you described, and I think you can run it under valgrind too.
- monocasa 8y agoTo be fair, UML runs at such a low level (raw syscalls rather than calls to, for instance, malloc and free) that it really limits what valgrind can tell you.