forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
PoC faster LSMs with static calls/keys: ask for feedbacks #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3af550b
Proof of Concept
PaulRenauld 58659bf
Remove macro magic to add LSM in a slot
PaulRenauld 5cb91dd
remove default functions
PaulRenauld c376984
Remove static keys and introduce static_call_cond_int
PaulRenauld 4d3a07d
Clean up
PaulRenauld b7d05cb
more cleanup
PaulRenauld 08fbfbc
Replace static_call_cond_int by switch statement
PaulRenauld 6507fd3
Remove static call API extension
PaulRenauld fa08676
cleanup
PaulRenauld 684ade3
Move changes from lsm_hooks.h to security.c, and use xmacro to copy t…
PaulRenauld 43f3d21
Move changes from lsm_hooks.h to security.c, and use xmacroaddress co…
PaulRenauld 5d9f58b
fix call void hook
PaulRenauld d243369
fix lsm_init_hook_static_slot
PaulRenauld 5f492ae
add loop_unrolling.h
PaulRenauld 7eef88c
address comments
PaulRenauld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // SPDX-License-Identifier: GPL-2.0 | ||
|
|
||
| /* | ||
| * Copyright (C) 2020 Google LLC. | ||
| */ | ||
|
|
||
| #ifndef __LINUX_LOOP_UNROLLING_H | ||
| #define __LINUX_LOOP_UNROLLING_H | ||
|
|
||
| /* | ||
| * Call MACRO N times. | ||
| * N must be an integer constant no greater than MAX_UNROLL_MACRO_LOOP | ||
| * MACRO should take as first argument the index and then | ||
| * the same __VA_ARGS__ | ||
| * Essenially, this will expand to: | ||
| * MACRO(0, ...) | ||
| * MACRO(1, ...) | ||
| * MACRO(2, ...) | ||
| * ... | ||
| */ | ||
| #define UNROLL_MACRO_LOOP(N, MACRO, ...) \ | ||
| _UNROLL_MACRO_LOOP(N, MACRO, __VA_ARGS__) | ||
|
|
||
| #define MAX_UNROLL_MACRO_LOOP (20) | ||
|
|
||
| // Intermediate macros to expand N if it is itself a macro | ||
| #define _UNROLL_MACRO_LOOP(N, MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP(N, MACRO, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP(N, MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_##N(MACRO, __VA_ARGS__) | ||
|
|
||
|
|
||
| #define __UNROLL_MACRO_LOOP_0(MACRO, ...) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_1(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_0(MACRO, __VA_ARGS__) \ | ||
| MACRO(0, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_2(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_1(MACRO, __VA_ARGS__) \ | ||
| MACRO(1, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_3(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_2(MACRO, __VA_ARGS__) \ | ||
| MACRO(2, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_4(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_3(MACRO, __VA_ARGS__) \ | ||
| MACRO(3, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_5(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_4(MACRO, __VA_ARGS__) \ | ||
| MACRO(4, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_6(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_5(MACRO, __VA_ARGS__) \ | ||
| MACRO(5, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_7(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_6(MACRO, __VA_ARGS__) \ | ||
| MACRO(6, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_8(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_7(MACRO, __VA_ARGS__) \ | ||
| MACRO(7, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_9(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_8(MACRO, __VA_ARGS__) \ | ||
| MACRO(8, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_10(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_9(MACRO, __VA_ARGS__) \ | ||
| MACRO(9, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_11(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_10(MACRO, __VA_ARGS__) \ | ||
| MACRO(10, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_12(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_11(MACRO, __VA_ARGS__) \ | ||
| MACRO(11, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_13(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_12(MACRO, __VA_ARGS__) \ | ||
| MACRO(12, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_14(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_13(MACRO, __VA_ARGS__) \ | ||
| MACRO(13, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_15(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_14(MACRO, __VA_ARGS__) \ | ||
| MACRO(14, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_16(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_15(MACRO, __VA_ARGS__) \ | ||
| MACRO(15, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_17(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_16(MACRO, __VA_ARGS__) \ | ||
| MACRO(16, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_18(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_17(MACRO, __VA_ARGS__) \ | ||
| MACRO(17, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_19(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_18(MACRO, __VA_ARGS__) \ | ||
| MACRO(18, __VA_ARGS__) | ||
|
|
||
| #define __UNROLL_MACRO_LOOP_20(MACRO, ...) \ | ||
| __UNROLL_MACRO_LOOP_19(MACRO, __VA_ARGS__) \ | ||
| MACRO(19, __VA_ARGS__) | ||
|
|
||
| #endif /* __LINUX_LOOP_UNROLLING_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps instead of panicking when this happens, you could have a fallback path that places a pointer to the normal
security_*helper function in the first slot and NOPs out the rest?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting recovery. Right now the idea is that we should have as many static call for each hook as there are LSMs in the kernel, so this wouldn't happen.