Skip to contentSkip to conversation

Introduce the initify gcc plugin

PATCH In review Kees Cook 4 participants 17 messages Jan 31, 2017 – Mar 30, 2017

Subsystems (29)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

v5 cover Introduce the initify gcc plugin

This is a continuation of Emese Revfy's initify plugin upstreaming, updated with various fixes from her github tree. Additionally, I split off the printf attribute fixes and sent those separately.

This is the initify gcc plugin. The kernel already has a mechanism to free up code and data memory that is only used during kernel or module initialization. This plugin will teach the compiler to find more such code and data that can be freed after initialization. It reduces memory usage at run-time, so the initify gcc plugin can be useful for embedded systems.

Originally it was a CII project supported by the Linux Foundation.

This plugin is the part of grsecurity/PaX. You can find out more here:
https://github.com/ephox-gcc-plugins/initify

Section and header size changes for v4.10-rc2:

defconfig (x86_64, gcc 5.4.0)
* 2171 initified strings
* 17 initified functions

section     size (before)  size (with initify)  change
----------  -------------  -------------------  ------
.rodata      3362592        3333920             -28672
.init.data    577208         661432             +84224

.exit.data 0 672 +672
.text 10633407 10629247 -4160
.init.text 444371 446839 +2468
.exit.text 8427 8427 0

header  FileSiz (before)  FileSiz (with initify)  change
------  ----------------  ----------------------  ------
00      16347136          16318464                -28672
03       1118208           1204224                +86016

00 .text .notes __ex_table .rodata __bug_table .pci_fixup .builtin_fw
.tracedata __ksymtab __ksymtab_gpl __ksymtab_strings __param __modver

03 .init.text .altinstr_aux .init.data .x86_cpu_dev.init .altinstructions
.altinstr_replacement .iommu_table .apicdrivers .exit.text .exit.data .smp_locks .data_nosave .bss .brk

Changed from v4:
* Refresh from Emese's latest version.
* Updated build statistics

Changed from v3:
* Refresh from Emese's latest version.

Changed from v2:
* Check all uses when walking a use-def chain.
* Check all uses of initialized local variables and initify them if they have only nocapture uses. Previously only uses in call arguments determined whether the initializer value could be initified.
* Handle the format gcc attribute from the plugin too.
* Verify nocapture parameters of calls. Track uses of these parameters and verify that all uses are not captured. Verify only the nocapture attribute (The format attribute should be verified too.).
* Fixed wrong indexing of function arguments.
* Fixed decl comparison. When comparing two decls the tree codes must be the same.
* Search capture uses of the return value. Use negative nocapture attribute parameter on a function argument to verify that the return value is not captured.
* Stop the search for capture uses if there is a cast to integer type.
* Removed unnecessary duplication hook.
* Handle cloned functions with a changed argument list.
* Check visited tree nodes to avoid an infinite loop.
* Add a new initify plugin option: enable_init_to_exit_moves. Move a function to the exit section if it is called by __init and __exit functions too.
* Added plugin option to disable the search of capture uses in nocapture functions. We must be able to disable verification of nocapture functions because there is a lot of asm code in the str* and mem* functions on i386.
* Added some more nocapture attributes.
* Added some more printf attributes.
* Added some unverified_nocapture attributes.
* Make is_kernel_rodata() nocapture.
* Added comment for the nocapture attribute from Kees.

Changes from v1:
* Removed unnecessary nocapture attributes from boot code (Reported-by: PaX Team <[email protected]>)
* Removed nocapture attributes from functions that return the marked parameter
(Reported-by: Rasmus Villemoes <[email protected]>)
* Added nocapture attribute to strlen()
* Updated gcc-common.h from PaX
* Don't forcibly constify initified string types this caused the size reduction of the .data section (initify_plugin.c)
* Added the section mismatch problem in the commit message

author
#1 lore raw

PATCH v5 1/4 gcc-plugins: Add the initify gcc plugin

From: Emese Revfy <[email protected]>

The kernel already has a mechanism to free up code and data memory that is only used during kernel or module initialization. This plugin will teach the compiler to find more such code and data that can be freed after initialization.

The plugin runs in two passes. The first one tries to find all functions that can be become __init/__exit. The second one moves string constants (local variables and function string arguments marked by the nocapture attribute) only referenced in __init/__exit functions to the __initconst/__exitconst sections.

The result is a reduction in memory usage, since more code is moved into __init and freed during boot. This plugin can be useful for embedded systems.

If a function is called by __init and __exit functions as well then the plugin moves it to the __exit section. This causes false positive section mismatch errors/warnings that I don't know how to handle yet.

The instrumentation pass of the latent_entropy plugin must run after the initify plugin to increase coverage (initify will move functions into init, where latent_entropy will instrument them).

Example build against v4.10-rc2:

defconfig (x86_64, gcc 5.4.0)
* 2171 initified strings
* 17 initified functions

section     size (before)  size (with initify)  change
----------  -------------  -------------------  ------
.rodata      3362592        3333920             -28672
.init.data    577208         661432             +84224

.exit.data 0 672 +672
.text 10633407 10629247 -4160
.init.text 444371 446839 +2468
.exit.text 8427 8427 0

header  FileSiz (before)  FileSiz (with initify)  change
------  ----------------  ----------------------  ------
00      16347136          16318464                -28672
03       1118208           1204224                +86016

00 .text .notes __ex_table .rodata __bug_table .pci_fixup .builtin_fw
.tracedata __ksymtab __ksymtab_gpl __ksymtab_strings __param __modver

03 .init.text .altinstr_aux .init.data .x86_cpu_dev.init .altinstructions
.altinstr_replacement .iommu_table .apicdrivers .exit.text .exit.data .smp_locks .data_nosave .bss .brk

[kees: expanded commit message]
---
 arch/Kconfig                         |   39 +
 arch/arm64/Kconfig                   |    1 +
 arch/x86/Kconfig                     |    1 +
 arch/x86/lib/Makefile                |    4 +
 include/asm-generic/vmlinux.lds.h    |    2 +
 include/linux/compiler-gcc.h         |   14 +
 include/linux/compiler.h             |    4 +
 scripts/Makefile.gcc-plugins         |   14 +
 scripts/gcc-plugins/initify_plugin.c | 1831 ++++++++++++++++++++++++++++++++++
 9 files changed, 1910 insertions(+)
 create mode 100644 scripts/gcc-plugins/initify_plugin.c
arch/Kconfig +39 -0
index 99839c23d453..b6009a21ebea 100644
@@ -410,6 +410,45 @@ config GCC_PLUGIN_LATENT_ENTROPY
 	   * https://grsecurity.net/
 	   * https://pax.grsecurity.net/
 
+config GCC_PLUGIN_INITIFY
+	bool "Free more kernel memory after init"
+	depends on GCC_PLUGINS
+	help
+	  The kernel has a mechanism to free up code and data memory that is
+	  only used during kernel or module initialization.  Enabling this
+	  feature will teach the compiler to find more such code and data
+	  that can be freed after initialization.
+
+	  This plugin currently triggers false positive warnings from the
+	  section mismatch checker.
+
+	  This plugin is the part of grsecurity/PaX. More information at:
+	   * https://grsecurity.net/
+	   * https://pax.grsecurity.net/
+
+config GCC_PLUGIN_INITIFY_VERBOSE
+	bool "Report initification"
+	depends on GCC_PLUGIN_INITIFY
+	help
+	  Print all initified strings and all functions which should be
+	  __init/__exit.
+	  Note that the candidates identified for __init/__exit markings
+	  depend on the current kernel configuration and thus should be
+	  verified manually before the source code is patched.
+
+config HAVE_GCC_PLUGIN_INITIFY_INIT_EXIT
+	bool
+	depends on GCC_PLUGINS
+	help
+	  The architecture supports moving functions to the exit section
+	  if they are called by both __init and __exit functions. This
+	  requires that exit sections are not removed from non-modular
+	  builds.
+
+config GCC_PLUGIN_INITIFY_INIT_EXIT
+	bool
+	depends on GCC_PLUGIN_INITIFY && HAVE_GCC_PLUGIN_INITIFY_INIT_EXIT
+
 config HAVE_CC_STACKPROTECTOR
 	bool
 	help
arch/arm64/Kconfig +1 -0
index 111742126897..139f62f93286 100644
@@ -83,6 +83,7 @@ config ARM64
 	select HAVE_FUNCTION_TRACER
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_GCC_PLUGINS
+	select HAVE_GCC_PLUGIN_INITIFY_INIT_EXIT if GCC_PLUGINS
 	select HAVE_GENERIC_DMA_COHERENT
 	select HAVE_HW_BREAKPOINT if PERF_EVENTS
 	select HAVE_IRQ_TIME_ACCOUNTING
