You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/chp4/assure_stack_1.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,7 @@ Lets visualize how a code snippet uses the stack, to make the push/pop discussio
75
75
76
76
* We're interested in how this program uses stack memory at runtime, adding the attribute `#[inline(never)]` to ensure the compiler allocates a stack frame each time either `recursive_count_down` or `square` is called.
77
77
78
-
* "Inlining" is an opportunistic compiler optimization can avoids function call overhead, including stack frame allocation and caller-register preservation [^Inlining]. It's not always applicable and as programmer we don't directly decide where it is. So forgoing it is a realistic case to prepare for.
78
+
* "Inlining" is an opportunistic compiler optimization that avoids function call overhead, including stack frame allocation and caller-register preservation [^Inlining]. It's not always applicable and as programmer we don't directly decide where it is. So forgoing it is a realistic case to prepare for.
79
79
80
80
If run with `cargo run -- 2`, this program outputs:
Copy file name to clipboardExpand all lines: src/chp4/attack_1.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ Be it C, C++, or `unsafe` Rust.
80
80
81
81
For a more concrete discussion of memory and type safety, we'll examine three C snippets and visualize the violations therein. Note:
82
82
83
-
* None of the three snippets are, to the best our knowledge, *exploitable*. These small programs break safety, but not in manner unfortunate enough to enable a break of data-code isolation.
83
+
* None of the three snippets are, to the best our knowledge, *exploitable*. These small programs break safety, but not in amanner unfortunate enough to enable a break of data-code isolation.
84
84
85
85
This distinction is intensional.
86
86
We're starting by learning to identify bugs, even if innocuous.
Copy file name to clipboardExpand all lines: src/chp4/sw_stack_1.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,7 @@ Both topics are the subjects of entire technical books, so we'll visually diagra
69
69
</p>
70
70
71
71
Main memory, a physical machine's Random Access Memory (RAM), supports all non-trivial runtime computation.
72
-
The bit-patterns it stores and operates on representations two distinct items:
72
+
The bit-patterns it stores and operates on represent two distinct items:
73
73
74
74
***Data** - Variable-length sequences of bytes representing any information: hardcoded strings, colors codes, numbers, entire image and video files, etc. Each byte can be addressed individually, even if word-aligned accesses are often preferable for performance.
75
75
@@ -114,7 +114,7 @@ Fortunately, we don't have to consider or understand such minutia when programmi
114
114
The jobs of various registers are, by contrast, important for a working mental model.
115
115
In addition to the IP, the two special purpose registers worth noting are:
116
116
117
-
* The **Stack Pointer (`SP`)** register - the address denoting the bottom of the current stack frame. A stack frame is akin to function's in-RAM "notepad" for computing and saving *function-local* results.
117
+
* The **Stack Pointer (`SP`)** register - the address denoting the bottom of the current stack frame. A stack frame is akin to a function's in-RAM "notepad" for computing and saving *function-local* results.
118
118
119
119
* In the statement `let x = 3 + 6;`, `x` will be computed using registers, then the value `9` will be stored on the stack[^RegisterAlloc]. This allows the CPU to re-use its small, fixed set of `GP*` registers for new computations when multiple functions are called in a program.
120
120
@@ -185,7 +185,7 @@ It's important you commit it to memory, pun intended.
185
185
> The kernel runs in "ring 0", the most privileged mode available.
186
186
> It can read/write from/to any processes's memory, directly access hardware, and control special CPU features.
187
187
>
188
-
> Rings 2 and 3 are almost never used in practice[^RingProt].
188
+
> Rings 1 and 2 are almost never used in practice[^RingProt].
189
189
> These modes were intended for device drivers, special programs that allow a kernel to communicate with vendor-specific hardware.
190
190
> In reality most device drivers are loaded directly into the kernel, running alongside it in ring 0 (creating a major OS attack surface[^MSKernBlocklist]).
0 commit comments