Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-21fa
project05b
Commits
9be87323
Commit
9be87323
authored
4 years ago
by
Caleb C. Sander
Browse files
Options
Download
Email Patches
Plain Diff
Add clang-format
parent
2f64e330
master
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
.clang-format
+15
-0
.clang-format
.githooks/pre-commit
+12
-0
.githooks/pre-commit
lib/util.c
+2
-1
lib/util.c
src/exploit.c
+4
-4
src/exploit.c
src/recover_local_secret.c
+2
-1
src/recover_local_secret.c
src/recover_protected_local_secret.c
+5
-5
src/recover_protected_local_secret.c
with
40 additions
and
11 deletions
+40
-11
.clang-format
0 → 100644
View file @
9be87323
---
# We'll use defaults from the Google style, but with 4 columns indentation.
BasedOnStyle: Google
# Never allow single-line functions
AllowShortFunctionsOnASingleLine: None
# Allow lines up to 90 characters
ColumnLimit: 90
# Indent each block by 4 spaces
IndentWidth: 4
TabWidth: 4
# Require 1 space before a comment on the same line
SpacesBeforeTrailingComments: 1
# Put a space after a cast, e.g. `(void) arg;`
SpaceAfterCStyleCast: true
---
This diff is collapsed.
Click to expand it.
.githooks/pre-commit
0 → 100755
View file @
9be87323
#!/bin/bash
if
loc
=
"
$(
type
-p
"clang-format"
)
"
&&
[[
-x
$loc
]]
;
then
for
name
in
$(
git diff
--cached
--name-only
--diff-filter
=
ACM
)
;
do
if
echo
$name
|
grep
-Eq
"
\.
[ch]$"
;
then
echo
"Formatting
${
name
}
..."
clang-format
-i
$name
fi
done
else
echo
"You do not have clang-format installed; so, we were unable to unify the formatting in your files."
fi
This diff is collapsed.
Click to expand it.
lib/util.c
View file @
9be87323
...
@@ -9,7 +9,8 @@ void force_read(const void *address) {
...
@@ -9,7 +9,8 @@ void force_read(const void *address) {
void
flush_cache_line
(
const
void
*
address
)
{
void
flush_cache_line
(
const
void
*
address
)
{
_mm_clflush
(
address
);
_mm_clflush
(
address
);
_mm_mfence
();
_mm_mfence
();
for
(
volatile
int
i
=
0
;
i
<
10000
;
i
++
)
{}
for
(
volatile
int
i
=
0
;
i
<
10000
;
i
++
)
{
}
}
}
uint64_t
time_read
(
const
void
*
address
)
{
uint64_t
time_read
(
const
void
*
address
)
{
...
...
This diff is collapsed.
Click to expand it.
src/exploit.c
View file @
9be87323
...
@@ -19,7 +19,7 @@ static inline void *get_kernel_data_address(void) {
...
@@ -19,7 +19,7 @@ static inline void *get_kernel_data_address(void) {
return
(
void
*
)
address
;
return
(
void
*
)
address
;
}
}
/* TODO: Copy your code from the previous stage and edit do_access().
// TODO: Copy your code from the previous stage and make the necessary edits to do_access()
* Note that this code WILL NOT WORK on compute-cpu2.
// Note that this code WILL NOT WORK on compute-cpu2.
You must push it to
g
it
l
ab to
get
it
to run
*
You must push it to
G
it
L
ab to
run
it
on one of the meltdown machines.
// on one of the meltdown machines.
*/
This diff is collapsed.
Click to expand it.
src/recover_local_secret.c
View file @
9be87323
...
@@ -30,7 +30,8 @@ static inline void do_access(page_t *pages, size_t secret_index) {
...
@@ -30,7 +30,8 @@ static inline void do_access(page_t *pages, size_t secret_index) {
int
main
()
{
int
main
()
{
page_t
*
pages
=
init_pages
();
page_t
*
pages
=
init_pages
();
// TODO: Copy me from the previous stage and edit me so I loop over SECRET_LENGTH characters.
/* TODO: Copy me from the previous stage and edit me
* to loop over SECRET_LENGTH characters. */
printf
(
"
\n
"
);
printf
(
"
\n
"
);
free
(
pages
);
free
(
pages
);
...
...
This diff is collapsed.
Click to expand it.
src/recover_protected_local_secret.c
View file @
9be87323
...
@@ -33,13 +33,13 @@ static inline void do_access(page_t *pages, size_t secret_index) {
...
@@ -33,13 +33,13 @@ static inline void do_access(page_t *pages, size_t secret_index) {
// Don't forget to call cache_secret() to ensure the secret is in memory.
// Don't forget to call cache_secret() to ensure the secret is in memory.
}
}
// TODO: Implement a SIGSEGV handler
// TODO: Implement a SIGSEGV handler
int
main
()
{
int
main
()
{
// TODO: Install your SIGSEGV handler
// TODO: Install your SIGSEGV handler
// TODO: For the remainder of the function, copy from the previous stage and edit the following:
// 1. Add asm volatile("label:") to the location you want the SIGSEGV handler to return to.
/* TODO: Copy the code from the previous stage and edit the following:
// 2. For each letter, it might take more than one attempt to get a valid guess. Throw all the logic in an inner loop.
* 1. Add `asm volatile("label:")` where you want the SIGSEGV handler to return to.
* 2. For each letter, it might take more than one attempt to get a cache hit.
* Throw all the logic in an inner loop. */
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help