arch/x86/Kconfig +1 -0
index e487493bbd47..bfbcf4fd0700 100644
@@ -127,6 +127,7 @@ config X86
 	select HAVE_FUNCTION_GRAPH_TRACER
 	select HAVE_FUNCTION_TRACER
 	select HAVE_GCC_PLUGINS
+	select HAVE_GCC_PLUGIN_INITIFY_INIT_EXIT if GCC_PLUGINS
 	select HAVE_HW_BREAKPOINT
 	select HAVE_IDE
 	select HAVE_IOREMAP_PROT
arch/x86/lib/Makefile +4 -0
index 34a74131a12c..b98b8fdb7aaf 100644
@@ -29,6 +29,10 @@ lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
 obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
 
 ifeq ($(CONFIG_X86_32),y)
+        CFLAGS_strstr_32.o += $(INITIFY_DISABLE_VERIFIY_NOCAPTURE_FUNCTIONS)
+        CFLAGS_string_32.o += $(INITIFY_DISABLE_VERIFIY_NOCAPTURE_FUNCTIONS)
+        CFLAGS_memcpy_32.o += $(INITIFY_DISABLE_VERIFIY_NOCAPTURE_FUNCTIONS)
+
         obj-y += atomic64_32.o
         lib-y += atomic64_cx8_32.o
         lib-y += checksum_32.o
include/asm-generic/vmlinux.lds.h +2 -0
index 0968d13b3885..4e09b28b0a7b 100644
@@ -551,6 +551,7 @@
 	MEM_DISCARD(init.data)						\
 	KERNEL_CTORS()							\
 	MCOUNT_REC()							\
+	*(.init.rodata.str)						\
 	*(.init.rodata)							\
 	FTRACE_EVENTS()							\
 	TRACE_SYSCALLS()						\
@@ -579,6 +580,7 @@
 	*(.fini_array)							\
 	*(.dtors)							\
 	MEM_DISCARD(exit.data)						\
+	*(.exit.rodata.str)						\
 	MEM_DISCARD(exit.rodata)
 
 #define EXIT_TEXT							\
