This is apparently an extension that will eliminate buffer overflow and format string vulnerabilities in C/C++ programs, I would guess by providing hardware support for, e.g. converting scanf to fgets automatically, or something along those lines. Will this extension change C/C++'s reputation as a dangerous language? Will C/C++ finally be completely safe to use? Or will other vulnerabilities like integer overflows still be a concern? Is there any reason why MPX wouldn't turn C/C++ into a completely safe language? I'm not very familiar with MPX and I want to hear from people who are.

I apologize if this question is too general. Suggestions for narrowing it down are welcome.

  • Per section 2.5 "INTEL INSTRUCTION SET ARCHITECTURE AND FEATURES REMOVED" of the Nov 2020 Intel manuals, Intel is removing MPX from 2019 onward. – user252180 Mar 3 at 22:55

Firstly, C++ has enough degrees of freedom that a computer cannot make it completely safe. C++ literally gives you full access to anything the CPU can do.

Functions like fscanf are just routines that do looping and checking internally to give you higher-level functionality. However, fscanf has no knowledge of how far a buffer goes (I.e. how big it is). The only part of the code that does have that information is the malloc library, but that's also just a higher-level algorithm to make things easier that the hardware doesn't know about.

Theoretically, the compiler can store this information and pass it to the MPX extensions, but in many applications that will be nearly impossible to do because most things are stored as void* and passed around manually so a static analyzer cannot have the requisite information to set those registers. The only way to do this would be to store additional information at runtime, thereby changing the size of void* which would violate the rules of C++, so it would have to be a special type that very few developers will actually implement because it will cost too much.

A buffer overflow happens when the developer is lazy with their power, not when the hardware messes up.

This is just one of the possible bugs in software that make it insecure. There have been SEVERAL bugs which are integer overflows, invalid logic, etc.

So no, it will not make C++ completely safe to use - nothing will.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.