File tree Expand file tree Collapse file tree 9 files changed +241
-47
lines changed Expand file tree Collapse file tree 9 files changed +241
-47
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
29
29
CFLAGS_REMOVE_vdso.o = -pg
30
30
31
31
# Force -O2 to avoid libgcc dependencies
32
- CFLAGS_REMOVE_vgettimeofday.o = -pg -Os
32
+ CFLAGS_REMOVE_vgettimeofday.o = -pg -Os $( GCC_PLUGINS_CFLAGS )
33
33
ifeq ($(c-gettimeofday-y ) ,)
34
34
CFLAGS_vgettimeofday.o = -O2
35
35
else
Original file line number Diff line number Diff line change 37
37
# define __GCC4_has_attribute___copy__ 0
38
38
# define __GCC4_has_attribute___designated_init__ 0
39
39
# define __GCC4_has_attribute___externally_visible__ 1
40
+ # define __GCC4_has_attribute___no_caller_saved_registers__ 0
40
41
# define __GCC4_has_attribute___noclone__ 1
41
42
# define __GCC4_has_attribute___nonstring__ 0
42
43
# define __GCC4_has_attribute___no_sanitize_address__ (__GNUC_MINOR__ >= 8)
176
177
*/
177
178
#define __mode (x ) __attribute__((__mode__(x)))
178
179
180
+ /*
181
+ * Optional: only supported since gcc >= 7
182
+ *
183
+ * gcc: https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#index-no_005fcaller_005fsaved_005fregisters-function-attribute_002c-x86
184
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#no-caller-saved-registers
185
+ */
186
+ #if __has_attribute (__no_caller_saved_registers__ )
187
+ # define __no_caller_saved_registers __attribute__((__no_caller_saved_registers__))
188
+ #else
189
+ # define __no_caller_saved_registers
190
+ #endif
191
+
179
192
/*
180
193
* Optional: not supported by clang
181
194
*
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ obj-$(CONFIG_WATCH_QUEUE) += watch_queue.o
125
125
126
126
obj-$(CONFIG_SYSCTL_KUNIT_TEST) += sysctl-test.o
127
127
128
+ CFLAGS_stackleak.o += $(DISABLE_STACKLEAK_PLUGIN )
128
129
obj-$(CONFIG_GCC_PLUGIN_STACKLEAK) += stackleak.o
129
130
KASAN_SANITIZE_stackleak.o := n
130
131
KCSAN_SANITIZE_stackleak.o := n
Original file line number Diff line number Diff line change @@ -104,19 +104,9 @@ asmlinkage void notrace stackleak_erase(void)
104
104
}
105
105
NOKPROBE_SYMBOL (stackleak_erase );
106
106
107
- void __used notrace stackleak_track_stack (void )
107
+ void __used __no_caller_saved_registers notrace stackleak_track_stack (void )
108
108
{
109
- /*
110
- * N.B. stackleak_erase() fills the kernel stack with the poison value,
111
- * which has the register width. That code assumes that the value
112
- * of 'lowest_stack' is aligned on the register width boundary.
113
- *
114
- * That is true for x86 and x86_64 because of the kernel stack
115
- * alignment on these platforms (for details, see 'cc_stack_align' in
116
- * arch/x86/Makefile). Take care of that when you port STACKLEAK to
117
- * new platforms.
118
- */
119
- unsigned long sp = (unsigned long )& sp ;
109
+ unsigned long sp = current_stack_pointer ;
120
110
121
111
/*
122
112
* Having CONFIG_STACKLEAK_TRACK_MIN_SIZE larger than
@@ -125,6 +115,8 @@ void __used notrace stackleak_track_stack(void)
125
115
*/
126
116
BUILD_BUG_ON (CONFIG_STACKLEAK_TRACK_MIN_SIZE > STACKLEAK_SEARCH_DEPTH );
127
117
118
+ /* 'lowest_stack' should be aligned on the register width boundary */
119
+ sp = ALIGN (sp , sizeof (unsigned long ));
128
120
if (sp < current -> lowest_stack &&
129
121
sp >= (unsigned long )task_stack_page (current ) +
130
122
sizeof (unsigned long )) {
Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK) \
33
33
+= -DSTACKLEAK_PLUGIN
34
34
gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK) \
35
35
+= -fplugin-arg-stackleak_plugin-track-min-size=$(CONFIG_STACKLEAK_TRACK_MIN_SIZE)
36
+ gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK) \
37
+ += -fplugin-arg-stackleak_plugin-arch=$(SRCARCH)
36
38
ifdef CONFIG_GCC_PLUGIN_STACKLEAK
37
39
DISABLE_STACKLEAK_PLUGIN += -fplugin-arg-stackleak_plugin-disable
38
40
endif
Original file line number Diff line number Diff line change 5
5
* Homepage:
6
6
* https://github.com/ephox-gcc-plugins/cyclomatic_complexity
7
7
*
8
- * http ://en.wikipedia.org/wiki/Cyclomatic_complexity
8
+ * https ://en.wikipedia.org/wiki/Cyclomatic_complexity
9
9
* The complexity M is then defined as:
10
10
* M = E - N + 2P
11
11
* where
Original file line number Diff line number Diff line change 11
11
*
12
12
* You can read about it more here:
13
13
* https://gcc.gnu.org/viewcvs/gcc?limit_changes=0&view=revision&revision=231296
14
- * http ://lwn.net/Articles/674854/
14
+ * https ://lwn.net/Articles/674854/
15
15
* https://github.com/google/syzkaller
16
16
* https://lwn.net/Articles/677764/
17
17
*
You can’t perform that action at this time.
0 commit comments