include/linux/compiler-gcc.h +14 -0
index 0444b1336268..cd4e9ffb00a7 100644
@@ -196,6 +196,20 @@
 #endif
 
 /*
+ * The initify gcc-plugin attempts to identify const arguments that are only
+ * used during init (see __init and __exit), so they can be moved to the
+ * .init.rodata/.exit.rodata section. If an argument is passed to a non-init
+ * function, it must normally be assumed that such an argument has been
+ * captured by that function and may be used in the future when .init/.exit has
+ * been unmapped from memory. In order to identify functions that are confirmed
+ * to not capture their arguments, the __nocapture() attribute is used so that
+ * initify can better identify candidate variables.
+ */
+#ifdef INITIFY_PLUGIN
+#define __nocapture(...) __attribute__((nocapture(__VA_ARGS__)))
+#endif
+
+/*
  * Mark a position in code as unreachable.  This can be used to
  * suppress control flow warnings after asm blocks that transfer
  * control elsewhere.
include/linux/compiler.h +4 -0
index cf0fa5d86059..8b3dcc790bb6 100644
@@ -433,6 +433,10 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 # define __latent_entropy
 #endif
 
+#ifndef __nocapture
+# define __nocapture(...)
+#endif
+
 /*
  * Tell gcc if a function is cold. The compiler will assume any path
  * directly leading to the call is unlikely.
scripts/Makefile.gcc-plugins +14 -0
index 060d2cb373db..51315474a961 100644
@@ -6,6 +6,19 @@ ifdef CONFIG_GCC_PLUGINS
 
   gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY)	+= cyc_complexity_plugin.so
 
+  gcc-plugin-$(CONFIG_GCC_PLUGIN_INITIFY)		+= initify_plugin.so
+  gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_INITIFY)	+= -DINITIFY_PLUGIN -fplugin-arg-initify_plugin-search_init_exit_functions
+  gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_INITIFY_VERBOSE)+= -fplugin-arg-initify_plugin-verbose -fplugin-arg-initify_plugin-print_missing_attr
+  gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_INITIFY_INIT_EXIT)	+= -fplugin-arg-initify_plugin-enable_init_to_exit_moves
+  ifdef CONFIG_GCC_PLUGIN_INITIFY
+    INITIFY_DISABLE_VERIFIY_NOCAPTURE_FUNCTIONS		+= -fplugin-arg-initify_plugin-disable_verify_nocapture_functions
+  endif
+
+  # The Latent Entropy instrumentation pass should already come after Initify
+  # ("optimized" vs "inline"), but just in case this changes, maintain the
+  # runtime ordering here too. Order matters so that Latent Entropy will
+  # instrument functions that have been newly moved into the .init section
+  # by Initify.
   gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)	+= latent_entropy_plugin.so
   gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)	+= -DLATENT_ENTROPY_PLUGIN
   ifdef CONFIG_PAX_LATENT_ENTROPY
@@ -29,6 +42,7 @@ ifdef CONFIG_GCC_PLUGINS
 
   export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR
   export SANCOV_PLUGIN DISABLE_LATENT_ENTROPY_PLUGIN
+  export INITIFY_DISABLE_VERIFIY_NOCAPTURE_FUNCTIONS
 
   ifneq ($(PLUGINCC),)
     # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication.
scripts/gcc-plugins/initify_plugin.c new file +1831 -0

1,831 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

Re: [kernel-hardening] [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

Quoted 6 lines · Kees Cook

From: Emese Revfy <[email protected]>

The kernel already has a mechanism to free up code and data memory that is only used during kernel or module initialization. This plugin will teach the compiler to find more such code and data that can be freed after initialization.

Currently checking whether we can wire this up for powerpc without too many problems...

arch/x86/lib/Makefile lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o · line 34

Quoted 11 lines
arch/x86/lib/Makefile +3 -0
index 34a74131a12c..b98b8fdb7aaf 100644
@@ -29,6 +29,10 @@ lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
 obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
 
 ifeq ($(CONFIG_X86_32),y)
+        CFLAGS_strstr_32.o += $(INITIFY_DISABLE_VERIFIY_NOCAPTURE_FUNCTIONS)
+        CFLAGS_string_32.o += $(INITIFY_DISABLE_VERIFIY_NOCAPTURE_FUNCTIONS)
+        CFLAGS_memcpy_32.o += $(INITIFY_DISABLE_VERIFIY_NOCAPTURE_FUNCTIONS)

s/VERIFIY/VERIFY/g here + Makefile.gcc-plugins?

Signature · 2 lines
Andrew Donnellan              OzLabs, ADL Canberra
[email protected]  IBM Australia Limited
author
#3 lore raw

Re: [kernel-hardening] [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

Quoted 4 lines · Andrew Donnellan
Quoted 3 lines · Kees Cook

From: Emese Revfy <[email protected]>

Quoted 8 lines
Quoted 4 lines

The kernel already has a mechanism to free up code and data memory that is only used during kernel or module initialization. This plugin will teach the compiler to find more such code and data that can be freed after initialization.

Currently checking whether we can wire this up for powerpc without too many problems...

Cool, thanks. FWIW, note that this plugin is a bit back-burnered at the moment. I've got this in my -next tree still, but it needs some rather large changes to how it does its annotations before Linus will accept it.

Quoted 7 lines
Quoted 7 lines
arch/x86/lib/Makefile +0 -0
index 34a74131a12c..b98b8fdb7aaf 100644
@@ -29,6 +29,10 @@ lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
 obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
 
Quoted 10 lines

arch/x86/lib/Makefile lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o · line 37

Quoted 7 lines
arch/x86/lib/Makefile +3 -0
 ifeq ($(CONFIG_X86_32),y)
+        CFLAGS_strstr_32.o +=
 $(INITIFY_DISABLE_VERIFIY_NOCAPTURE_FUNCTIONS)
+        CFLAGS_string_32.o +=
 $(INITIFY_DISABLE_VERIFIY_NOCAPTURE_FUNCTIONS)
+        CFLAGS_memcpy_32.o +=
 $(INITIFY_DISABLE_VERIFIY_NOCAPTURE_FUNCTIONS)

s/VERIFIY/VERIFY/g here + Makefile.gcc-plugins?

Ah, thanks for catching that! I'll get that fixed.

-Kees

Signature · 2 lines
Kees Cook
Pixel Security
#4 lore raw

Re: [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

Quoted 12 lines · Kees Cook
Quoted 10 lines · Andrew Donnellan
Quoted 7 lines · Kees Cook

From: Emese Revfy <[email protected]>

The kernel already has a mechanism to free up code and data memory that is only used during kernel or module initialization. This plugin will teach the compiler to find more such code and data that can be freed after initialization.

Quoted 7 lines
Quoted 2 lines

Currently checking whether we can wire this up for powerpc without too many problems...

Cool, thanks. FWIW, note that this plugin is a bit back-burnered at the moment. I've got this in my -next tree still, but it needs some rather large changes to how it does its annotations before Linus will accept it.

Why not just hardcode the annotations in the plugin itself? I'd expect just making it know about mem*, str*, and the various *printf/printk functions would get 90% of the benefits. The prototypes of these aren't gonna change anytime soon, so there's no compelling reason to keep the annotations with the declarations. The plugin can still do its sanity checking when it compiles a function with one of these names.

Rasmus

author
#5 lore raw

Re: [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

Quoted 22 lines · Rasmus Villemoes
Quoted 12 lines · Kees Cook
Quoted 10 lines · Andrew Donnellan
Quoted 7 lines · Kees Cook

From: Emese Revfy <[email protected]>

The kernel already has a mechanism to free up code and data memory that is only used during kernel or module initialization. This plugin will teach the compiler to find more such code and data that can be freed after initialization.

Quoted 7 lines
Quoted 2 lines

Currently checking whether we can wire this up for powerpc without too many problems...

Cool, thanks. FWIW, note that this plugin is a bit back-burnered at the moment. I've got this in my -next tree still, but it needs some rather large changes to how it does its annotations before Linus will accept it.

Quoted 6 lines

Why not just hardcode the annotations in the plugin itself? I'd expect just making it know about mem*, str*, and the various *printf/printk functions would get 90% of the benefits. The prototypes of these aren't gonna change anytime soon, so there's no compelling reason to keep the annotations with the declarations. The plugin can still do its sanity checking when it compiles a function with one of these names.

Yup, I think that's another entirely workable solution too. I just meant to say that I don't have time at the moment to look at it (if you want to, please do), and I think Emese is already happy with how the annotations work, so I don't think she'd want to work on it either (but she can correct me if I'm wrong).

-Kees

Signature · 2 lines
Kees Cook
Pixel Security
maintainer
#6 lore raw

Re: [kernel-hardening] [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

In reply to Kees Cook
Quoted 12 lines · Kees Cook
Quoted 10 lines · Andrew Donnellan
Quoted 7 lines · Kees Cook

From: Emese Revfy <[email protected]>

The kernel already has a mechanism to free up code and data memory that is only used during kernel or module initialization. This plugin will teach the compiler to find more such code and data that can be freed after initialization.

Quoted 7 lines
Quoted 2 lines

Currently checking whether we can wire this up for powerpc without too many problems...

Cool, thanks. FWIW, note that this plugin is a bit back-burnered at the moment. I've got this in my -next tree still, but it needs some rather large changes to how it does its annotations before Linus will accept it.

I've tried turning it on again a few days ago and still got too many build problems with my randconfig tree, so I've turned it off again. I think I've already reported most of what I found now, so I did not send out new reports.

Arnd

author
#7 lore raw

Re: [kernel-hardening] [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

Quoted 21 lines · Arnd Bergmann
Quoted 12 lines · Kees Cook
Quoted 10 lines · Andrew Donnellan
Quoted 7 lines · Kees Cook

From: Emese Revfy <[email protected]>

The kernel already has a mechanism to free up code and data memory that is only used during kernel or module initialization. This plugin will teach the compiler to find more such code and data that can be freed after initialization.

Quoted 7 lines
Quoted 2 lines

Currently checking whether we can wire this up for powerpc without too many problems...

Cool, thanks. FWIW, note that this plugin is a bit back-burnered at the moment. I've got this in my -next tree still, but it needs some rather large changes to how it does its annotations before Linus will accept it.

Quoted 4 lines

I've tried turning it on again a few days ago and still got too many build problems with my randconfig tree, so I've turned it off again. I think I've already reported most of what I found now, so I did not send out new reports.

Hrm, with what's in -next? That's too bad. I thought everything you reported had been fixed. Dang. :(

-Kees

Signature · 2 lines
Kees Cook
Pixel Security
maintainer
#8 lore raw

Re: [kernel-hardening] [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

Quoted 22 lines · Kees Cook
Quoted 21 lines · Arnd Bergmann
Quoted 19 lines · Kees Cook
Quoted 4 lines · Andrew Donnellan
Quoted 3 lines · Kees Cook

From: Emese Revfy <[email protected]>

Quoted 8 lines
Quoted 4 lines

The kernel already has a mechanism to free up code and data memory that is only used during kernel or module initialization. This plugin will teach the compiler to find more such code and data that can be freed after initialization.

Currently checking whether we can wire this up for powerpc without too many problems...

Cool, thanks. FWIW, note that this plugin is a bit back-burnered at the moment. I've got this in my -next tree still, but it needs some rather large changes to how it does its annotations before Linus will accept it.

Quoted 7 lines
Quoted 4 lines

I've tried turning it on again a few days ago and still got too many build problems with my randconfig tree, so I've turned it off again. I think I've already reported most of what I found now, so I did not send out new reports.

Hrm, with what's in -next? That's too bad. I thought everything you reported had been fixed. Dang. :(

Here are the ones I'm still getting with around 50 randconfig builds:

0xA1433C1D Tue Mar 28 21:43:01 CEST 2017 failed /git/arm-soc/drivers/acpi/acpica/utdebug.c: In function 'acpi_debug_print':
/git/arm-soc/drivers/acpi/acpica/utdebug.c:158:1: error:
'acpi_debug_print' captures its 3 ('function_name') parameter, please remove it from the nocapture attribute. [-Werror]

0x46D10F38 Tue Mar 28 21:48:11 CEST 2017 failed /git/arm-soc/lib/string.c: In function 'check_bytes8':
/git/arm-soc/lib/string.c:900:7: error: 'check_bytes8' captures its 1 ('start') parameter, please remove it from the nocapture attribute. [-Werror]
void *check_bytes8(const u8 *start, u8 value, unsigned int bytes)

       ^~~~~~~~~~~~

0xDC65C29E Tue Mar 28 22:20:43 CEST 2017 success 0xCF5F679E Tue Mar 28 22:21:02 CEST 2017 failed /git/arm-soc/lib/string.c: In function 'strnstr':
/git/arm-soc/lib/string.c:858:7: error: 'strnstr' captures its 1 ('s1') parameter, please remove it from the nocapture attribute. [-Werror]

I also got this a few days ago:

*** WARNING *** there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins.

Event                            | Plugins
PLUGIN_ATTRIBUTES                | initify_plugin
PLUGIN_START_UNIT                | initify_plugin

/git/arm-soc/arch/arm/mach-mv78xx0/common.c: In function 'mv78xx0_init':
/git/arm-soc/arch/arm/mach-mv78xx0/common.c:384:13: internal compiler
error: in search_constant_strings, at git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
void __init mv78xx0_init(void)

             ^~~~~~~~~~~~

0x2b0538381b9d search_constant_strings /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375 0x2b0538381950 search_constant_strings /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1335 0x2b0538381950 search_constant_strings /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1367 0x2b0538382abe search_constant_strings /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1506 0x2b0538382abe search_var_param /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1419 0x2b0538382abe search_const_strs /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1471 0x2b0538382abe initify_function_transform /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1519 0xc679a3 execute_one_ipa_transform_pass /home/arnd/git/gcc/gcc/passes.c:2207
0xc67b2d execute_all_ipa_transforms() /home/arnd/git/gcc/gcc/passes.c:2249
0x8d5a46 cgraph_node::expand() /home/arnd/git/gcc/gcc/cgraphunit.c:2029
0x8d5f1c expand_all_functions /home/arnd/git/gcc/gcc/cgraphunit.c:2172
0x8d69ec symbol_table::compile() /home/arnd/git/gcc/gcc/cgraphunit.c:2529
0x8d6c2c symbol_table::finalize_compilation_unit() /home/arnd/git/gcc/gcc/cgraphunit.c:2619
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. /git/arm-soc/scripts/Makefile.build:308: recipe for target 'arch/arm/mach-mv78xx0/common.o' failed

Arnd

#9 lore raw

Re: [kernel-hardening] [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

In reply to Andrew Donnellan
Quoted 10 lines · Andrew Donnellan
Quoted 6 lines · Kees Cook

From: Emese Revfy <[email protected]>

The kernel already has a mechanism to free up code and data memory that is only used during kernel or module initialization. This plugin will teach the compiler to find more such code and data that can be freed after initialization.

Currently checking whether we can wire this up for powerpc without too many problems...

Added "select HAVE_GCC_PLUGIN_INITIFY_INIT_EXIT if GCC_PLUGINS" to arch/powerpc/Kconfig and have successfully compiled and booted a modular and non-modular powernv_defconfig, it looks like we handle the .exit sections correctly.

Could this be folded in for further testing when you get around to v6, Kees?

Signature · 2 lines
Andrew Donnellan              OzLabs, ADL Canberra
[email protected]  IBM Australia Limited
author
#10 lore raw

Re: [kernel-hardening] [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

Quoted 16 lines · Andrew Donnellan
Quoted 5 lines · Andrew Donnellan
Quoted 3 lines · Kees Cook

From: Emese Revfy <[email protected]>

Quoted 8 lines
Quoted 4 lines

The kernel already has a mechanism to free up code and data memory that is only used during kernel or module initialization. This plugin will teach the compiler to find more such code and data that can be freed after initialization.

Currently checking whether we can wire this up for powerpc without too many problems...

Quoted 6 lines

Added "select HAVE_GCC_PLUGIN_INITIFY_INIT_EXIT if GCC_PLUGINS" to arch/powerpc/Kconfig and have successfully compiled and booted a modular and non-modular powernv_defconfig, it looks like we handle the .exit sections correctly.

Could this be folded in for further testing when you get around to v6, Kees?

Awesome, thanks for testing! I'll get it queued for a v6...

-Kees

Signature · 2 lines
Kees Cook
Pixel Security
maintainer
#11 lore raw

Re: [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

In reply to Kees Cook

Here is a reduced test case for one assertion failure I get with the initify plugin:

8<------------
typedef unsigned int u32;

__attribute__ ((format(printf, 1, 2))) __attribute__ ((__cold__)) int printk(const char *fmt, ...);

void mv78xx0_pcie_id(u32 * dev, u32 * rev);

static char * __attribute__ ((__section__(".init.text")))

    __attribute__ ((__cold__)) __attribute__ ((no_instrument_function))
    __attribute__ ((latent_entropy)) mv78xx0_id(void)
{
        u32 dev, rev;
        mv78xx0_pcie_id(&dev, &rev);
        if (dev == 0x7820) {
                return "MV78200-A0";
        } else {
                return "Device-Unknown";
        }
}

void __attribute__ ((__section__(".init.text"))) __attribute__ ((__cold__))

    __attribute__ ((no_instrument_function))
    __attribute__ ((latent_entropy)) mv78xx0_init(void)
{
        printk("\001" "6" "%s ", mv78xx0_id());
}

------------->8

arm-linux-gnueabi-gcc-7.0.1 -Wimplicit-fallthrough=0 -Wno-duplicate-decl-specifier -Wno-override-init -Wno-int-in-bool-context -Wno-bool-operation -Wno-format-truncation -Werror -Wa,--fatal-warnings -DKCONFIG_SEED= -wrapper /usr/bin/time,--format=%M:%U:%C,-o,/home/arnd/arm-soc/defconfig-kbytes,--append -Wp,-MD,arch/arm/mach-mv78xx0/.common.o.d -nostdinc -isystem /home/arnd/cross-gcc/lib/gcc/arm-linux-gnueabi/7.0.1/include -I/git/arm-soc/arch/arm/include -I./arch/arm/include/generated/uapi -I./arch/arm/include/generated -I/git/arm-soc/include -I./include -I/git/arm-soc/arch/arm/include/uapi -I/git/arm-soc/include/uapi -I./include/generated/uapi -include /git/arm-soc/include/linux/kconfig.h -I/git/arm-soc/arch/arm/mach-mv78xx0 -Iarch/arm/mach-mv78xx0 -D__KERNEL__ -mbig-endian -Wall -Wundef -Wstrict-prototypes -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -std=gnu89 -fno-PIE -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp -funwind-tables -marm -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=xscale -msoft-float -Uarm -Wextra -Wno-frame-address -ffunction-sections -fdata-sections -O2 --param=allow-store-data-races=0 -DCC_HAVE_ASM_GOTO -fplugin=./scripts/gcc-plugins/initify_plugin.so -fplugin=./scripts/gcc-plugins/latent_entropy_plugin.so -DINITIFY_PLUGIN -fplugin-arg-initify_plugin-search_init_exit_functions -DLATENT_ENTROPY_PLUGIN -Wframe-larger-than=1024 -fstack-protector-strong -fno-delete-null-pointer-checks -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -fno-inline-functions-called-once -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-type-limits -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wmissing-include-dirs -Wformat=2 -Wno-format-nonliteral -Wtrampolines -Wold-style-definition -Wnormalized -Wvolatile-register-var -Wdisabled-optimization -Wno-format-security -Wimplicit-fallthrough=0 -Wno-duplicate-decl-specifier -Wno-int-in-bool-context -Wno-bool-operation -Wformat-truncation=0 -Wformat-overflow=0 -I/git/arm-soc/arch/arm/plat-orion/include -DKBUILD_BASENAME='"common"' -DKBUILD_MODNAME='"common"' -c arch/arm/mach-mv78xx0/common.c
*** WARNING *** there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins.

Event                            | Plugins
PLUGIN_ATTRIBUTES                | latent_entropy_plugin initify_plugin
PLUGIN_START_UNIT                | latent_entropy_plugin initify_plugin

arch/arm/mach-mv78xx0/common.i: In function 'mv78xx0_init':
arch/arm/mach-mv78xx0/common.i:23:38: internal compiler error: in search_constant_strings, at git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375

     __attribute__ ((latent_entropy)) mv78xx0_init(void)
                                      ^~~~~~~~~~~~

0x7f319a009b9d search_constant_strings /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375 0x7f319a009950 search_constant_strings /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1335 0x7f319a009950 search_constant_strings /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1367 0x7f319a00aabe search_constant_strings /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1506 0x7f319a00aabe search_var_param /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1419 0x7f319a00aabe search_const_strs /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1471 0x7f319a00aabe initify_function_transform /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1519 0x932ce7 execute_one_ipa_transform_pass /home/arnd/git/gcc/gcc/passes.c:2207
0x932ce7 execute_all_ipa_transforms() /home/arnd/git/gcc/gcc/passes.c:2249
0x6b28fc cgraph_node::expand() /home/arnd/git/gcc/gcc/cgraphunit.c:2031
0x6b3e5c expand_all_functions /home/arnd/git/gcc/gcc/cgraphunit.c:2174
0x6b3e5c symbol_table::compile() /home/arnd/git/gcc/gcc/cgraphunit.c:2531
0x6b58b7 symbol_table::compile() /home/arnd/git/gcc/gcc/cgraphunit.c:2595
0x6b58b7 symbol_table::finalize_compilation_unit() /home/arnd/git/gcc/gcc/cgraphunit.c:2621
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.

maintainer
#12 lore raw

Re: [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

And here is a workaround that I applied locally to avoid the ICE, but I wouldn't want to have this upstream.

commit 8712fd8979a5730318a84922fbcb8791ea5af40e

Author: Arnd Bergmann <[email protected]>
Date:   Wed Mar 29 10:53:48 2017 +0200

work around initify ICE

arch/arm/mach-mv78xx0/common.i: In function 'mv78xx0_init':
arch/arm/mach-mv78xx0/common.i:28:38: internal compiler error: in
search_constant_strings, at git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375

         __attribute__ ((latent_entropy)) mv78xx0_init(void)
                                          ^~~~~~~~~~~~
    0x7fe5cd711b9d search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
    0x7fe5cd711950 search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1335
    0x7fe5cd711950 search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1367
    0x7fe5cd712abe search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1506
    0x7fe5cd712abe search_var_param
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1419
    0x7fe5cd712abe search_const_strs
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1471
    0x7fe5cd712abe initify_function_transform
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1519
    0x932ce7 execute_one_ipa_transform_pass
            /home/arnd/git/gcc/gcc/passes.c:2207
    0x932ce7 execute_all_ipa_transforms()
            /home/arnd/git/gcc/gcc/passes.c:2249
    0x6b28fc cgraph_node::expand()
            /home/arnd/git/gcc/gcc/cgraphunit.c:2031
    0x6b3e5c expand_all_functions
            /home/arnd/git/gcc/gcc/cgraphunit.c:2174
    0x6b3e5c symbol_table::compile()
            /home/arnd/git/gcc/gcc/cgraphunit.c:2531
    0x6b58b7 symbol_table::compile()
            /home/arnd/git/gcc/gcc/cgraphunit.c:2595
    0x6b58b7 symbol_table::finalize_compilation_unit()
            /home/arnd/git/gcc/gcc/cgraphunit.c:2621
    Please submit a full bug report,
    with preprocessed source if appropriate.
    Please include the complete backtrace with any bug report.
    See <https://gcc.gnu.org/bugs/> for instructions.

    Signed-off-by: Arnd Bergmann <[email protected]>
arch/arm/mach-mv78xx0/common.c +19 -9
index f72e1e9f5fc5..66e04a770e32 100644
@@ -348,31 +348,41 @@ void __ref mv78xx0_timer_init(void)
 /*****************************************************************************
  * General
  ****************************************************************************/
