Protecting against invalid memory references
Techniques facilitating hardware-based memory-error mitigation for heap-objects. In one example, a system can comprise a process that executes computer executable components stored in a non-transitory computer readable medium. The computer executable components comprise: an entry component; and a re-purpose component. The entry component can allocate an entry in a table to store bounds-information when an object is allocated in memory. The re-purpose component can re-purpose unused bits of an object address to store an index to the table entry.
1. A system, comprising:
a memory device that stores computer executable components; and
a processor that executes the computer-executable components stored in the memory device, wherein the computer executable components comprise:
a check component that:
intercepts an instruction comprising an object pointer, wherein the object pointer comprises first bits specifying an address of an object, and second bits specifying an index to an entry in a table, and wherein the entry in the table comprises bounds-information for the object; and
executes bounds-checking to validate the address according to the bounds-information by extracting the index from the object pointer to access the bounds-information for comparison against the address to determine whether the address is valid.
2. The system of claim 1 , further comprising:
a re-purpose component that:
determines unused bits of the object pointer specifying the address of the object, and
writes, in the unused bits, the index to the entry in the table, resulting in the second bits.
3. The system of claim 1 , wherein the bounds-checking comprises determining whether an array reference is in-bounds or out-of-bounds.
4. The system of claim 3 , wherein the bounds-checking further comprises, in response to determining that the array reference is out-of-bounds mitigating a potential memory error that would result from the array reference is out-of-bounds.
5. The system of claim 1 , further comprising a propagation component that propagates the second bits when the object pointer is copied in an assignment statement.
6. The system of claim 1 , further comprising a propagation component that propagates the second bits when the object pointer is passed as an argument in a function call.
7. The system of claim 1 , further comprising a propagation component that propagates the second bits when the object pointer is used to compute another address.
8. A computer-implemented method, comprising:
intercepting, by a processor, an instruction comprising an object pointer, wherein the object pointer comprises first bits specifying an address of an object, and second bits specifying an index to an entry in a table, and wherein the entry in the table comprises bounds-information for the object; and
executing, by the processor, bounds-checking to validate the address according to the bounds-information by extracting the index from the object pointer to access the bounds-information for comparison against the address to determine whether the address is valid.
9. The computer-implemented method of claim 8 , further comprising:
determining, by the processor, unused bits of the object pointer specifying the address of the object; and
writing, by the processor, in the unused bits, the index to the entry in the table, resulting in the second bits.
10. The computer-implemented method of claim 8 , wherein the bounds-checking comprises determining whether an array reference is in-bounds or out-of-bounds.
11. The computer-implemented method of claim 10 , wherein the bounds-checking further comprises, in response to determining that the array reference is out-of-bounds mitigating a potential memory error that would result from the array reference is out-of-bounds.
12. The computer-implemented method of claim 8 , further comprising propagating, by the processor, the second bits when the object pointer is copied in an assignment statement.
13. The computer-implemented method of claim 8 , further comprising propagating, by the processor, the second bits when the object pointer is passed as an argument in a function call.
14. The computer-implemented method of claim 8 , further comprising propagating, by the processor, the second bits when the object pointer is used to compute another address.
15. A computer program product comprising a non-transitory computer readable medium having program instructions embodied therewith, the program instructions executable by a processor to cause the processor to:
intercept, by the processor, an instruction comprising an object pointer, wherein the object pointer comprises first bits specifying an address of an object, and second bits specifying an index to an entry in a table, and wherein the entry in the table comprises bounds-information for the object; and
execute, by the processor, bounds-checking to validate the address according to the bounds-information by extracting the index from the object pointer to access the bounds-information for comparison against the address to determine whether the address is valid.
16. The computer program product of claim 15 , wherein the program instructions executable by the processor further cause the processor to:
determine, by the processor, unused bits of the object pointer specifying the address of the object; and
write, by the processor, in the unused bits, the index to the entry in the table, resulting in the second bits.
17. The computer program product of claim 15 , wherein the bounds-checking comprises determining whether an array reference is in-bounds or out-of-bounds.
18. The computer program product of claim 15 , wherein the program instructions executable by the processor further cause the processor to propagate the second bits when the object pointer is copied in an assignment statement.
19. The computer program product of claim 15 , wherein the program instructions executable by the processor further cause the processor to propagate the second bits when the object pointer is passed as an argument in a function call.
20. The computer program product of claim 15 , wherein the program instructions executable by the processor further cause the processor to propagate the second bits when the object pointer is used to compute another address.