# US 11,120,130 B2 · Method and apparatus for protecting kernel control-flow integrity using static binary instrumentation

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

- Number: US 11,120,130 B2
- Document ID: US11120130B2
- Status: Granted
- Kind: B2
- Application number: 16/367,530
- Filed: 2019-03-28
- Published: 2019-07-25
- Granted: 2021-09-14
- Earliest claimed: 2015-11-12
- Assignees: Samsung Electronics Co., Ltd.
- Applicants: Samsung Electronics Co., Ltd.
- Inventors: James Gleeson; Ahmed Azab; Wenbo Shen; Rohan Bhutkar
- Web page: https://patentgrep.com/patent/US11120130B2

## CPC

- G06F 21/556: {involving covert channels, i.e. data leakage between processes (inhibiting the analysis of circuitry or operation with measures against power attack G06F21/755)}
- G06F 21/125: {by manipulating the program code, e.g. source code, compiled code, interpreted code, machine code}
- G06F 21/57: Certifying or maintaining trusted computer platforms, e.g. secure boots or power-downs, version controls, system software checks, secure updates or assessing vulnerabilities
- G06F 8/41: Compilation
- G06F 2221/033: Test or assess software
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

An apparatus and a method for protecting kernel control-flow integrity using static binary instrumentation are provided. The method includes configuring a compiler to reserve a register in a processor, compiling source code into a binary based on the configured compiler, and modifying the binary to prevent exploits using the reserved register, wherein the reserved register stores a first encryption key for encrypting and decrypting return addresses. The reserved register stores an encryption key that is used to encrypt and decrypt return addresses to prevent control flow exploits.

## Claims

### Claim 1

A method of preventing kernel control flow integrity exploits, the method comprising:
configuring a compiler to reserve a register in a processor;
compiling source code into a binary based on the configured compiler; and
modifying one or more instructions in the binary to prevent exploits using the reserved register,
wherein the reserved register stores a first encryption key for encrypting and decrypting return addresses, and
wherein modifying the one or more instructions in the binary to prevent exploits comprises:
identifying certain instructions, among the one or more instructions, in the binary that copy a value of the reserved register into a memory; and
removing each of the identified instructions from the binary.

### Claim 2 (depends on 1)

The method of claim 1, wherein modifying the one or more instructions in the binary to prevent exploits comprises:
identifying a branch instruction in the binary;
inserting instructions into the binary to encrypt a return address of the identified branch instruction based on the first encryption key; and
inserting instructions into the binary to decrypt the return address of the identified branch instruction based on the first encryption key.

### Claim 3 (depends on 2)

The method of claim 2, wherein modifying the one or more instructions in the binary to prevent exploits further comprises:
identifying a transition point in the binary; and
inserting instructions into the binary to:
identify memory addresses based on the identified transition point,
decrypt return addresses at the identified memory addresses based on the first encryption key, and
encrypt the return addresses at the identified memory addresses based on a second encryption key.

### Claim 4 (depends on 3)

The method of claim 3, wherein the transition point comprises a kernel thread entry or a user thread entry.

### Claim 5 (depends on 3)

The method of claim 3, wherein modifying the one or more instructions in the binary to prevent exploits further comprises generating the second encryption key based on a cycle counter of the processor.

### Claim 6 (depends on 1)

The method of claim 1, wherein modifying the one or more instructions in the binary to prevent exploits comprises:
identifying an indirect branch instruction to a first address; and
inserting instructions into the binary to selectively execute a function associated with the first address.

### Claim 7 (depends on 6)

The method of claim 6, wherein modifying the one or more instructions in the binary to prevent exploits further comprises:
inserting an authentication sequence into the binary;
inserting an authentication function to authenticate the function based on the first address and the authentication sequence; and
replacing the identified indirect branch instruction with a direct branch instruction to the authentication function.

### Claim 8 (depends on 7)

The method of claim 7, wherein the authentication sequence is immediately before a start point of the function.

### Claim 9 (depends on 1)

The method of claim 1, wherein modifying the one or more instructions in the binary to prevent exploits comprises:
identifying a function in the source code; identifying a register to zero based on a number of arguments associated with the identified function; and
inserting instructions into the binary to zero the identified register in the identified function.

### Claim 10 (depends on 1)

The method of claim 1, wherein the binary comprises a kernel of an operating system.

### Claim 11 (depends on 1)

The method of claim 1, wherein modifying the one or more instructions in the binary to prevent exploits comprises:
identifying instructions, among the one or more instructions, that store and load a return address in a register within the binary;
inserting instructions into the binary to encrypt the register before the return address is stored to memory based on the first encryption key; and
inserting instructions into the binary to decrypt the register after the return address is loaded from memory based on the first encryption key.

### Claim 12

An electronic device comprising:
a memory configured to store data; and
a processor having at least one hardware register and configured to:
receive a compiler configuration to reserve a register in the processor,
compile source code into a binary based on the configured compiler, and
modify one or more instructions in the binary to prevent exploits using the reserved register,
wherein the reserved register stores a first encryption key for encrypting and decrypting return addresses, and
wherein, to modify the one or more instructions in the binary, the processor is further configured to:
identify instructions, among the one or more instructions, in the binary that copy a value of the reserved register into the memory, and
remove each of the identified instructions from the binary.

### Claim 13 (depends on 12)

The electronic device of claim 12, wherein, to modify the one or more instructions in the binary, the processor is further configured to:
identify a branch instruction in the binary,
insert instructions into the binary to encrypt a return address of the identified branch instruction based on the first encryption key, and
insert instructions into the binary to decrypt the return address of the identified branch instruction.

### Claim 14 (depends on 13)

The electronic device of claim 13, wherein, to modify the one or more instructions in the binary, the processor is further configured to:
identify a transition point in the binary, and
insert instructions into the binary to:
identify memory addresses based on the identified transition point,
decrypt return addresses at the identified memory addresses based on the first encryption key, and
encrypt the return addresses at the identified memory addresses based on a second encryption key.

### Claim 15 (depends on 14)

The electronic device of claim 14, wherein the transition point comprises a kernel thread entry or a user thread entry.

### Claim 16 (depends on 14)

The electronic device of claim 14, wherein, to modify the one or more instructions in the binary, the processor is further configured to generate the second encryption key based on a cycle counter of the processor.

### Claim 17 (depends on 12)

The electronic device of claim 12, wherein, to modify the one or more instructions in the binary, the processor is further configured to:
identify an indirect branch instruction to a first address, and
insert instructions into the binary to selectively execute a function associated with the first address.

### Claim 18 (depends on 17)

The electronic device of claim 17, wherein, to modify the one or more instructions in the binary, the processor is further configured to:
insert an authentication sequence into the binary,
insert an authentication function to authenticate the function based on the first address and the authentication sequence, and
replace the identified indirect branch instruction with a direct branch instruction to the authentication function.

### Claim 19 (depends on 18)

The electronic device of claim 18, wherein the authentication sequence is immediately before a start point of the function.

### Claim 20 (depends on 19)

The electronic device of claim 19, wherein, to modify the one or more instructions in the binary, the processor is further configured to:
identify a function in the source code,
identify a register to zero based on a number of arguments associated with the identified function, and
insert instructions into the binary to zero the identified register in the identified function.

### Claim 21 (depends on 12)

The electronic device of claim 12, wherein the binary comprises a kernel of an operating system.