-static char * __init mv78xx0_id(void)
+static const char * __init mv78xx0_id(void)
 {
        u32 dev, rev;
+       static const char *chip_ids[] = {
+               "MV78X00-Z0",
+               "MV78X00-Rev-Unsupported",
+               "MV78100-A0",
+               "MV78100-A1",
+               "MV78100-Rev-Unsupported",
+               "MV78200-A0",
+               "MV78200-Rev-Unsupported",
+               "Device-Unknown",
+       };
 
        mv78xx0_pcie_id(&dev, &rev);
 
        if (dev == MV78X00_Z0_DEV_ID) {
                if (rev == MV78X00_REV_Z0)
-                       return "MV78X00-Z0";
+                       return chip_ids[0];
                else
-                       return "MV78X00-Rev-Unsupported";
+                       return chip_ids[1];
        } else if (dev == MV78100_DEV_ID) {
                if (rev == MV78100_REV_A0)
-                       return "MV78100-A0";
+                       return chip_ids[2];
                else if (rev == MV78100_REV_A1)
-                       return "MV78100-A1";
+                       return chip_ids[3];
                else
-                       return "MV78100-Rev-Unsupported";
+                       return chip_ids[4];
        } else if (dev == MV78200_DEV_ID) {
                if (rev == MV78100_REV_A0)
-                       return "MV78200-A0";
+                       return chip_ids[5];
                else
-                       return "MV78200-Rev-Unsupported";
+                       return chip_ids[6];
        } else {
-               return "Device-Unknown";
+               return chip_ids[7];
        }
 }
