2 ms·
There is no index checks in the current kernel C code at all. It is better to panic than violate memory safety.
by fpoling 5y ago
There is no index checks in the current kernel C code at all. It is better to panic than violate memory safety.
- dvt 5y ago> There is no index checks in the current kernel C code at all. It is better to panic than violate memory safety. This isn't the question here. malloc (or other memory operation) failures should never panic. According to Torvalds[1]: > Allocation failures in a driver or non-core code - and that is by definition all of any new Rust code - can never EVER validly cause panics. Same goes for "oh, some case I didn't test used 128-bit integers or floating point". Kernel code is a bit quirky in this sense that it will always favor system stability (and expect proper errors to trickle down) instead of crashing. Also, Linux runs on plenty of low-memory embedded systems so failing on a malloc may not even be a particularly rare occurrence. [1] https://lkml.org/lkml/2021/4/14/1099 https://lkml.org/lkml/2021/4/14/1099
- comex 5y agoThe parent post mentioned both allocation and indexing. Both have the potential to panic in Rust programs based on the full standard library. Allocation needs to be dealt with, as you mention, but out-of-bounds indexing could likely continue to be a Rust panic, which could be translated to a Linux BUG() call.