# US 10,120,745 B2 · Providing instructions to protect stack return addresses in a hardware managed stack architecture

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 10,120,745 B2
- Document ID: US10120745B2
- Status: Granted
- Kind: B2
- Application number: 14/989,459
- Filed: 2016-01-06
- Published: 2017-07-06
- Granted: 2018-11-06
- Earliest claimed: 2016-01-06
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Karl J. Duvalsaint; Michael K. Gschwind; Valentina Salapura
- Web page: https://patentgrep.com/patent/US10120745B2

## CPC

- G06F 9/30076: {to perform miscellaneous control operations, e.g. NOP}
- G06F 9/3004: {to perform operations on memory}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Corruption of program stacks is detected by using guard words placed in the program stacks. An instruction, which is to be used in protecting stacks of a computing environment, is provided in a called routine, based on determining that the called routine is to include logic to detect corruption of stacks. The instruction in the called routine is to check a guard word provided by a calling routine to determine whether a stack is corrupt.

## Claims

### Claim 1

A computer program product for facilitating detection of corruption of stacks of a computing environment, said computer program product comprising:
a non-transitory computer readable storage medium readable by a processing circuit and storing instructions for execution by the processing circuit for performing a method comprising:
determining that a called routine executing on a processor of the computing environment is to include logic to detect corruption of stacks; and
providing, based on determining that the called routine is to include logic to detect corruption of stacks, an instruction in the called routine to check a guard word provided by a calling routine, the calling routine having called the called routine, and the guard word being stored in a stack by the calling routine and protecting a return address stored directly into the stack by a hardware instruction, the guard word being stored in the stack at a location between a stack frame of the calling routine and a stack frame of the called routine, the stack frame of the calling routine and the stack frame of the called routine being a part of the stack.

### Claim 2 (depends on 1)

The computer program product of claim 1, wherein the instruction in the called routine is further to determine, based on checking the guard word, whether the guard word has an expected value, wherein based on the guard word having an unexpected value, an indication of corruption of the stack is provided.

### Claim 3 (depends on 1)

The computer program product of claim 1, wherein the providing the instruction in the called routine comprises:
generating a sequence of operations; and
writing, using a selected processor, the sequence of operations to a module to be executed.

### Claim 4 (depends on 3)

The computer program product of claim 3, wherein the method further comprises providing the module to a linker to prepare the module for execution.

### Claim 5 (depends on 1)

The computer program product of claim 1, wherein the providing the instruction in the called routine comprises:
generating a sequence of operations; and
storing, using a selected processor, the sequence of operations in a location to be accessed to execute the sequence of operations.

### Claim 6 (depends on 1)

The computer program product of claim 1, wherein the providing the instruction in the called routine includes inserting the instruction in the called routine, the instruction in the called routine to obtain the guard word from the stack, move a stack pointer of the stack such that the guard word no longer appears on the stack, and perform the checking.

### Claim 7 (depends on 6)

The computer program product of claim 6, wherein the instruction in the called routine is further to determine, based on checking the guard word, whether the guard word has an expected value, wherein based on the guard word having an unexpected value, an indication of corruption of the stack is provided.

### Claim 8 (depends on 1)

The computer program product of claim 1, wherein the method further comprises providing an instruction to provide the guard word on the stack, the instruction to provide the guard word specifying an address for the guard word.

### Claim 9 (depends on 1)

The computer program product of claim 1, wherein the providing the instruction to provide the guard word comprises inserting the instruction to provide the guard word in the calling routine.

### Claim 10

A computer system for facilitating detection of corruption of stacks of a computing environment, said computer system comprising:
a memory; and
a processor in communication with the memory, wherein the computer system is configured to perform a method, said method comprising:
determining that a called routine executing on a processor of the computing environment is to include logic to detect corruption of stacks; and
providing, based on determining that the called routine is to include logic to detect corruption of stacks, an instruction in the called routine to check a guard word provided by a calling routine, the calling routine having called the called routine, and the guard word being stored in a stack by the calling routine and protecting a return address stored directly into the stack by a hardware instruction, the guard word being stored in the stack at a location between a stack frame of the calling routine and a stack frame of the called routine, the stack frame of the calling routine and the stack frame of the called routine being a part of the stack.

### Claim 11 (depends on 10)

The computer system of claim 10, wherein the providing the instruction in the called routine comprises:
generating a sequence of operations; and
writing the sequence of operations to a module.

### Claim 12 (depends on 11)

The computer system of claim 11, wherein the method further comprises providing the module to a linker to prepare the module for execution.

### Claim 13 (depends on 10)

The computer system of claim 10, wherein the providing the instruction in the called routine comprises:
generating a sequence of operations; and
storing the sequence of operations in a location to be accessed to execute the sequence of operations.

### Claim 14 (depends on 10)

The computer system of claim 10, wherein the providing the instruction in the called routine includes inserting the instruction in the called routine, the instruction in the called routine to obtain the guard word from the stack, move a stack pointer of the stack such that the guard word no longer appears on the stack, and perform the checking.

### Claim 15 (depends on 10)

The computer system of claim 10, wherein the method further comprises providing an instruction to provide the guard word on the stack, the instruction to provide the guard word specifying an address for the guard word.

### Claim 16

A computer-implemented method of detecting corruption of stacks of a computing environment, said computer-implemented method comprising:
determining that a called routine executing on a processor of the computing environment is to include logic to detect corruption of stacks; and
providing, based on determining that the called routine is to include logic to detect corruption of stacks, an instruction in the called routine to check a guard word provided by a calling routine, the calling routine having called the called routine, and the guard word being stored in a stack by the calling routine and protecting a return address stored directly into the stack by a hardware instruction, the guard word being stored in the stack at a location between a stack frame of the calling routine and a stack frame of the called routine, the stack frame of the calling routine and the stack frame of the called routine being a part of the stack.

### Claim 17 (depends on 16)

The computer-implemented method of claim 16, wherein the providing the instruction in the called routine comprises:
generating a sequence of operations; and
writing the sequence of operations to a module to be executed.

### Claim 18 (depends on 17)

The computer-implemented method of claim 17, wherein the method further comprises providing the module to a linker to prepare the module for execution.

### Claim 19 (depends on 16)

The computer-implemented method of claim 16, wherein the providing the instruction in the called routine comprises:
generating a sequence of operations; and
storing the sequence of operations in a location to be accessed to execute the sequence of operations.

### Claim 20 (depends on 1)

The computer program product of claim 1, wherein the guard word, written once in the stack, is used by a plurality of called routines to detect corruption of the stack.