maintainer
#13 lore raw

Re: [PATCH v5 1/4] gcc-plugins: Add the initify gcc plugin

Quoted 13 lines · Arnd Bergmann

And here is a workaround that I applied locally to avoid the ICE, but I wouldn't want to have this upstream.

commit 8712fd8979a5730318a84922fbcb8791ea5af40e

Author: Arnd Bergmann <[email protected]>
Date:   Wed Mar 29 10:53:48 2017 +0200

work around initify ICE

arch/arm/mach-mv78xx0/common.i: In function 'mv78xx0_init':
arch/arm/mach-mv78xx0/common.i:28:38: internal compiler error: in
search_constant_strings, at git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375

Quoted 10 lines
         __attribute__ ((latent_entropy)) mv78xx0_init(void)
                                          ^~~~~~~~~~~~
    0x7fe5cd711b9d search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
    0x7fe5cd711950 search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1335
    0x7fe5cd711950 search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1367
    0x7fe5cd712abe search_constant_strings
            /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1506

Two more ICEs:

a)
*** WARNING *** there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins.

Event                            | Plugins
PLUGIN_ATTRIBUTES                | latent_entropy_plugin initify_plugin
PLUGIN_START_UNIT                | latent_entropy_plugin initify_plugin

/git/arm-soc/drivers/scsi/gdth.c: In function 'gdth_search_drives':
/git/arm-soc/drivers/scsi/gdth.c:1550:12: internal compiler error: in search_constant_strings, at git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
static int gdth_search_drives(gdth_ha_str *ha)

            ^~~~~~~~~~~~~~~~~~
0x2b0f7a831b9d search_constant_strings
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1375
0x2b0f7a831950 search_constant_strings
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1335
0x2b0f7a831950 search_constant_strings
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1367
0x2b0f7a832abe search_constant_strings
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1506
0x2b0f7a832abe search_var_param
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1419
0x2b0f7a832abe search_const_strs
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1471
0x2b0f7a832abe initify_function_transform
        /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1519
0x9b6c07 execute_one_ipa_transform_pass
        /home/arnd/git/gcc/gcc/passes.c:2207
0x9b6c07 execute_all_ipa_transforms()
        /home/arnd/git/gcc/gcc/passes.c:2249
0x734d6c cgraph_node::expand()
        /home/arnd/git/gcc/gcc/cgraphunit.c:2031
0x7362cc expand_all_functions
        /home/arnd/git/gcc/gcc/cgraphunit.c:2174
0x7362cc symbol_table::compile()
        /home/arnd/git/gcc/gcc/cgraphunit.c:2531
0x737d27 symbol_table::compile()
        /home/arnd/git/gcc/gcc/cgraphunit.c:2595
0x737d27 symbol_table::finalize_compilation_unit()
        /home/arnd/git/gcc/gcc/cgraphunit.c:2621

Please submit a full bug report,
with preprocessed source if appropriate.

This is the probably the same bug as the first, and I've worked around it incorrectly for now:

