Profiling
By analyzing the uniqueness of the control flow path segments in computer software and optimizing the analysis behavior, the problems of high detection difficulty and high resource consumption in the prior art are solved, and the efficiency and security of attack detection are improved.
Patent Information
- Application Number
- CN202280094084.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-03-31
- Filing Date
- 2022-12-22
- Publication Date
- 2024-11-15
AI Technical Summary
When the prior art detects that the control flow paths in computer software are vulnerable to attack, it is difficult to distinguish between legal and illegal control flow paths, resulting in an increase in the chances of hiding by attackers, and the analysis process is resource-intensive, which complicates detection.
Through data processing devices and methods, multiple interconnection instructions are stored and analyzed to determine the uniqueness of the analysis measurement of the control flow path segment. The compilation circuit is used to insert the insertion instructions, and the use of the performance monitoring unit is used to measure the resource, and the analysis start and end are determined. Point to optimize uniqueness.
It improves the intelligent judgment ability of attack behavior, reduces the possibility of attack hiding, reduces the use of analysis resources, and enhances computer security.
Smart Images

Figure CN118974728A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to data processing. Background Art
[0002] Profiling can be used to identify control flow paths (e.g., sequences of actions) that allow attackers to exploit vulnerabilities in computer software. For example, if a particular sequence of actions or control flow path is found to be vulnerable, profiling can be performed to perform specific measurements on the sequence of actions. Then, in the future, by performing the profiling again and performing the same measurements, it may be possible to determine whether an attack is occurring. One difficulty with this approach is that the measurements performed via profiling may not be unique for the vulnerable control flow path. In this case, a completely legitimate control flow path may look like an attack. This is particularly advantageous for attackers because it creates a large attack surface to work on. In fact, the lower the uniqueness of each measurement of the control flow, the more opportunities the attacker has to remain hidden, and similarly, the more unique each control flow is, the easier the attack is to be detected. In other words, for any possible attack that diverts from the known structure of the program (executing code that does not exist in the binary) or sequentially exploits the existing structure of the program, it becomes increasingly difficult for the attacker to remain undetected. Generally speaking, profiling is resource intensive, which further complicates detection. Therefore, it is desirable to limit profiling where possible. Summary of the invention
[0003] From a first example configuration, a data processing apparatus is provided, the data processing apparatus comprising: a storage circuit configured to store a plurality of instructions, wherein the plurality of instructions are interconnected; and an analysis circuit configured to analyze the plurality of instructions to determine a degree of uniqueness of profile measurements of a plurality of control flow path segments within the plurality of instructions.
[0004] From a second example configuration, a data processing method is provided, the method comprising: storing a plurality of instructions, wherein the plurality of instructions are interconnected; and analyzing the plurality of instructions to determine a degree of uniqueness of profiling measurements of a plurality of control flow path segments within the plurality of instructions.
[0005] From a third example configuration, a non-transitory storage medium is provided that stores a computer program that, when executed, analyzes a plurality of interconnect instructions to determine a degree of uniqueness of profiling measurements of a plurality of control flow path segments within the plurality of interconnect instructions. BRIEF DESCRIPTION OF THE DRAWINGS
[0006] The present invention will now be further described, by way of example only, with reference to embodiments of the invention as shown in the accompanying drawings, in which:
[0007] Figure 1 A system including a data processing apparatus according to some embodiments is illustrated;
[0008] FIG. 2A to FIG. 2D The process of determining the degree of uniqueness of edges in a control flow graph is illustrated;
[0009] Figure 3 illustrates the tradeoffs in where to perform instrumentation; and
[0010] Figure 4 The whole process is shown in the form of a flow chart. DETAILED DESCRIPTION
[0011] Before discussing the embodiments with reference to the drawings, the following description of the embodiments is provided.
[0012] According to one example configuration, a data processing apparatus is provided, the data processing apparatus comprising: a storage circuit configured to store a plurality of instructions, wherein the plurality of instructions are interconnected; and an analysis circuit configured to analyze the plurality of instructions to determine a degree of uniqueness of profiling measurements of a plurality of control flow path segments within the plurality of instructions.
[0013] A plurality of instructions may constitute a program or a part of a program, such as a library or a module. These instructions are interconnected with each other. In particular, this interconnection may be the result of instructions having a particular order so that the instructions are executed in a linear sequence and / or the result of an explicit redirection that causes the flow to continue in a nonlinear manner. A plurality of control flow path fragments exist within an instruction. For example, a control flow path fragment may represent a subset of instructions that follow a theoretical flow through those instructions. These control flow path fragments do not need to start at the top basic block, nor do they need to end at the last basic block. Instead, they may represent a subset of the execution of a program. Profiling measurements corresponding to control flow path fragments may be performed. These may, for example, represent specific statistics or resource usage associated with instructions that constitute the control flow path fragments. The determination of these profiling measurements does not necessarily require the execution of control flow path fragments (although in some cases it may be performed). The analysis circuit determines the degree of uniqueness of the measurement for some control flow path fragments. It is not necessary to analyze all possible control flow path fragments, and in some cases, only a subset of all possible control flow path fragments is considered. By determining the uniqueness of a particular control flow path segment, it is possible to make more intelligent decisions about how, where, and when profiling should occur to best capture behavior corresponding to an attack. For example, performing profiling on a control flow path segment that is executed as part of every single control flow path (e.g., an initialization routine at the start of a program) may be of little benefit because it provides little or no information about which control flow path is being executed. For example, the determination of control flow path segments may be made with reference to a control flow graph.
[0014] In some examples, the degree of uniqueness of a given profiling measurement is derived relative to the number of ways that the given profiling measurement is produced from different combinations of instructions. If a control flow path segment produces a given profiling measurement, the uniqueness indicates how many other ways produce that same profiling measurement. For example, if the profiling measurement represents resource usage, the uniqueness indicates how many ways (using different combinations of instructions) produce that exact same resource usage. If the only way to produce that resource usage is the actual set of instructions associated with the control flow path segment, then the profiling measurement is unique. In other words, in order to obtain the profiling measurement, the exact control flow path segment must be followed. If many other combinations of instructions will produce the same resource usage, then the profiling measurement will have relatively low uniqueness.
[0015] In some examples, multiple instructions are divided into multiple basic blocks, each basic block includes a continuous subset of multiple instructions; and multiple basic blocks are interconnected using control flow instructions. Control flow instructions can be considered as instructions that enable (but not necessarily force) control flow to stay away from a non-linear sequence. This can include (unconditional or conditional) branch instructions. Basic blocks can then be considered as instructions executed as a result of following a specific control flow instruction, or alternatively, as all instructions between sequence control flow instructions. For example, a function without branch instructions can be considered as a single basic block. If the function contains a single IF statement, the function can be composed of three basic blocks-instructions before the IF statement, instructions executed when the IF statement is applicable, and instructions executed when the IF statement is not applicable. The fourth basic block can be composed of instructions that are executed once the IF statement is parsed (or in fact, some of these blocks can be merged).
[0016] In some examples, each control flow path segment in the control flow path segment is defined by a set of control flow instructions. Thus, a segment can be a sequence of instructions (e.g., those in a basic block) connected together by multiple control flow instructions. The segment maintains the linearization of instructions mentioned previously. That is, the segment is not a completely arbitrary collection of unrelated basic blocks.
[0017] In some examples, the profiled measurements are measurements of a performance monitoring unit. A performance monitoring unit (PMU) is a device used to collect various metrics about the operation of a processor and its memory system during runtime. PMU measurements can be estimated offline via static analysis of the code or code introspection.
[0018] In some examples, the profiling measurements include one or more of the following: the number of instructions executed, the number of instructions, the number of control flow instructions taken, and the number of control flow instructions. The number of instructions executed can be the number of instructions executed within a control flow segment, which may be different from the number of instructions actually within the control flow segment (e.g., due to microarchitectural optimizations). The number of control flow instructions encountered may also be different from the number of control flow instructions taken (or not taken) because not all control flow instructions are taken, such as in the case of conditional branch instructions.
[0019] In some examples, the data processing device includes a compilation circuit that is configured to perform a compilation of multiple instructions to produce a compilation output, wherein the compilation output includes an instrumented instruction that causes a profiling measurement to be performed when executed. The compilation process typically takes instructions provided in one language and translates those instructions into another "language". For example, a compiler may translate instructions provided in C into machine code for execution on a processor. In these examples, the compilation circuit is also designed to insert instrumented instructions. These are instructions that cause profiling measurements to be performed between specific points in the remainder of the compiled code. For example, as already described, such profiling measurements can be performed using a PMU. In this way, profiling behavior (which can be resource-intensive) can be limited.
[0020] In some examples, the compilation is a just-in-time compilation. In a just-in-time (JIT) compiler, at least some of the compilation occurs at execution time. This can be achieved by performing an initial (non-JIT) compilation to convert the initial source code into byte code that can be more easily converted into machine code at execution time. In the case of using a control flow graph to determine the control flow path segments, for example, this can be obtained during the first or second stage of compilation.
[0021] In some examples, the analysis circuitry is configured to determine a profiling start point and a profiling end point based on a degree of uniqueness of profiling measurements of a plurality of control flow path segments within a plurality of instructions. There are a variety of ways to determine the points at which profiling should be performed. However, in these examples, the uniqueness of the profiling measurements is taken into account. For example, these points may be selected to maximize, optimize, or simply improve the uniqueness of the profiling measurements compared to other possible placements of the profiling measurement instructions.
[0022] In some examples, the analysis circuit is configured to determine the profiling start point and the profiling end point by determining a tradeoff between the distance between the profiling start point and the profiling end point, and the degree of uniqueness of the profiling measurements of multiple control flow path fragments within multiple instructions. The distance can be measured as the number of instructions (all instructions or instructions of a specific type). When measuring the distance in this way, the number of instructions can be considered to be the minimum, maximum or average number of such instructions that may be encountered between the profiling start point and the end point (depending on the specific control flow path taken between the profiling start point and the end point). Alternatively, the distance can be measured as the amount of time or the number of processor cycles that pass between the profiling start point and the end point. The tradeoff experienced in these examples is that as the distance between the profiling start point and the profiling end point increases, the uniqueness of the measurement of each control flow path fragment increases-because there are more opportunities for deviation. However, the length of time that the profiling exists also increases, which may lead to increased resource usage. Therefore, the goal of the tradeoff is to select an acceptable point with a small distance and a large degree of uniqueness. By having a large degree of uniqueness, it can be said with greater confidence whether a specific control flow path fragment is being executed based on the profiling measurement. In some examples, a trade-off optimization may be determined. In other examples, the optimization may be a statistical optimization that indicates a solution is particularly good but may not be the best.
[0023] In some examples, the control flow path segments are selected by random sampling. In some of these examples, the random sampling is unbiased random sampling. For example, if the control flow path segments are selected to always start at the beginning of multiple instructions, there will be a clear preference for earlier instructions (rather than later instructions).
[0024] In some examples, the analysis circuit has a restricted operating mode in which at least one of the control flow path segments cannot be reached by the execution of the plurality of instructions; and the analysis circuit has a full operating mode in which the control flow path segment is selected regardless of whether the control flow path segment can be reached during the execution of the instruction. Thus, in the restricted operating mode, at least one of the control flow path segments cannot be reached by the ordinary (linear) execution of the instruction. That is, if the instruction is actually to be executed, the control flow cannot pass along one of the control flow path segments. This may occur, for example, in a simplified example where the instruction expresses the code "IF (true) then X, otherwise Y". In this case, X will always be executed because the IF statement will always be found to be true. During execution, it is impossible to reach code Y via the IF statement. However, in the control flow graph, the graph may still represent it as a branch point; and when selecting a control flow path segment, the restricted operating mode will allow such a control flow path segment to be selected (even if it indicates that execution is impossible). This helps to reduce or eliminate preferences in control flow segments. However, it also allows the profiling of control flow paths that, although theoretically impossible, may be reached if a malicious third party were to interfere with instruction execution (e.g., as part of a buffer overflow attack). In full operational mode, control flow path segments may or may not include such scenarios.
[0025] Specific embodiments will now be described with reference to the accompanying drawings.
[0026] Figure 1 A system 100 including a data processing apparatus 110 according to some embodiments is illustrated. The data processing apparatus 110 includes a storage circuit 150 for storing a plurality of instructions. The instructions are interconnected with each other. This may be a result of the ordering of the instructions within the plurality of instructions (i.e., so that the instructions are executed in a linear sequence) and / or a result of control flow instructions such as branch instructions. The instructions are considered by analysis circuitry 130. Analysis circuitry 130 is used to determine a set of insertion points within the instructions. The insertion points and the instructions may then be provided to compile circuitry 140. Compile circuitry 140 generates a set of compiled / inserted instructions.
[0027] The compile / insert instructions may be provided to a second data processing device 120 having a processor 160 that executes the compile / insert instructions. A performance monitoring unit 170 (sometimes also referred to as a performance measurement unit) is provided to perform performance monitoring. In particular, performance monitoring is enabled / disabled / updated by an instrumentation point within the compile / insert instructions.
[0028] The performance monitoring unit 170 typically reduces the speed at which the processor 160 operates. In fact, in some examples, the performance monitoring unit 170 can be the processor 160 itself, and the performance monitoring can be performed by software executing on the processor. The compiled instructions can be executed, for example, within a virtual machine executing on the processor 160, which is accessible to the performance monitoring software running on the processor 160. In any case, the performance monitoring unit is configured to monitor, for example, execution statistics and / or resource usage consumed during the execution of instructions when performance monitoring is enabled. In the examples that will be discussed in the remainder of this specification, the two statistics monitored are the total number of instructions encountered and the number of branch instructions encountered.
[0029] It is desirable that the statistics provided by the performance monitoring unit 170 be as unique as possible for each control flow path. In particular, if there is a one-to-one mapping between the statistics and the control flow path, the control flow path taken may be identified by taking a set of measurements from the performance monitoring unit 170. This is particularly useful with respect to computer security. For example, if it is later discovered that a specific control flow path is part of an attack vector in a computer system, the performance monitoring statistics associated with the control flow path can be determined and used as a signature for detecting similar future attacks. If the performance monitoring statistics are unique to the control flow path, this identification is very useful. This uniqueness attribute gives credibility to the integrity of the baseline behavior of the program, and deviations from the baseline can be inferred as anomalies. As uniqueness increases, attacks become more difficult to hide because it is difficult for attackers to find legitimate control flow paths that will produce performance monitoring statistics that match attack vectors.
[0030] Instrumentation points are added to enable performance monitoring to occur on a set of instructions where the uniqueness of the control flow path is considered good.
[0031] The data processing apparatus 110 and the second data processing apparatus 120 may be the same device - for example if just-in-time compilation is being performed.
[0032] FIG. 2A to FIG. 2D The process of determining the degree of uniqueness of edges in a control flow graph is illustrated. A control flow graph can be generated by treating a set of instructions (representing a program or a portion of a program) as a series of interconnected basic blocks. A basic block is a set of consecutive instructions divided by control flow instructions (e.g., branch instructions). Therefore, a control flow graph is generated by representing basic blocks as vertices and edges as control flow instructions (e.g., branches). Each basic block contains multiple instructions, which are indicated as the values of the vertices. Edges represent possible locations (basic blocks) to which a control flow instruction can go from another basic block. For example, a control flow graph can be derived by analyzing the code of a program.
[0033] Figure 2AAn initial control flow graph is shown. The first basic block 200 contains 3 instructions. The control flow instruction then enables the control flow to move to the second basic block 210 of four instructions or the third basic block 220 of two instructions. In any case, the control flow instruction then causes the control flow to be passed to the fourth basic block 230 of five instructions. Finally, another control flow instruction enables the flow to be passed to the fifth basic block 240 of three instructions or the sixth basic block 250 of two instructions. Among them, the sixth basic block 250 has a loop that returns to the earlier instruction block 220, that is, a reverse loop. The first step is to remove the reverse loop in the control flow graph, through which the node 250 returns to the previous node 220. This is achieved by modifying the edge 235 that defines the reverse loop to point to a new virtual node of the initial target (endpoint) 220 of the reference edge 235.
[0034] It should be appreciated that in this simple example, there are now four possible control flow paths. Note that in practice, some of these paths may not be possible. For example, a path between the first basic block 200 and the third basic block 220 may technically be allowed according to the instruction, but during execution, the path will never actually be taken. For example, if the control flow instruction linking the first basic block 200 to the second basic block 210 and the third basic block 220 essentially states that if x is greater than 15, the control flow should be passed to the second block 210, and if x is less than 15, the control flow should be passed to the third block 220, then in theory either path can be followed. However, if the final instruction of the first basic block 200 is "x=300", then in practice, the flow to the third basic block 220 will never actually be taken. Depending on the operating mode of the data processing device 110, such control flow paths may or may not be allowed, as will be discussed in more detail below.
[0035] Figure 2B The selection of three control flow path fragments on a modification graph containing virtual node 237 is illustrated. A control flow path fragment is at least a portion of a control flow path. The fragment need not start at the top basic block, nor need it end at the last basic block. A control flow path fragment may be an entire control flow path, or may be only a sub-segment of such a path. Control flow path fragments are randomly sampled (e.g., via the technique described in https: / / math.stackexchange.com / questions / 2673132 / a-procedure-for-sampling-paths-in-a-directed-acyclic-graph / 2676725).
[0036] In some embodiments, the random sampling of control flow path segments may be limited to segments of a certain length. If so, and if the randomly sampled control flow path segment exceeds that length, another segment is randomly sampled. If the randomly sampled control flow path segment ends with a dummy node (e.g., a dummy node added to eliminate a reverse loop), a target reference node (which is associated with the added dummy node) may be added to the end of the segment (as long as it does not exceed the length limit). If there are multiple possibilities for the target reference node, one may be randomly picked.
[0037] Note that in some embodiments, the length limit is not a hard limit, and small deviations from it may be allowed, for example if a randomly sampled control flow path segment ends with one of the virtual nodes.
[0038] Figure 2B Three randomly sampled (control flow) path fragments—paths A, B, and C—are illustrated in FIG.
[0039] Figure 2C The formula for determining the probability (i.e., the inverse of uniqueness) that two control flow path segments produce the same measurement is shown. This can be expressed as follows:
[0040]
[0041] In this example, two measurements are made: the number of instructions encountered across basic blocks, and the number of branch instructions encountered. In other embodiments, the number of executed instructions and the number of executed branch instructions may be considered. In other embodiments, additional or alternative measurements may be considered.
[0042] The number of possible control flow path fragments that produce the same measurement is combinatorial:
[0043]
[0044] Where n is the number of elements (instructions and branches) in the basic blocks that make up the path segment, and b is the number of branch instructions within the path segment. Thus, for a segment containing 18 non-branch instructions and four branch instructions, there are:
[0045]
[0046] Each of those control flow path segments will produce the same measurements.
[0047] Since two measurements are taken, the number of possible control flow path fragments is
[0048] 2 n
[0049] That is, each of the n elements can be a branch instruction or another instruction. If three measurements are taken, the formula would simply be 3 n , and so on.
[0050] The matching probability of path segment X is then:
[0051]
[0052] Figure 2C The calculation of the uniqueness for each of the control flow path segments A, B, and C is shown. For path A, this is 91 / 2 14 , for path B, this is 560 / 2 16 , while for path C this is 55 / 2 11 In practice, the order from lowest to highest uniqueness is therefore C, B, and A.
[0053] The random sampling process can be performed until each edge appears at least once (assuming all edges are reachable) or can be performed a fixed number of times.
[0054] Each edge is then weighted based on these calculations. There are many ways to implement this. However, in this example, assume that each matching probability P m are independent. Therefore, the weight of each edge is equal to the sum of the matching probabilities of all sampled paths that the edge is in. An empty edge (if any) can simply take the probability of its nearest neighbor edge (or from its parent edge) that has a value.
[0055] Figure 2D An example of such a calculation is shown in FIG. 2. For example, for edge 260 that is located only on path segment A, the value of the edge is equal to P mA In contrast, for edge 270 that is on both path segment B and path segment C, the value of the edge is equal to P mB +P mC The weight of an edge thus represents the probability that the edge is unique to a path segment.
[0056] Note that instead of calculating each fraction, one can consider only the numerator and then perform normalization of each weight by scaling it according to the largest denominator.
[0057] After calculating the weight of each edge, the control flow graph reconnects any reverse loops, such as by eliminating the originally created virtual nodes 237 and restoring the removed edges 235.
[0058] The next step is to use the calculated edge weights to determine the instrumentation points. Instrumentation points are used to indicate points in the compiled instructions that are to be profiled, for example, by the execution data processing device 120. For example, Ball and Larus in "Efficient Path Profiling" (Proceedings of the 29 th The technique described in the annual ACM / IEEE international symposium on Microarchitecture can achieve the determination of the insertion point. This technique "consumes" FIG. 2A to FIG. 2D The edge weights calculated in order to determine where to place the instrumentation points. Additionally, the edge or basic block is assigned a value that can be used to uniquely identify the path taken through the graph. This is different from the previously calculated weights. Figure 3 A simplified example of these values is shown. During profiling, a running total of the values passed through each edge is maintained. By carefully assigning the values, it is possible to uniquely identify a control flow path based on the running total produced. One way to do this is to assign a different power of 2 to each edge. However, Ball and Larus also describe another technique that may be more effective for uniquely identifying a path.
[0059] like Figure 3 As shown, there is a tradeoff in where to place the instrumentation points (i.e., where the analysis starts and ends). In Figure (A), the instrumentation points are placed at N 1 and N 7 , so that the profiling is performed across the entire program, and it is therefore possible to uniquely identify paths or path fragments - no two control flow paths or control flow path fragments will produce exactly the same total, as for N 1 To N 7 , which is shown in the table encoding each possible control flow path of . However, profiling is typically a resource-intensive activity, so profiling across the entire program is undesirable, even though it would allow one to determine the exact control flow path that has been taken. Instead, in Figure (B) (where the edges of the unmeasurable paths have been removed for clarity), instrumentation points are placed at N 4 and N 5 , so that only one control flow instruction (with edge value '16') is profiled. Resource usage is thus kept low. However, it is almost impossible to determine which control flow path was taken because, when activated, profiling will produce the same total (16) for each control flow path. Therefore, for path N 1 N 2 N 6 N 7 No encoding is generated because it does not follow the edge (N 4 , N 5 ) is transmitted. At the same time, for1 To N 7 Every other path of produces the same encoding (16).
[0060] More generally, as the scope of execution profiling decreases, the uniqueness of control flow paths also decreases. Going back to the above, the more unique each control flow path is, the easier it is to identify attack vectors in the program, and the harder it is for a potential attacker to identify hard-to-find attack vectors because such vectors will stand out.
[0061] It is therefore desirable to limit the scope of execution profiling while maintaining control flow paths as unique as possible. As mentioned earlier, Ball and Larus in “Efficient Path Profiling” (Proceedings of the 29 th The technique presented in Section 3.3 of the annual ACM / IEEE international symposium on Microarchitecture can be used to find suitable locations for the insertion points. Briefly, the algorithm can be implemented as follows:
[0062] ●Determine the maximum spanning tree of the control flow graph
[0063] ●For each edge 'E' that is not in the maximum spanning tree:
[0064] ○ Add edge E to form a loop
[0065] ○ The edge weight of each edge that forms the cycle (previously using the matching probability P m Calculation, for example Figure 2D ) are added together to produce S
[0066] ○ Assign the value of S to edge E
[0067] ○ Label each edge on the loop
[0068] ○ Remove edge E
[0069] ● Set the edge weight of each marked edge to 0
[0070] • Re-add all edges E that were not part of the initial spanning tree.
[0071] In effect, the weights of the edges in the maximum spanning tree (which are based on matching probabilities) are thereby "migrated" to the remaining edges. A highly accurate determination of path (segment) uniqueness can then be determined by adding instrumentation points to cover each edge with a non-zero weight. The edges with the lowest scores are the least useful in identifying control flow paths, and those below a certain threshold can be eliminated from the profiling process. Note that there can be multiple sets of instrumentation points - for example, if the weighted edges are far apart.
[0072] Figure 4 The entire process is shown in the form of a flowchart 400. In step 410, the control flow path segments are randomly sampled. In step 420, the uniqueness of each randomly sampled control flow path segment is calculated, for example, Figure 2C In step 430, weights are assigned to the edges. This assignment is based on the edge weights calculated in step 420 and the frequency with which each edge appears in the randomly sampled control flow path segments. For example, Figure 2D . In step 440, an insertion point is selected based on the uniqueness (edge weight) assigned to the edge. This can be achieved using the Ball and Larus technique described above. Once the insertion points are determined, these calculated edge weights can be discarded. The initial instruction set can then be modified in step 450 so that PMU profiling is performed between the insertion points. This can be achieved by adding the edge value to a running total (e.g., in a register). After modifying the instructions in this way, the resulting instructions are then compiled in step 460.
[0073] The result is an instrumentation of the original instruction set. The instrumentation causes those parts of the control flow graph (i.e., those parts of the program) that are more useful in unambiguously identifying the control flow paths taken to be prioritized for profiling using the PMU. Thus, the scope of profiling performed can be limited while still performing enough profiling to optimally identify the control flow paths taken. To identify the control paths taken, the profiling performed can itself include summed edge values (e.g., maintained as a running total in a register). As previously described, the selection of instrumentation points is such that the amount of profiling performed is kept low, while the uniqueness of each control path (as identified by the PMU count of the running total) is kept high.
[0074] Thus, profiling is limited while making it harder for attackers to find good attack vectors, i.e., control flow paths that allow attacks and happen to look like other legitimate control flow paths. Thus, security is improved while resource usage is reduced.
[0075] In this application, the words "configured to..." are used to mean that elements of a device have a configuration that enables the performance of a defined operation. In this context, "configuration" means the arrangement or manner of interconnection of hardware or software. For example, the device may have dedicated hardware that provides the defined operation, or a processor or other processing device may be programmed to perform the function. "Configured to" does not mean that the device elements need to be changed in any way in order to provide the defined operation.
[0076] Although exemplary embodiments of the present invention have been described in detail herein in conjunction with the accompanying drawings, it should be understood that the present invention is not limited to those precise embodiments, and that various changes, additions and modifications may be implemented therein by those skilled in the art without departing from the scope and spirit of the present invention as defined in the appended claims. For example, the features of the dependent claims may be combined in various ways with the features of the independent claims without departing from the scope of the present invention.
Claims
1. A data processing device, comprising: a storage circuit configured to store a plurality of instructions, wherein the plurality of instructions are interconnected; and Analysis circuitry is configured to analyze the plurality of instructions to determine a degree of uniqueness of profiling measurements of a plurality of control flow path segments within the plurality of instructions.
2. The data processing apparatus according to claim 1, wherein The degree of uniqueness of a given profiling measure is derived relative to the number of ways in which the given profiling measure can be generated from different combinations of instructions.
3. The data processing apparatus according to claim 1, wherein The plurality of instructions are divided into a plurality of basic blocks, each basic block comprising a contiguous subset of the plurality of instructions; and The plurality of basic blocks are interconnected using control flow instructions.
4. The data processing apparatus according to claim 3, wherein Each of the control flow path segments is defined by a set of the control flow instructions.
5. The data processing apparatus according to claim 1, wherein The profiling measurements are measurements of the performance monitoring unit.
6. The data processing apparatus according to claim 1, wherein The profiling measurements include one or more of: a number of instructions executed, a number of instructions, a number of control flow instructions taken, and a number of control flow instructions.
7. The data processing device according to claim 1, comprising: Compilation circuitry is configured to perform compilation of the plurality of instructions to produce compilation output, wherein the compilation output includes instrumented instructions that, when executed, cause the profiling measurements to be made.
8. The data processing apparatus according to claim 7, wherein The compilation is a just-in-time compilation.
9. The data processing apparatus according to claim 1, wherein The analysis circuitry is configured to determine a profiling start point and a profiling end point based on the degree of uniqueness of the profiling measurements of the plurality of control flow path segments within the plurality of instructions.
10. The data processing apparatus according to claim 9, wherein The analysis circuit is configured to determine the profiling start point and the profiling end point by determining a tradeoff between: The distance between the profiling start point and the profiling end point, and The degree of uniqueness of the profiling measurements of the plurality of control flow path segments within the plurality of instructions.
11. The data processing apparatus according to claim 1, wherein The control flow path segments are selected by random sampling.
12. The data processing apparatus according to claim 1, wherein The analysis circuit has a restricted operating mode in which at least one of the control flow path segments is not reachable through execution of the plurality of instructions; and The analysis circuit has a full operating mode in which the control flow path segment is selected regardless of whether the control flow path segment can be reached during execution of the instruction.
13. A data processing method, the data processing method comprising: storing a plurality of instructions, wherein the plurality of instructions are interconnected; as well as The plurality of instructions are analyzed to determine a degree of uniqueness of profiling measurements of a plurality of control flow path segments within the plurality of instructions.
14. A non-transitory storage medium storing a computer program, wherein when the computer program is executed: A plurality of interconnect instructions are analyzed to determine a degree of uniqueness of profiling measurements of a plurality of control flow path segments within the plurality of interconnect instructions.