drivers/scsi/gdth.c +2 -0
index d020a13646ae..37c9cf7a4e82 100644
@@ -3846,6 +3846,8 @@ static const char *gdth_ctr_name(gdth_ha_str *ha)
 {
     TRACE2(("gdth_ctr_name()\n"));
 
+       return "";
+
     if (ha->type == GDT_EISA) {
         switch (ha->stype) {
           case GDT3_ID:

b)
*** WARNING *** there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins.

Event                            | Plugins
PLUGIN_ATTRIBUTES                | initify_plugin
PLUGIN_START_UNIT                | initify_plugin

/git/arm-soc/arch/x86/kernel/traps.c:1049:1: internal compiler error:
in set_section, at symtab.c:1514
}
^
0x724dd6 symtab_node::set_section(char const*) /home/arnd/git/gcc/gcc/symtab.c:1514
0x2b26ed538c51 move_function_to_init_exit_text /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1751 0x2b26ed538c51 initify_execute /git/arm-soc/scripts/gcc-plugins/initify_plugin.c:1771 0x2b26ed538c51 execute /git/arm-soc/scripts/gcc-plugins/gcc-generate-ipa-pass.h:215 Please submit a full bug report,

This one is different from the other two, and I don't know much about what happened, but this clearly bogus change avoids the problem:

arch/x86/include/asm/desc.h +1 -1
index d0a21b12dd58..3793900f7f73 100644
@@ -508,7 +508,7 @@ static inline void alloc_system_vector(int vector)
  */
 static inline void set_system_intr_gate(unsigned int n, void *addr)
 {
-       BUG_ON((unsigned)n > 0xFF);
+       //BUG_ON((unsigned)n > 0xFF);
        _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
 }
 

Aside from these problems and the annotations I sent yesterday, the initify plugin doesn't cause any more build-time regressions for me, so I'm leaving it enabled.

Arnd

author
#14 lore raw

PATCH v5 2/4 util: Move type casts into is_kernel_rodata

In reply to Kees Cook

From: Emese Revfy <[email protected]>

This moves type casts into the is_kernel_rodata() function itself so that parameters can be marked as "nocapture" in the coming initify gcc plugin.

[kees: expanded commit message]
---
 mm/util.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
mm/util.c +5 -5
index 3cb2164f4099..a700e3fb1587 100644
@@ -17,10 +17,10 @@
 
 #include "internal.h"
 
-static inline int is_kernel_rodata(unsigned long addr)
+static inline int is_kernel_rodata(const void *addr)
 {
-	return addr >= (unsigned long)__start_rodata &&
-		addr < (unsigned long)__end_rodata;
+	return (unsigned long)addr >= (unsigned long)__start_rodata &&
+		(unsigned long)addr < (unsigned long)__end_rodata;
 }
 
 /**
@@ -31,7 +31,7 @@ static inline int is_kernel_rodata(unsigned long addr)
  */
 void kfree_const(const void *x)
 {
-	if (!is_kernel_rodata((unsigned long)x))
+	if (!is_kernel_rodata(x))
 		kfree(x);
 }
 EXPORT_SYMBOL(kfree_const);
@@ -68,7 +68,7 @@ EXPORT_SYMBOL(kstrdup);
  */
 const char *kstrdup_const(const char *s, gfp_t gfp)
 {
-	if (is_kernel_rodata((unsigned long)s))
+	if (is_kernel_rodata(s))
 		return s;
 
 	return kstrdup(s, gfp);
Signature · 1 line
2.7.4
author
#15 lore raw

PATCH v5 3/4 initify: Mark functions with the __nocapture attribute

In reply to Kees Cook

From: Emese Revfy <[email protected]>

The nocapture gcc attribute can be on functions only. The attribute takes zero or more signed integer constants as parameters that specify the function parameters to initify when the passed arguments are of const char* type.

A negative attribute parameter value means that the corresponding function parameter is returned by the function and the passed argument will only be initified if the data flow of the returned value is not captured in the caller.

If no values are passed to the attribute then all function parameters are treated as nocapture.

If the marked parameter is a vararg then the plugin initifies all vararg arguments.

---
 arch/arm/include/asm/string.h     | 10 +++---
 arch/arm64/include/asm/string.h   | 25 ++++++-------
 arch/powerpc/include/asm/string.h | 19 +++++-----
 arch/x86/include/asm/string_32.h  | 25 ++++++-------
 arch/x86/include/asm/string_64.h  | 23 ++++++------
 arch/x86/kernel/hpet.c            |  2 +-
 drivers/acpi/acpica/acutils.h     |  2 +-
 fs/char_dev.c                     |  2 +-
 fs/ntfs/debug.h                   |  6 ++--
 fs/ocfs2/cluster/masklog.h        |  2 +-
 include/acpi/acpixf.h             |  2 +-
 include/asm-generic/bug.h         |  7 ++--
 include/drm/drm_drv.h             |  2 +-
 include/linux/audit.h             |  5 +--
 include/linux/fs.h                |  8 +++--
 include/linux/printk.h            |  2 +-
 include/linux/ratelimit.h         |  3 +-
 include/linux/string.h            | 75 ++++++++++++++++++++-------------------
 lib/vsprintf.c                    |  6 ++--
 mm/util.c                         |  2 +-
 security/integrity/integrity.h    |  2 +-
 21 files changed, 121 insertions(+), 109 deletions(-)
arch/arm/include/asm/string.h +5 -5
index cf4f3aad0fc1..8f2f2d9a6549 100644
@@ -7,19 +7,19 @@
  */
 
 #define __HAVE_ARCH_STRRCHR
-extern char * strrchr(const char * s, int c);
+extern char * strrchr(const char * s, int c) __nocapture(-1);
 
 #define __HAVE_ARCH_STRCHR
-extern char * strchr(const char * s, int c);
+extern char * strchr(const char * s, int c) __nocapture(-1);
 
 #define __HAVE_ARCH_MEMCPY
-extern void * memcpy(void *, const void *, __kernel_size_t);
+extern void * memcpy(void *, const void *, __kernel_size_t) __nocapture(2);
 
 #define __HAVE_ARCH_MEMMOVE
-extern void * memmove(void *, const void *, __kernel_size_t);
+extern void * memmove(void *, const void *, __kernel_size_t) __nocapture(2);
 
 #define __HAVE_ARCH_MEMCHR
-extern void * memchr(const void *, int, __kernel_size_t);
+extern void * memchr(const void *, int, __kernel_size_t) __nocapture(-1);
 
 #define __HAVE_ARCH_MEMSET
 extern void * memset(void *, int, __kernel_size_t);
arch/arm64/include/asm/string.h +13 -12
index 2eb714c4639f..188a1022c764 100644
@@ -17,40 +17,41 @@
 #define __ASM_STRING_H
 
 #define __HAVE_ARCH_STRRCHR
-extern char *strrchr(const char *, int c);
+extern char *strrchr(const char *, int c) __nocapture(-1);
 
 #define __HAVE_ARCH_STRCHR
-extern char *strchr(const char *, int c);
+extern char *strchr(const char *, int c) __nocapture(-1);
 
 #define __HAVE_ARCH_STRCMP
-extern int strcmp(const char *, const char *);
+extern int strcmp(const char *, const char *) __nocapture();
 
 #define __HAVE_ARCH_STRNCMP
-extern int strncmp(const char *, const char *, __kernel_size_t);
+extern int
+strncmp(const char *, const char *, __kernel_size_t) __nocapture(1, 2);
 
 #define __HAVE_ARCH_STRLEN
-extern __kernel_size_t strlen(const char *);
+extern __kernel_size_t strlen(const char *) __nocapture(1);
 
 #define __HAVE_ARCH_STRNLEN
-extern __kernel_size_t strnlen(const char *, __kernel_size_t);
+extern __kernel_size_t strnlen(const char *, __kernel_size_t) __nocapture(1);
 
 #define __HAVE_ARCH_MEMCPY
-extern void *memcpy(void *, const void *, __kernel_size_t);
-extern void *__memcpy(void *, const void *, __kernel_size_t);
+extern void *memcpy(void *, const void *, __kernel_size_t) __nocapture(2);
+extern void *__memcpy(void *, const void *, __kernel_size_t) __nocapture(2);
 
 #define __HAVE_ARCH_MEMMOVE
-extern void *memmove(void *, const void *, __kernel_size_t);
-extern void *__memmove(void *, const void *, __kernel_size_t);
+extern void *memmove(void *, const void *, __kernel_size_t) __nocapture(2);
+extern void *__memmove(void *, const void *, __kernel_size_t) __nocapture(2);
 
 #define __HAVE_ARCH_MEMCHR
-extern void *memchr(const void *, int, __kernel_size_t);
+extern void *memchr(const void *, int, __kernel_size_t) __nocapture(-1);
 
 #define __HAVE_ARCH_MEMSET
 extern void *memset(void *, int, __kernel_size_t);
 extern void *__memset(void *, int, __kernel_size_t);
 
 #define __HAVE_ARCH_MEMCMP
-extern int memcmp(const void *, const void *, size_t);
+extern int memcmp(const void *, const void *, size_t) __nocapture(1, 2);
 
 
 #if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__)
arch/powerpc/include/asm/string.h +10 -9
index da3cdffca440..ba08cf461ca2 100644
@@ -11,16 +11,17 @@
 #define __HAVE_ARCH_MEMCMP
 #define __HAVE_ARCH_MEMCHR
 
-extern char * strcpy(char *,const char *);
-extern char * strncpy(char *,const char *, __kernel_size_t);
-extern __kernel_size_t strlen(const char *);
-extern int strcmp(const char *,const char *);
-extern int strncmp(const char *, const char *, __kernel_size_t);
-extern char * strcat(char *, const char *);
+extern char * strcpy(char *,const char *) __nocapture(2);
+extern char * strncpy(char *,const char *, __kernel_size_t) __nocapture(2);
+extern __kernel_size_t strlen(const char *) __nocapture(1);
+extern int strcmp(const char *,const char *) __nocapture();
+extern int
+strncmp(const char *, const char *, __kernel_size_t) __nocapture(1, 2);
+extern char * strcat(char *, const char *) __nocapture(2);
 extern void * memset(void *,int,__kernel_size_t);
-extern void * memcpy(void *,const void *,__kernel_size_t);
-extern void * memmove(void *,const void *,__kernel_size_t);
-extern int memcmp(const void *,const void *,__kernel_size_t);
+extern void * memcpy(void *,const void *,__kernel_size_t) __nocapture(2);
+extern void * memmove(void *,const void *,__kernel_size_t) __nocapture(2);
+extern int memcmp(const void *,const void *,__kernel_size_t) __nocapture(1, 2);
 extern void * memchr(const void *,int,__kernel_size_t);
 
 #endif /* __KERNEL__ */
arch/x86/include/asm/string_32.h +13 -12
index 3d3e8353ee5c..db6fe4c3d1e8 100644
@@ -6,28 +6,29 @@
 /* Let gcc decide whether to inline or use the out of line functions */
 
 #define __HAVE_ARCH_STRCPY
-extern char *strcpy(char *dest, const char *src);
+extern char *strcpy(char *dest, const char *src) __nocapture(2);
 
 #define __HAVE_ARCH_STRNCPY
-extern char *strncpy(char *dest, const char *src, size_t count);
+extern char *strncpy(char *dest, const char *src, size_t count) __nocapture(2);
 
 #define __HAVE_ARCH_STRCAT
-extern char *strcat(char *dest, const char *src);
+extern char *strcat(char *dest, const char *src) __nocapture(2);
 
 #define __HAVE_ARCH_STRNCAT
-extern char *strncat(char *dest, const char *src, size_t count);
+extern char *strncat(char *dest, const char *src, size_t count) __nocapture(2);
 
 #define __HAVE_ARCH_STRCMP
-extern int strcmp(const char *cs, const char *ct);
+extern int strcmp(const char *cs, const char *ct) __nocapture();
 
 #define __HAVE_ARCH_STRNCMP
-extern int strncmp(const char *cs, const char *ct, size_t count);
+extern int
+strncmp(const char *cs, const char *ct, size_t count) __nocapture(1, 2);
 
 #define __HAVE_ARCH_STRCHR
-extern char *strchr(const char *s, int c);
+extern char *strchr(const char *s, int c) __nocapture(-1);
 
 #define __HAVE_ARCH_STRLEN
-extern size_t strlen(const char *s);
+extern size_t strlen(const char *s) __nocapture(1);
 
 static __always_inline void *__memcpy(void *to, const void *from, size_t n)
 {
@@ -197,12 +198,12 @@ static inline void *__memcpy3d(void *to, const void *from, size_t len)
 #endif
 
 #define __HAVE_ARCH_MEMMOVE
-void *memmove(void *dest, const void *src, size_t n);
+void *memmove(void *dest, const void *src, size_t n) __nocapture(2);
 
 #define memcmp __builtin_memcmp
 
 #define __HAVE_ARCH_MEMCHR
-extern void *memchr(const void *cs, int c, size_t count);
+extern void *memchr(const void *cs, int c, size_t count) __nocapture(-1);
 
 static inline void *__memset_generic(void *s, char c, size_t count)
 {
@@ -243,11 +244,11 @@ void *__constant_c_memset(void *s, unsigned long c, size_t count)
 
 /* Added by Gertjan van Wingerde to make minix and sysv module work */
 #define __HAVE_ARCH_STRNLEN
-extern size_t strnlen(const char *s, size_t count);
+extern size_t strnlen(const char *s, size_t count) __nocapture(1);
 /* end of additional stuff */
 
 #define __HAVE_ARCH_STRSTR
-extern char *strstr(const char *cs, const char *ct);
+extern char *strstr(const char *cs, const char *ct) __nocapture(-1, 2);
 
 /*
  * This looks horribly ugly, but the compiler can optimize it totally,
arch/x86/include/asm/string_64.h +12 -11
index a164862d77e3..e06b6eb806ac 100644
@@ -28,8 +28,8 @@ static __always_inline void *__inline_memcpy(void *to, const void *from, size_t
    function. */
 
 #define __HAVE_ARCH_MEMCPY 1
-extern void *memcpy(void *to, const void *from, size_t len);
-extern void *__memcpy(void *to, const void *from, size_t len);
+extern void *memcpy(void *to, const void *from, size_t len) __nocapture(2);
+extern void *__memcpy(void *to, const void *from, size_t len) __nocapture(2);
 
 #ifndef CONFIG_KMEMCHECK
 #if (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || __GNUC__ < 4
@@ -57,14 +57,14 @@ void *memset(void *s, int c, size_t n);
 void *__memset(void *s, int c, size_t n);
 
 #define __HAVE_ARCH_MEMMOVE
-void *memmove(void *dest, const void *src, size_t count);
-void *__memmove(void *dest, const void *src, size_t count);
+void *memmove(void *dest, const void *src, size_t count) __nocapture(2);
+void *__memmove(void *dest, const void *src, size_t count) __nocapture(2);
 
-int memcmp(const void *cs, const void *ct, size_t count);
-size_t strlen(const char *s);
-char *strcpy(char *dest, const char *src);
-char *strcat(char *dest, const char *src);
-int strcmp(const char *cs, const char *ct);
+int memcmp(const void *cs, const void *ct, size_t count) __nocapture(1, 2);
+size_t strlen(const char *s) __nocapture(1);
+char *strcpy(char *dest, const char *src) __nocapture(2);
+char *strcat(char *dest, const char *src) __nocapture(2);
+int strcmp(const char *cs, const char *ct) __nocapture(1, 2);
 
 #if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__)
 
@@ -79,7 +79,8 @@ int strcmp(const char *cs, const char *ct);
 #define memset(s, c, n) __memset(s, c, n)
 #endif
 
-__must_check int memcpy_mcsafe_unrolled(void *dst, const void *src, size_t cnt);
+__must_check __nocapture(2) int
+memcpy_mcsafe_unrolled(void *dst, const void *src, size_t cnt);
 DECLARE_STATIC_KEY_FALSE(mcsafe_key);
 
 /**
@@ -96,7 +97,7 @@ DECLARE_STATIC_KEY_FALSE(mcsafe_key);
  *
  * Return 0 for success, -EFAULT for fail
  */
-static __always_inline __must_check int
+static __always_inline __must_check __nocapture(2) int
 memcpy_mcsafe(void *dst, const void *src, size_t cnt)
 {
 #ifdef CONFIG_X86_MCE
arch/x86/kernel/hpet.c +1 -1
index 85e87b46c318..74d50b7b6adb 100644
@@ -136,7 +136,7 @@ int is_hpet_enabled(void)
 }
 EXPORT_SYMBOL_GPL(is_hpet_enabled);
 
-static void _hpet_print_config(const char *function, int line)
+static void __nocapture(1) _hpet_print_config(const char *function, int line)
 {
 	u32 i, timers, l, h;
 	printk(KERN_INFO "hpet: %s(%d):\n", function, line);
drivers/acpi/acpica/acutils.h +1 -1
index 845afb180a7e..99caf0aef79e 100644
@@ -291,7 +291,7 @@ void acpi_ut_init_stack_ptr_trace(void);
 
 void acpi_ut_track_stack_ptr(void);
 
-void
+__nocapture(2) void
 acpi_ut_trace(u32 line_number,
 	      const char *function_name,
 	      const char *module_name, u32 component_id);
fs/char_dev.c +1 -1
index 44a240c4bb65..3bc97002c86f 100644
@@ -70,7 +70,7 @@ void chrdev_show(struct seq_file *f, off_t offset)
  *
  * Returns a -ve errno on failure.
  */
-static struct char_device_struct *
+static __nocapture(4) struct char_device_struct *
 __register_chrdev_region(unsigned int major, unsigned int baseminor,
 			   int minorct, const char *name)
 {
fs/ntfs/debug.h +3 -3
index 61bf091e32a8..6ac561943118 100644
@@ -30,7 +30,7 @@
 
 extern int debug_msgs;
 
-extern __printf(4, 5)
+extern __printf(4, 5) __nocapture(3)
 void __ntfs_debug(const char *file, int line, const char *function,
 		  const char *format, ...);
 /**
@@ -58,12 +58,12 @@ do {									\
 
 #endif	/* !DEBUG */
 
-extern  __printf(3, 4)
+extern  __printf(3, 4) __nocapture(1)
 void __ntfs_warning(const char *function, const struct super_block *sb,
 		    const char *fmt, ...);
 #define ntfs_warning(sb, f, a...)	__ntfs_warning(__func__, sb, f, ##a)
 
-extern  __printf(3, 4)
+extern  __printf(3, 4) __nocapture(1)
 void __ntfs_error(const char *function, const struct super_block *sb,
 		  const char *fmt, ...);
 #define ntfs_error(sb, f, a...)		__ntfs_error(__func__, sb, f, ##a)
fs/ocfs2/cluster/masklog.h +1 -1
index 308ea0eb35fd..3c16da69605d 100644
@@ -162,7 +162,7 @@ extern struct mlog_bits mlog_and_bits, mlog_not_bits;
 
 #endif
 
-__printf(4, 5)
+__printf(4, 5) __nocapture(2)
 void __mlog_printk(const u64 *m, const char *func, int line,
 		   const char *fmt, ...);
 
include/acpi/acpixf.h +1 -1
index f5e10dd8e86b..9040aafc24a6 100644
@@ -938,7 +938,7 @@ ACPI_MSG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(3)
 /*
  * Debug output
  */
-ACPI_DBG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(6)
+ACPI_DBG_DEPENDENT_RETURN_VOID(ACPI_PRINTF_LIKE(6) __nocapture(3)
 			       void ACPI_INTERNAL_VAR_XFACE
 			       acpi_debug_print(u32 requested_debug_level,
 						u32 line_number,
include/asm-generic/bug.h +4 -3
index 6f96247226a4..f6ae0d76f2e7 100644
@@ -62,13 +62,13 @@ struct bug_entry {
  * to provide better diagnostics.
  */
 #ifndef __WARN_TAINT
-extern __printf(3, 4)
+extern __printf(3, 4) __nocapture(1)
 void warn_slowpath_fmt(const char *file, const int line,
 		       const char *fmt, ...);
-extern __printf(4, 5)
+extern __printf(4, 5) __nocapture(1)
 void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint,
 			     const char *fmt, ...);
-extern void warn_slowpath_null(const char *file, const int line);
+extern __nocapture(1) void warn_slowpath_null(const char *file, const int line);
 #define WANT_WARN_ON_SLOWPATH
 #define __WARN()		warn_slowpath_null(__FILE__, __LINE__)
 #define __WARN_printf(arg...)	warn_slowpath_fmt(__FILE__, __LINE__, arg)
@@ -84,6 +84,7 @@ extern void warn_slowpath_null(const char *file, const int line);
 /* used internally by panic.c */
 struct warn_args;
 
+__nocapture(1, 0)
 void __warn(const char *file, int line, void *caller, unsigned taint,
 	    struct pt_regs *regs, struct warn_args *args);
 
include/drm/drm_drv.h +1 -1
index c4fc49583dc0..ade960c65929 100644
@@ -407,7 +407,7 @@ struct drm_driver {
 	struct list_head legacy_dev_list;
 };
 
-extern __printf(6, 7)
+extern __printf(6, 7) __nocapture(4)
 void drm_dev_printk(const struct device *dev, const char *level,
 		    unsigned int category, const char *function_name,
 		    const char *prefix, const char *format, ...);
include/linux/audit.h +3 -2
index f51fca8d0b6f..4b644ca7311b 100644
@@ -135,7 +135,7 @@ extern void		    audit_log_n_hex(struct audit_buffer *ab,
 					  size_t len);
 extern void		    audit_log_n_string(struct audit_buffer *ab,
 					       const char *buf,
-					       size_t n);
+					       size_t n) __nocapture(2);
 extern void		    audit_log_n_untrustedstring(struct audit_buffer *ab,
 							const char *string,
 							size_t n);
@@ -552,7 +552,8 @@ static inline bool audit_loginuid_set(struct task_struct *tsk)
 	return uid_valid(audit_get_loginuid(tsk));
 }
 
-static inline void audit_log_string(struct audit_buffer *ab, const char *buf)
+static inline __nocapture(2)
+void audit_log_string(struct audit_buffer *ab, const char *buf)
 {
 	audit_log_n_string(ab, buf, strlen(buf));
 }
include/linux/fs.h +5 -3
index 2ba074328894..a1a5f7305ee9 100644
@@ -2424,13 +2424,15 @@ static inline void bd_unlink_disk_holder(struct block_device *bdev,
 #define CHRDEV_MAJOR_HASH_SIZE	255
 /* Marks the bottom of the first segment of free char majors */
 #define CHRDEV_MAJOR_DYN_END 234
-extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
+extern int __nocapture(4)
+alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
 extern int register_chrdev_region(dev_t, unsigned, const char *);
 extern int __register_chrdev(unsigned int major, unsigned int baseminor,
 			     unsigned int count, const char *name,
 			     const struct file_operations *fops);
-extern void __unregister_chrdev(unsigned int major, unsigned int baseminor,
-				unsigned int count, const char *name);
+extern __nocapture(4) void __unregister_chrdev(unsigned int major,
+				unsigned int baseminor, unsigned int count,
+				const char *name);
 extern void unregister_chrdev_region(dev_t, unsigned);
 extern void chrdev_show(struct seq_file *,off_t);
 
include/linux/printk.h +1 -1
index 3472cc6b7a60..87a1d8fb5cc1 100644
@@ -187,7 +187,7 @@ __printf(1, 2) __cold int printk_deferred(const char *fmt, ...);
  * with all other unrelated printk_ratelimit() callsites.  Instead use
  * printk_ratelimited() or plain old __ratelimit().
  */
-extern int __printk_ratelimit(const char *func);
+extern int __printk_ratelimit(const char *func) __nocapture(1);
 #define printk_ratelimit() __printk_ratelimit(__func__)
 extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
 				   unsigned int interval_msec);
include/linux/ratelimit.h +2 -1
index 56375edf2ed2..67864ad91978 100644
@@ -72,7 +72,8 @@ ratelimit_set_flags(struct ratelimit_state *rs, unsigned long flags)
 
 extern struct ratelimit_state printk_ratelimit_state;
 
-extern int ___ratelimit(struct ratelimit_state *rs, const char *func);
+extern __nocapture(2)
+int ___ratelimit(struct ratelimit_state *rs, const char *func);
 #define __ratelimit(state) ___ratelimit(state, __func__)
 
 #ifdef CONFIG_PRINTK
include/linux/string.h +39 -36

161 lines not on this page · raw message

lib/vsprintf.c +3 -3
index 0967771d8f7f..a192761d338a 100644
@@ -118,7 +118,7 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base)
 }
 EXPORT_SYMBOL(simple_strtoll);
 
-static noinline_for_stack
+static noinline_for_stack __nocapture(1)
 int skip_atoi(const char **s)
 {
 	int i = 0;
@@ -1570,7 +1570,7 @@ int kptr_restrict __read_mostly;
  * function pointers are really function descriptors, which contain a
  * pointer to the real address.
  */
-static noinline_for_stack
+static noinline_for_stack __nocapture(1)
 char *pointer(const char *fmt, char *buf, char *end, void *ptr,
 	      struct printf_spec spec)
 {
@@ -1749,7 +1749,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
  * @precision: precision of a number
  * @qualifier: qualifier of a number (long, size_t, ...)
  */
-static noinline_for_stack
+static noinline_for_stack __nocapture(1)
 int format_decode(const char *fmt, struct printf_spec *spec)
 {
 	const char *start = fmt;
mm/util.c +1 -1
index a700e3fb1587..e91250dabf49 100644
@@ -17,7 +17,7 @@
 
 #include "internal.h"
 
-static inline int is_kernel_rodata(const void *addr)
+static inline __nocapture(1) int is_kernel_rodata(const void *addr)
 {
 	return (unsigned long)addr >= (unsigned long)__start_rodata &&
 		(unsigned long)addr < (unsigned long)__end_rodata;
security/integrity/integrity.h +1 -1
index 24520b4ef3b0..b89448a69cf4 100644
@@ -177,7 +177,7 @@ static inline void evm_load_x509(void)
 
 #ifdef CONFIG_INTEGRITY_AUDIT
 /* declarations */
-void integrity_audit_msg(int audit_msgno, struct inode *inode,
+void __nocapture(4) integrity_audit_msg(int audit_msgno, struct inode *inode,
 			 const unsigned char *fname, const char *op,
 			 const char *cause, int result, int info);
 #else
Signature · 1 line
2.7.4
author
#16 lore raw

PATCH v5 4/4 initify: Mark functions with the __unverified_nocapture attribute

In reply to Kees Cook

From: Emese Revfy <[email protected]>

The initify plugin attempts to analyze function arguments that have been marked correctly with the __nocapture attribute. However, due to code complexity, this is not always possible to verify. As a result, some __nocapture attributes need to be marked as excluded from the automatic verification. To do this, the __unverified_nocapture attribute is added. It is intedned to only be used on function parameters that are difficult for the plugin to analyze.

---
 include/linux/compiler-gcc.h | 8 ++++++++
 include/linux/compiler.h     | 4 ++++
 lib/vsprintf.c               | 4 ++--
 3 files changed, 14 insertions(+), 2 deletions(-)
include/linux/compiler-gcc.h +8 -0
index cd4e9ffb00a7..fc0495e849ff 100644
@@ -204,9 +204,17 @@
  * been unmapped from memory. In order to identify functions that are confirmed
  * to not capture their arguments, the __nocapture() attribute is used so that
  * initify can better identify candidate variables.
+ *
+ * Arguments marked in this way are verified by the plugin, but sometimes
+ * code complexity and other limitiations will cause initify to not be able
+ * to check it correctly. For these cases, the __unverified_nocapture
+ * attribute can be added to disable this checking, overriding the plugin
+ * logic for cases that have been manually verified. This should not need
+ * to be used very often.
  */
 #ifdef INITIFY_PLUGIN
 #define __nocapture(...) __attribute__((nocapture(__VA_ARGS__)))
+#define __unverified_nocapture(...) __attribute__((unverified_nocapture(__VA_ARGS__)))
 #endif
 
 /*
include/linux/compiler.h +4 -0
index 8b3dcc790bb6..1bde420f07bb 100644
@@ -437,6 +437,10 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 # define __nocapture(...)
 #endif
 
+#ifndef __unverified_nocapture
+# define __unverified_nocapture(...)
+#endif
+
 /*
  * Tell gcc if a function is cold. The compiler will assume any path
  * directly leading to the call is unlikely.
lib/vsprintf.c +2 -2
index a192761d338a..cb964b51f9f8 100644
@@ -118,7 +118,7 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base)
 }
 EXPORT_SYMBOL(simple_strtoll);
 
-static noinline_for_stack __nocapture(1)
+static noinline_for_stack __nocapture(1) __unverified_nocapture(1)
 int skip_atoi(const char **s)
 {
 	int i = 0;
@@ -1570,7 +1570,7 @@ int kptr_restrict __read_mostly;
  * function pointers are really function descriptors, which contain a
  * pointer to the real address.
  */
-static noinline_for_stack __nocapture(1)
+static noinline_for_stack __nocapture(1) __unverified_nocapture(1)
 char *pointer(const char *fmt, char *buf, char *end, void *ptr,
 	      struct printf_spec spec)
 {
Signature · 1 line
2.7.4