Skip to contentSkip to conversation

Introduce the initify gcc plugin

PATCH New Emese Revfy 2 participants 15 messages Jul 26, 2016 – Jul 27, 2016

Subsystems (28)
lore
Share & tools
lore
#0 lore raw

v3 cover Introduce the initify gcc plugin

I would like to introduce 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.
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.

The plugin supports all gcc versions from 4.5 to 6.0.

I made some changes on top of the PaX version (since March 6.). These are the important ones:
* move all local strings to init.rodata.str and exit.rodata.str (not just __func__)
* report all initified strings and functions (GCC_PLUGIN_INITIFY_VERBOSE config option)
* automatically discover init/exit functions and apply the __init or __exit attributes on them

You can find more about the changes here:
https://github.com/ephox-gcc-plugins/initify

This patch set is based on next-20160721.

Some statistics about the plugin:

On allyes config (amd64, gcc-6):
* 8412 initified strings
* 167 initified functions

On allmod config (i386, gcc-6):
* 8597 initified strings
* 159 initified functions

On allyes config (amd64, gcc-6):

section vanilla vanilla + initify change
-----------------------------------------------------------------------
.rodata 21746728 (0x14bd428) 21488680 (0x147e428) -258048
.init.data 1338376 (0x146c08) 1683016 (0x19ae48) +344640
.text 78270904 (0x4aa51b8) 78228280 (0x4a9ab38) -42624

.init.text	 1184725  (0x1213d5)	 1223257  (0x12aa59)	 +38532
.exit.data	     104  (0x000068)	   17760  (0x004560)	 +17656
.exit.text	  174473  (0x02a989)	  175763  (0x02ae93)	  +1290

FileSiz (vanilla) FileSiz (vanilla + initify) change
------------------------------------------------------------------------
00 102936576 (0x622b000) 102678528 (0x61ec000) -258048
03 28680192 (0x1b5a000) 29081600 (0x1bbc000) +401408

00 .text .notes __ex_table .rodata __bug_table .pci_fixup .builtin_fw
.tracedata __ksymtab __ksymtab_gpl __ksymtab_strings __init_rodata __param __modver
03 .init.text .altinstr_aux .init.data .x86_cpu_dev.init
.parainstructions .altinstructions .altinstr_replacement .iommu_table .apicdrivers .exit.text .exit.data .smp_locks .bss .brk

On defconfig (amd64, gcc-6):
* 1957 initified strings
* 29 initified functions

On defconfig (amd64, gcc-6):

section vanilla vanilla + initify change
-----------------------------------------------------------------------
.rodata 2524240 (0x268450) 2462800 (0x259450) -61440
.init.data 560256 (0x088c80) 644000 (0x09d3a0) +83744
.text 9377367 (0x8f1657) 9373079 (0x8f0597) -4288
.init.text 438586 (0x06b13a) 441828 (0x06bde4) +3242
.exit.data 0 832 (0x000340) +832
.exit.text 8857 (0x002299) 8857 (0x002299) 0

FileSiz (vanilla) FileSiz (vanilla + initify) change
------------------------------------------------------------------------
00 13398016 (0xcc7000) 13336576 (0xcb8000) -61440
03 2203648 (0x21a000) 2293760 (0x230000) +90112

00 .text .notes __ex_table .rodata __bug_table .pci_fixup .builtin_fw
.tracedata __ksymtab __ksymtab_gpl __ksymtab_strings __init_rodata __param __modver
03 .init.text .altinstr_aux .init.data .x86_cpu_dev.init
.parainstructions .altinstructions .altinstr_replacement .iommu_table .apicdrivers .exit.text .exit.data .smp_locks .bss .brk

Emese Revfy (7):
Move type casts into is_kernel_rodata
Split up struct warn_args to enable dataflow verification by the initify plugin Constify some function parameters
Add the initify gcc plugin
Mark functions with the __nocapture attribute
Mark a few functions with the printf attribute
Mark functions with the __unverified_nocapture attribute

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

---
 arch/Kconfig                         |   35 +
 arch/arm/include/asm/string.h        |   10 +-
 arch/arm64/include/asm/string.h      |   25 +-
 arch/powerpc/include/asm/string.h    |   19 +-
 arch/x86/Kconfig                     |    1 +
 arch/x86/include/asm/string_32.h     |   25 +-
 arch/x86/include/asm/string_64.h     |   20 +-
 arch/x86/kernel/hpet.c               |    2 +-
 arch/x86/lib/Makefile                |    4 +
 drivers/acpi/acpica/acutils.h        |    2 +-
 drivers/isdn/hisax/config.c          |   16 +-
 drivers/isdn/hisax/hisax.h           |    4 +-
 drivers/scsi/esas2r/esas2r_log.h     |    4 +-
 fs/char_dev.c                        |    2 +-
 fs/ntfs/debug.h                      |    6 +-
 fs/ocfs2/cluster/masklog.h           |    2 +-
 include/acpi/acpiosxf.h              |    3 +-
 include/acpi/acpixf.h                |    2 +-
 include/asm-generic/bug.h            |   12 +-
 include/asm-generic/vmlinux.lds.h    |    2 +
 include/drm/drmP.h                   |    2 +-
 include/linux/audit.h                |    5 +-
 include/linux/compiler-gcc.h         |   15 +
 include/linux/compiler.h             |    8 +
 include/linux/fs.h                   |    8 +-
 include/linux/printk.h               |    2 +-
 include/linux/ratelimit.h            |    3 +-
 include/linux/string.h               |   75 +-
 kernel/panic.c                       |   32 +-
 lib/bug.c                            |    2 +-
 lib/vsprintf.c                       |    6 +-
 mm/util.c                            |   10 +-
 scripts/Makefile.gcc-plugins         |    9 +
 scripts/gcc-plugins/gcc-common.h     |   41 +
 scripts/gcc-plugins/initify_plugin.c | 1880 ++++++++++++++++++++++++++++++++++
 security/integrity/integrity.h       |    2 +-
 36 files changed, 2146 insertions(+), 150 deletions(-)
#1 lore raw

PATCH v3 1/7 Move type casts into is_kernel_rodata

so that its parameter can be marked as nocapture.

---
 mm/util.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
mm/util.c +5 -5
index 662cddf..d95f10b 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.8.1
#2 lore raw

PATCH v3 2/7 Split up struct warn_args

In reply to Emese Revfy

to enable dataflow verification by the initify plugin. This allows marking warn_slowpath* parameters as nocapture and compile time verification of the related dataflows.

---
 include/asm-generic/bug.h |  5 +----
 kernel/panic.c            | 32 ++++++++++++--------------------
 lib/bug.c                 |  2 +-
 3 files changed, 14 insertions(+), 25 deletions(-)
include/asm-generic/bug.h +1 -4
index 6f96247..3048d10 100644
@@ -81,11 +81,8 @@ extern void warn_slowpath_null(const char *file, const int line);
 	do { printk(arg); __WARN_TAINT(taint); } while (0)
 #endif
 
-/* used internally by panic.c */
-struct warn_args;
-
 void __warn(const char *file, int line, void *caller, unsigned taint,
-	    struct pt_regs *regs, struct warn_args *args);
+	    struct pt_regs *regs, const char *fmt, va_list args);
 
 #ifndef WARN_ON
 #define WARN_ON(condition) ({						\
kernel/panic.c +12 -20
index ca8cea1..993ad20 100644
@@ -475,13 +475,8 @@ void oops_exit(void)
 	kmsg_dump(KMSG_DUMP_OOPS);
 }
 
-struct warn_args {
-	const char *fmt;
-	va_list args;
-};
-
 void __warn(const char *file, int line, void *caller, unsigned taint,
-	    struct pt_regs *regs, struct warn_args *args)
+	    struct pt_regs *regs, const char *fmt, va_list args)
 {
 	disable_trace_on_warning();
 
@@ -495,8 +490,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 		pr_warn("WARNING: CPU: %d PID: %d at %pS\n",
 			raw_smp_processor_id(), current->pid, caller);
 
-	if (args)
-		vprintk(args->fmt, args->args);
+	if (fmt)
+		vprintk(fmt, args);
 
 	if (panic_on_warn) {
 		/*
@@ -525,31 +520,28 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 #ifdef WANT_WARN_ON_SLOWPATH
 void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
 {
-	struct warn_args args;
+	va_list args;
 
-	args.fmt = fmt;
-	va_start(args.args, fmt);
-	__warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL,
-	       &args);
-	va_end(args.args);
+	va_start(args, fmt);
+	__warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, fmt, args);
+	va_end(args);
 }
 EXPORT_SYMBOL(warn_slowpath_fmt);
 
 void warn_slowpath_fmt_taint(const char *file, int line,
 			     unsigned taint, const char *fmt, ...)
 {
-	struct warn_args args;
+	va_list args;
 
-	args.fmt = fmt;
-	va_start(args.args, fmt);
-	__warn(file, line, __builtin_return_address(0), taint, NULL, &args);
-	va_end(args.args);
+	va_start(args, fmt);
+	__warn(file, line, __builtin_return_address(0), taint, NULL, fmt, args);
+	va_end(args);
 }
 EXPORT_SYMBOL(warn_slowpath_fmt_taint);
 
 void warn_slowpath_null(const char *file, int line)
 {
-	__warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, NULL);
+	__warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, NULL, NULL);
 }
 EXPORT_SYMBOL(warn_slowpath_null);
 #endif
lib/bug.c +1 -1
index bc3656e..c8bdebb 100644
@@ -168,7 +168,7 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
 	if (warning) {
 		/* this is a WARN_ON rather than BUG/BUG_ON */
 		__warn(file, line, (void *)bugaddr, BUG_GET_TAINT(bug), regs,
-		       NULL);
+		       NULL, NULL);
 		return BUG_TRAP_TYPE_WARN;
 	}
 
Signature · 1 line
2.8.1
#6 lore raw

PATCH v3 3/7 Constify some function parameters

In reply to Emese Revfy

Initify needs const pointer types, the initify plugin caught some __printf arguments that weren't const yet.

---
 drivers/isdn/hisax/config.c | 16 ++++++++--------
 drivers/isdn/hisax/hisax.h  |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/isdn/hisax/config.c +8 -8
index bf04d2a..2d12c6c 100644
@@ -659,7 +659,7 @@ int jiftime(char *s, long mark)
 
 static u_char tmpbuf[HISAX_STATUS_BUFSIZE];
 
-void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
+void VHiSax_putstatus(struct IsdnCardState *cs, char *head, const char *fmt,
 		      va_list args)
 {
 	/* if head == NULL the fmt contains the full info */
@@ -669,23 +669,24 @@ void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
 	u_char		*p;
 	isdn_ctrl	ic;
 	int		len;
+	const u_char	*data;
 
 	if (!cs) {
 		printk(KERN_WARNING "HiSax: No CardStatus for message");
 		return;
 	}
 	spin_lock_irqsave(&cs->statlock, flags);
-	p = tmpbuf;
 	if (head) {
+		p = tmpbuf;
 		p += jiftime(p, jiffies);
 		p += sprintf(p, " %s", head);
 		p += vsprintf(p, fmt, args);
 		*p++ = '\n';
 		*p = 0;
 		len = p - tmpbuf;
-		p = tmpbuf;
+		data = tmpbuf;
 	} else {
-		p = fmt;
+		data = fmt;
 		len = strlen(fmt);
 	}
 	if (len > HISAX_STATUS_BUFSIZE) {
@@ -699,13 +700,12 @@ void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
 	if (i >= len)
 		i = len;
 	len -= i;
-	memcpy(cs->status_write, p, i);
+	memcpy(cs->status_write, data, i);
 	cs->status_write += i;
 	if (cs->status_write > cs->status_end)
 		cs->status_write = cs->status_buf;
-	p += i;
 	if (len) {
-		memcpy(cs->status_write, p, len);
+		memcpy(cs->status_write, data + i, len);
 		cs->status_write += len;
 	}
 #ifdef KERNELSTACK_DEBUG
@@ -729,7 +729,7 @@ void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
 	}
 }
 
-void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...)
+void HiSax_putstatus(struct IsdnCardState *cs, char *head, const char *fmt, ...)
 {
 	va_list args;
 
drivers/isdn/hisax/hisax.h +2 -2
index 6ead6314..338d040 100644
@@ -1288,9 +1288,9 @@ int jiftime(char *s, long mark);
 int HiSax_command(isdn_ctrl *ic);
 int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb);
 __printf(3, 4)
-void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...);
+void HiSax_putstatus(struct IsdnCardState *cs, char *head, const char *fmt, ...);
 __printf(3, 0)
-void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, va_list args);
+void VHiSax_putstatus(struct IsdnCardState *cs, char *head, const char *fmt, va_list args);
 void HiSax_reportcard(int cardnr, int sel);
 int QuickHex(char *txt, u_char *p, int cnt);
 void LogFrame(struct IsdnCardState *cs, u_char *p, int size);
Signature · 1 line
2.8.1
#7 lore raw

PATCH v3 4/7 Add the initify gcc plugin

In reply to Emese Revfy

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 has 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.
It reduces memory usage. 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.

---
 arch/Kconfig                         |   35 +
 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         |    9 +
 scripts/gcc-plugins/gcc-common.h     |   41 +
 scripts/gcc-plugins/initify_plugin.c | 1883 ++++++++++++++++++++++++++++++++++
 9 files changed, 1993 insertions(+)
 create mode 100644 scripts/gcc-plugins/initify_plugin.c
arch/Kconfig +35 -0
index 88673c2..41eb562 100644
@@ -417,6 +417,41 @@ 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 is the part of grsecurity/PaX. More information at:
+	   * https://grsecurity.net/
+	   * https://pax.grsecurity.net/
+
+config HAVE_GCC_PLUGIN_INITIFY_INIT_EXIT
+	bool
+	depends on GCC_PLUGINS
+	help
+	  Move functions to the exit section if they are called by __init and
+	  __exit functions too.
+
+config GCC_PLUGIN_INITIFY_INIT_EXIT
+	bool
+	depends on GCC_PLUGIN_INITIFY && HAVE_GCC_PLUGIN_INITIFY_INIT_EXIT
+
+config GCC_PLUGIN_INITIFY_VERBOSE
+	bool "Verbose"
+	depends on GCC_PLUGINS
+	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_CC_STACKPROTECTOR
 	bool
 	help
arch/x86/Kconfig +1 -0
index c580d8c..921a13c 100644
@@ -114,6 +114,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_GENERIC_DMA_COHERENT	if X86_32
 	select HAVE_HW_BREAKPOINT
 	select HAVE_IDE
arch/x86/lib/Makefile +4 -0
index 34a7413..b98b8fd 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 2456397..6e292f9 100644
@@ -531,6 +531,7 @@
 	MEM_DISCARD(init.data)						\
 	KERNEL_CTORS()							\
 	MCOUNT_REC()							\
+	*(.init.rodata.str)						\
 	*(.init.rodata)							\
 	FTRACE_EVENTS()							\
 	TRACE_SYSCALLS()						\
@@ -558,6 +559,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 0ef8329..6697ea3 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 0adcfc2..391b48b 100644
@@ -412,6 +412,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 +9 -0
index 1f922df..4a73a20 100644
@@ -12,6 +12,14 @@ ifdef CONFIG_GCC_PLUGINS
     DISABLE_LATENT_ENTROPY_PLUGIN			+= -fplugin-arg-latent_entropy_plugin-disable
   endif
 
+  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
+
   ifdef CONFIG_GCC_PLUGIN_SANCOV
     ifeq ($(CFLAGS_KCOV),)
       # It is needed because of the gcc-plugin.sh and gcc version checks.
@@ -28,6 +36,7 @@ ifdef CONFIG_GCC_PLUGINS
   GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))
 
   export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR 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/gcc-common.h +41 -0

65 lines not on this page · raw message

scripts/gcc-plugins/initify_plugin.c new file +1883 -0

1,883 lines not on this page · raw message

Signature · 1 line
2.8.1
#8 lore raw

PATCH v3 5/7 Mark functions with the __nocapture attribute

In reply to Emese Revfy

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.

I couldn't test the arm, arm64 and powerpc architectures.

---
 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  | 20 +++++------
 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/drmP.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, 119 insertions(+), 108 deletions(-)
arch/arm/include/asm/string.h +5 -5
index cf4f3aa..8f2f2d9 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 2eb714c..188a102 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 da3cdff..ba08cf4 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 3d3e835..db6fe4c 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 +10 -10
index 90dbbd9..607d3ba 100644
@@ -27,8 +27,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
@@ -56,14 +56,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__)
 
@@ -89,7 +89,7 @@ int strcmp(const char *cs, const char *ct);
  *
  * Return 0 for success, -EFAULT for fail
  */
-int memcpy_mcsafe(void *dst, const void *src, size_t cnt);
+int memcpy_mcsafe(void *dst, const void *src, size_t cnt) __nocapture(2);
 
 #endif /* __KERNEL__ */
 
arch/x86/kernel/hpet.c +1 -1
index ed16e58..dce9c02 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 a7dbb2b..93e986e 100644
@@ -274,7 +274,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 6edd825..e8cbd2d 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 61bf091..6ac5619 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 308ea0e..3c16da6 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 1ff3a76..c52f3b4 100644
@@ -914,7 +914,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 3048d10..13a9241 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)
@@ -81,6 +81,7 @@ extern void warn_slowpath_null(const char *file, const int line);
 	do { printk(arg); __WARN_TAINT(taint); } while (0)
 #endif
 
+__nocapture(1, 6)
 void __warn(const char *file, int line, void *caller, unsigned taint,
 	    struct pt_regs *regs, const char *fmt, va_list args);
 
include/drm/drmP.h +1 -1
index d377865..485683b 100644
@@ -134,7 +134,7 @@ struct dma_buf_attachment;
 #define DRM_UT_ATOMIC		0x10
 #define DRM_UT_VBL		0x20
 
-extern __printf(2, 3)
+extern __printf(2, 3) __nocapture(1)
 void drm_ut_debug_printk(const char *function_name,
 			 const char *format, ...);
 extern __printf(1, 2)
include/linux/audit.h +3 -2
index 9d4443f..730485b 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 fc3f5b0..be20fb9 100644
@@ -2478,13 +2478,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 8dc155d..c82d437 100644
@@ -171,7 +171,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 57c9e06..fe14126 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 0967771..a192761 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 d95f10b..985abc1 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 24520b4..b89448a 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.8.1
#9 lore raw

PATCH v3 6/7 Mark a few functions with the printf attribute

In reply to Emese Revfy

This allows not only compile time format string checking but can also increase the coverage of the initify plugin.

---
 drivers/scsi/esas2r/esas2r_log.h | 4 ++--
 include/acpi/acpiosxf.h          | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/esas2r/esas2r_log.h +2 -2
index 7b6397b..75b9d23 100644
@@ -61,8 +61,8 @@ enum {
 #endif
 };
 
-int esas2r_log(const long level, const char *format, ...);
-int esas2r_log_dev(const long level,
+__printf(2, 3) int esas2r_log(const long level, const char *format, ...);
+__printf(3, 4) int esas2r_log_dev(const long level,
 		   const struct device *dev,
 		   const char *format,
 		   ...);
include/acpi/acpiosxf.h +2 -1
index 562603d..7ee4475 100644
@@ -337,11 +337,12 @@ acpi_status acpi_os_signal(u32 function, void *info);
  * Debug print routines
  */
 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_printf
+__printf(1, 2)
 void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *format, ...);
 #endif
 
 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_vprintf
-void acpi_os_vprintf(const char *format, va_list args);
+__printf(1, 0) void acpi_os_vprintf(const char *format, va_list args);
 #endif
 
 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
Signature · 1 line
2.8.1
#14 lore raw

PATCH v3 7/7 Mark functions with the __unverified_nocapture attribute

In reply to Emese Revfy

This attribute disables the compile data flow verification of the designated nocapture parameters of the function. Use it only on function parameters that are difficult for the plugin to analyze.

---
 include/linux/compiler-gcc.h | 1 +
 include/linux/compiler.h     | 4 ++++
 lib/vsprintf.c               | 4 ++--
 3 files changed, 7 insertions(+), 2 deletions(-)
include/linux/compiler-gcc.h +1 -0
index 6697ea3..76797b9 100644
@@ -207,6 +207,7 @@
  */
 #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 391b48b..f0b4156 100644
@@ -416,6 +416,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 a192761..cb964b5 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.8.1
#10 lore raw

Re: [PATCH v3 6/7] Mark a few functions with the printf attribute

In reply to Emese Revfy
url: https://github.com/0day-ci/linux/commits/Emese-Revfy/Introduce-the-initify-gcc-plugin/20160727-084514 config: x86_64-randconfig-s1-07270838 (attached as .config) compiler: gcc-4.4 (Debian…

Hi,

[auto build test WARNING on next-20160726]
[cannot apply to stable/master linus/master linux/master v4.7-rc7 v4.7-rc6 v4.7-rc5 v4.7] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Emese-Revfy/Introduce-the-initify-gcc-plugin/20160727-084514
config: x86_64-randconfig-s1-07270838 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

drivers/acpi/acpica/utdebug.c: In function 'acpi_debug_print':

>> drivers/acpi/acpica/utdebug.c:192: warning: format '%04ld' expects type 'long int', but argument 3 has type 'u32'
--
   drivers/acpi/acpica/dbhistry.c: In function 'acpi_db_display_history':
>> drivers/acpi/acpica/dbhistry.c:162: warning: format '%3ld' expects type 'long int', but argument 2 has type 'u32'
--
   drivers/acpi/acpica/dbinput.c: In function 'acpi_db_get_line':
>> drivers/acpi/acpica/dbinput.c:610: warning: format '%u' expects type 'unsigned int', but argument 2 has type 'long unsigned int'
   drivers/acpi/acpica/dbinput.c: In function 'acpi_db_command_dispatch':
>> drivers/acpi/acpica/dbinput.c:866: warning: format '%8.8lX' expects type 'long unsigned int', but argument 2 has type 'u32'

drivers/acpi/acpica/dbinput.c:869: warning: format '%8.8lX' expects type 'long unsigned int', but argument 2 has type 'u32' drivers/acpi/acpica/dbinput.c:876: warning: format '%8.8lX' expects type 'long unsigned int', but argument 2 has type 'u32' drivers/acpi/acpica/dbinput.c:876: warning: format '%8.8lX' expects type 'long unsigned int', but argument 3 has type 'u32' drivers/acpi/acpica/dbinput.c:883: warning: format '%8.8lX' expects type 'long unsigned int', but argument 2 has type 'u32' drivers/acpi/acpica/dbinput.c:883: warning: format '%8.8lX' expects type 'long unsigned int', but argument 3 has type 'u32'
--
drivers/acpi/acpica/dbstats.c: In function 'acpi_db_display_statistics':

>> drivers/acpi/acpica/dbstats.c:383: warning: format '% 10ld' expects type 'long int', but argument 3 has type 'int'
   drivers/acpi/acpica/dbstats.c:383: warning: format '% 10ld' expects type 'long int', but argument 4 has type 'int'
   drivers/acpi/acpica/dbstats.c:388: warning: format '% 10ld' expects type 'long int', but argument 3 has type 'int'
   drivers/acpi/acpica/dbstats.c:388: warning: format '% 10ld' expects type 'long int', but argument 4 has type 'int'
>> drivers/acpi/acpica/dbstats.c:391: warning: format '% 10ld' expects type 'long int', but argument 3 has type 'u32'
   drivers/acpi/acpica/dbstats.c:391: warning: format '% 10ld' expects type 'long int', but argument 4 has type 'u32'
>> drivers/acpi/acpica/dbstats.c:419: warning: format '% 7ld' expects type 'long int', but argument 2 has type 'u32'
   drivers/acpi/acpica/dbstats.c:421: warning: format '% 7ld' expects type 'long int', but argument 2 has type 'u32'
   drivers/acpi/acpica/dbstats.c:429: warning: format '% 7ld' expects type 'long int', but argument 3 has type 'u32'
>> drivers/acpi/acpica/dbstats.c:438: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int'

drivers/acpi/acpica/dbstats.c:440: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:442: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:444: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:446: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:448: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:450: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:452: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:454: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:456: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:458: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:460: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:462: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:464: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:466: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:468: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:470: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:472: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:474: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:476: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:478: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:480: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:485: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:487: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:489: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:491: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:493: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:495: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:500: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:502: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:504: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:506: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:508: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:510: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:512: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:514: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:516: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int' drivers/acpi/acpica/dbstats.c:518: warning: format '%3d' expects type 'int', but argument 2 has type 'long unsigned int'

vim +192 drivers/acpi/acpica/utdebug.c

^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  176  	thread_id = acpi_os_get_thread_id();
0dfaaa3d drivers/acpi/acpica/utdebug.c    Bob Moore      2016-03-24  177  	if (thread_id != acpi_gbl_previous_thread_id) {
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  178  		if (ACPI_LV_THREADS & acpi_dbg_level) {
4be44fcd drivers/acpi/utilities/utdebug.c Len Brown      2005-08-05  179  			acpi_os_printf
28eb3fcf drivers/acpi/acpica/utdebug.c    Lin Ming       2010-09-15  180  			    ("\n**** Context Switch from TID %u to TID %u ****\n\n",
0dfaaa3d drivers/acpi/acpica/utdebug.c    Bob Moore      2016-03-24  181  			     (u32)acpi_gbl_previous_thread_id, (u32)thread_id);
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  182  		}
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  183  
0dfaaa3d drivers/acpi/acpica/utdebug.c    Bob Moore      2016-03-24  184  		acpi_gbl_previous_thread_id = thread_id;
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  185  		acpi_gbl_nesting_level = 0;
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  186  	}
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  187  
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  188  	/*
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  189  	 * Display the module name, current line number, thread ID (if requested),
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  190  	 * current procedure nesting level, and the current procedure name
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  191  	 */
2856846e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-09-23 @192  	acpi_os_printf("%9s-%04ld ", module_name, line_number);
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  193  
5076f005 drivers/acpi/acpica/utdebug.c    Bob Moore      2014-01-08  194  #ifdef ACPI_APPLICATION
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  195  	/*
5076f005 drivers/acpi/acpica/utdebug.c    Bob Moore      2014-01-08  196  	 * For acpi_exec/iASL only, emit the thread ID and nesting level.
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  197  	 * Note: nesting level is really only useful during a single-thread
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  198  	 * execution. Otherwise, multiple threads will keep resetting the
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  199  	 * level.
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  200  	 */

:::::: The code at line 192 was first introduced by commit
:::::: 2856846e3a7bee02ce6b498c760376061e41aaed ACPICA: Debug output: small formatting update, no functional change.

:::::: TO: Bob Moore <[email protected]> :::::: CC: Rafael J. Wysocki <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

Re: [PATCH v3 2/7] Split up struct warn_args

In reply to Emese Revfy
url: https://github.com/0day-ci/linux/commits/Emese-Revfy/Introduce-the-initify-gcc-plugin/20160727-084514 config: tile-allyesconfig (attached as .config) compiler: tilegx-linux-gcc (GCC) 4.6.2…

Hi,

[auto build test ERROR on next-20160726]
[also build test ERROR on v4.7]
[cannot apply to stable/master linus/master linux/master v4.7-rc7 v4.7-rc6 v4.7-rc5] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Emese-Revfy/Introduce-the-initify-gcc-plugin/20160727-084514
config: tile-allyesconfig (attached as .config)
compiler: tilegx-linux-gcc (GCC) 4.6.2
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=tile

All errors (new ones prefixed by >>):

kernel/panic.c: In function 'warn_slowpath_null':

>> kernel/panic.c:544:2: error: incompatible type for argument 7 of '__warn'

kernel/panic.c:478:6: note: expected 'va_list' but argument is of type 'void *'

vim +/__warn +544 kernel/panic.c

538 va_end(args);
539 }
540 EXPORT_SYMBOL(warn_slowpath_fmt_taint);
541
542 void warn_slowpath_null(const char *file, int line)
543 {

 > 544		__warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, NULL, NULL);

545 }
546 EXPORT_SYMBOL(warn_slowpath_null);
547 #endif

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#11 lore raw

Re: [PATCH v3 6/7] Mark a few functions with the printf attribute

In reply to Emese Revfy
url: https://github.com/0day-ci/linux/commits/Emese-Revfy/Introduce-the-initify-gcc-plugin/20160727-084514 config: x86_64-randconfig-s0-07270838 (attached as .config) compiler: gcc-4.4 (Debian…

Hi,

[auto build test WARNING on next-20160726]
[cannot apply to stable/master linus/master linux/master v4.7-rc7 v4.7-rc6 v4.7-rc5 v4.7] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Emese-Revfy/Introduce-the-initify-gcc-plugin/20160727-084514
config: x86_64-randconfig-s0-07270838 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

drivers/scsi/esas2r/esas2r_init.c: In function 'esas2r_claim_interrupts':

>> drivers/scsi/esas2r/esas2r_init.c:241: warning: format '%x' expects type 'unsigned int', but argument 6 has type 'long unsigned int'
--
   drivers/scsi/esas2r/esas2r_ioctl.c: In function 'esas2r_ioctl_handler':
>> drivers/scsi/esas2r/esas2r_ioctl.c:1305: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'
--
   drivers/scsi/esas2r/esas2r_main.c: In function 'write_hw':
>> drivers/scsi/esas2r/esas2r_main.c:202: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'
   drivers/scsi/esas2r/esas2r_main.c: In function 'esas2r_dev_targ_reset':
>> drivers/scsi/esas2r/esas2r_main.c:1191: warning: format '%d' expects type 'int', but argument 4 has type 'u64'

vim +241 drivers/scsi/esas2r/esas2r_init.c

26780d9e Bradley Grove      2013-08-23  225  			   "unknown interrupt_mode %d requested, "
26780d9e Bradley Grove      2013-08-23  226  			   "falling back to legacy interrupt",
26780d9e Bradley Grove      2013-08-23  227  			   interrupt_mode);
26780d9e Bradley Grove      2013-08-23  228  		goto use_legacy_interrupts;
26780d9e Bradley Grove      2013-08-23  229  	}
26780d9e Bradley Grove      2013-08-23  230  }
26780d9e Bradley Grove      2013-08-23  231  
26780d9e Bradley Grove      2013-08-23  232  static void esas2r_claim_interrupts(struct esas2r_adapter *a)
26780d9e Bradley Grove      2013-08-23  233  {
4909cc2b Michael Opdenacker 2014-03-05  234  	unsigned long flags = 0;
26780d9e Bradley Grove      2013-08-23  235  
26780d9e Bradley Grove      2013-08-23  236  	if (a->intr_mode == INTR_MODE_LEGACY)
26780d9e Bradley Grove      2013-08-23  237  		flags |= IRQF_SHARED;
26780d9e Bradley Grove      2013-08-23  238  
26780d9e Bradley Grove      2013-08-23  239  	esas2r_log(ESAS2R_LOG_INFO,
26780d9e Bradley Grove      2013-08-23  240  		   "esas2r_claim_interrupts irq=%d (%p, %s, %x)",
26780d9e Bradley Grove      2013-08-23 @241  		   a->pcid->irq, a, a->name, flags);
26780d9e Bradley Grove      2013-08-23  242  
26780d9e Bradley Grove      2013-08-23  243  	if (request_irq(a->pcid->irq,
26780d9e Bradley Grove      2013-08-23  244  			(a->intr_mode ==
26780d9e Bradley Grove      2013-08-23  245  			 INTR_MODE_LEGACY) ? esas2r_interrupt :
26780d9e Bradley Grove      2013-08-23  246  			esas2r_msi_interrupt,
26780d9e Bradley Grove      2013-08-23  247  			flags,
26780d9e Bradley Grove      2013-08-23  248  			a->name,
26780d9e Bradley Grove      2013-08-23  249  			a)) {

:::::: The code at line 241 was first introduced by commit
:::::: 26780d9e12edf45c0b98315de272b1feff5a8e93 [SCSI] esas2r: ATTO Technology ExpressSAS 6G SAS/SATA RAID Adapter Driver

:::::: TO: Bradley Grove <[email protected]> :::::: CC: James Bottomley <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#12 lore raw

Re: [PATCH v3 6/7] Mark a few functions with the printf attribute

In reply to Emese Revfy
url: https://github.com/0day-ci/linux/commits/Emese-Revfy/Introduce-the-initify-gcc-plugin/20160727-084514 config: x86_64-randconfig-s3-07270832 (attached as .config) compiler: gcc-6 (Debian…

Hi,

[auto build test WARNING on next-20160726]
[cannot apply to stable/master linus/master linux/master v4.7-rc7 v4.7-rc6 v4.7-rc5 v4.7] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Emese-Revfy/Introduce-the-initify-gcc-plugin/20160727-084514
config: x86_64-randconfig-s3-07270832 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

drivers/acpi/acpica/utdebug.c: In function 'acpi_debug_print':

>> drivers/acpi/acpica/utdebug.c:192:26: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'u32 {aka unsigned int}' [-Wformat=]
     acpi_os_printf("%9s-%04ld ", module_name, line_number);
                             ^
--
   drivers/acpi/acpica/dbhistry.c: In function 'acpi_db_display_history':
>> drivers/acpi/acpica/dbhistry.c:158:23: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'u32 {aka unsigned int}' [-Wformat=]
       acpi_os_printf("%3ld %s\n",
                          ^
--
   drivers/acpi/acpica/dbinput.c: In function 'acpi_db_get_line':
>> drivers/acpi/acpica/dbinput.c:609:56: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'long unsigned int' [-Wformat=]
          ("Buffer overflow while parsing input line (max %u characters)\n",
                                                           ^
   drivers/acpi/acpica/dbinput.c: In function 'acpi_db_command_dispatch':
>> drivers/acpi/acpica/dbinput.c:865:58: warning: format '%lX' expects argument of type 'long unsigned int', but argument 2 has type 'u32 {aka unsigned int}' [-Wformat=]

("Current debug level for file output is: %8.8lX\n",
^
drivers/acpi/acpica/dbinput.c:868:58: warning: format '%lX' expects argument of type 'long unsigned int', but argument 2 has type 'u32 {aka unsigned int}' [-Wformat=]
("Current debug level for console output is: %8.8lX\n",
^
drivers/acpi/acpica/dbinput.c:875:50: warning: format '%lX' expects argument of type 'long unsigned int', but argument 2 has type 'u32 {aka unsigned int}' [-Wformat=]
("Debug Level for console output was %8.8lX, now %8.8lX\n",
^
drivers/acpi/acpica/dbinput.c:875:62: warning: format '%lX' expects argument of type 'long unsigned int', but argument 3 has type 'u32 {aka unsigned int}' [-Wformat=]
("Debug Level for console output was %8.8lX, now %8.8lX\n",
^
drivers/acpi/acpica/dbinput.c:882:47: warning: format '%lX' expects argument of type 'long unsigned int', but argument 2 has type 'u32 {aka unsigned int}' [-Wformat=]
("Debug Level for file output was %8.8lX, now %8.8lX\n",
^
drivers/acpi/acpica/dbinput.c:882:59: warning: format '%lX' expects argument of type 'long unsigned int', but argument 3 has type 'u32 {aka unsigned int}' [-Wformat=]
("Debug Level for file output was %8.8lX, now %8.8lX\n",
^
--
drivers/acpi/acpica/dbstats.c: In function 'acpi_db_display_statistics':

>> drivers/acpi/acpica/dbstats.c:380:33: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'int' [-Wformat=]
       acpi_os_printf("%16.16s % 10ld% 10ld\n",
                                    ^
   drivers/acpi/acpica/dbstats.c:380:39: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'int' [-Wformat=]
       acpi_os_printf("%16.16s % 10ld% 10ld\n",
                                          ^
   drivers/acpi/acpica/dbstats.c:386:32: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'int' [-Wformat=]
      acpi_os_printf("%16.16s % 10ld% 10ld\n", "Misc/Unknown",
                                   ^
   drivers/acpi/acpica/dbstats.c:386:38: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'int' [-Wformat=]
      acpi_os_printf("%16.16s % 10ld% 10ld\n", "Misc/Unknown",
                                         ^
>> drivers/acpi/acpica/dbstats.c:390:32: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'u32 {aka unsigned int}' [-Wformat=]
      acpi_os_printf("%16.16s % 10ld% 10ld\n", "TOTALS:",
                                   ^
   drivers/acpi/acpica/dbstats.c:390:38: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'u32 {aka unsigned int}' [-Wformat=]
      acpi_os_printf("%16.16s % 10ld% 10ld\n", "TOTALS:",
                                         ^
   drivers/acpi/acpica/dbstats.c:418:54: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'u32 {aka unsigned int}' [-Wformat=]
      acpi_os_printf("Calls to AcpiPsFind:.. ........% 7ld\n",
                                                         ^
   drivers/acpi/acpica/dbstats.c:420:55: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'u32 {aka unsigned int}' [-Wformat=]
      acpi_os_printf("Calls to AcpiNsLookup:..........% 7ld\n",
                                                          ^
   drivers/acpi/acpica/dbstats.c:427:35: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'u32 {aka unsigned int}' [-Wformat=]
       acpi_os_printf("%-28s:     % 7ld\n",
                                      ^
>> drivers/acpi/acpica/dbstats.c:437:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Common         %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:439:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Number         %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:441:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("String         %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:443:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Buffer         %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:445:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Package        %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:447:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("BufferField    %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:449:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Device         %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:451:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Event          %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:453:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Method         %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:455:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Mutex          %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:457:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Region         %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:459:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("PowerResource  %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:461:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Processor      %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:463:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("ThermalZone    %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:465:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("RegionField    %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:467:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("BankField      %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:469:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("IndexField     %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:471:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Reference      %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:473:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Notify         %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:475:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("AddressSpace   %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:477:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Extra          %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:479:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("Data           %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:484:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("ParseObject    %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:486:38: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("ParseObjectNamed %3d\n",
                                         ^
   drivers/acpi/acpica/dbstats.c:488:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("ParseObjectAsl %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:490:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("OperandObject  %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:492:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("NamespaceNode  %3d\n",
                                       ^
   drivers/acpi/acpica/dbstats.c:494:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
      acpi_os_printf("AcpiObject     %3d\n",
                                       ^

drivers/acpi/acpica/dbstats.c:499:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
acpi_os_printf("Generic State %3d\n",
^
drivers/acpi/acpica/dbstats.c:501:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
acpi_os_printf("Common State %3d\n",
^
drivers/acpi/acpica/dbstats.c:503:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
acpi_os_printf("Control State %3d\n",
^
drivers/acpi/acpica/dbstats.c:505:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
acpi_os_printf("Update State %3d\n",
^
drivers/acpi/acpica/dbstats.c:507:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
acpi_os_printf("Scope State %3d\n",
^
drivers/acpi/acpica/dbstats.c:509:36: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat=]
acpi_os_printf("Parse Scope %3d\n",

vim +192 drivers/acpi/acpica/utdebug.c

^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  176  	thread_id = acpi_os_get_thread_id();
0dfaaa3d drivers/acpi/acpica/utdebug.c    Bob Moore      2016-03-24  177  	if (thread_id != acpi_gbl_previous_thread_id) {
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  178  		if (ACPI_LV_THREADS & acpi_dbg_level) {
4be44fcd drivers/acpi/utilities/utdebug.c Len Brown      2005-08-05  179  			acpi_os_printf
28eb3fcf drivers/acpi/acpica/utdebug.c    Lin Ming       2010-09-15  180  			    ("\n**** Context Switch from TID %u to TID %u ****\n\n",
0dfaaa3d drivers/acpi/acpica/utdebug.c    Bob Moore      2016-03-24  181  			     (u32)acpi_gbl_previous_thread_id, (u32)thread_id);
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  182  		}
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  183  
0dfaaa3d drivers/acpi/acpica/utdebug.c    Bob Moore      2016-03-24  184  		acpi_gbl_previous_thread_id = thread_id;
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  185  		acpi_gbl_nesting_level = 0;
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  186  	}
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  187  
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  188  	/*
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  189  	 * Display the module name, current line number, thread ID (if requested),
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  190  	 * current procedure nesting level, and the current procedure name
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  191  	 */
2856846e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-09-23 @192  	acpi_os_printf("%9s-%04ld ", module_name, line_number);
^1da177e drivers/acpi/utilities/utdebug.c Linus Torvalds 2005-04-16  193  
5076f005 drivers/acpi/acpica/utdebug.c    Bob Moore      2014-01-08  194  #ifdef ACPI_APPLICATION
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  195  	/*
5076f005 drivers/acpi/acpica/utdebug.c    Bob Moore      2014-01-08  196  	 * For acpi_exec/iASL only, emit the thread ID and nesting level.
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  197  	 * Note: nesting level is really only useful during a single-thread
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  198  	 * execution. Otherwise, multiple threads will keep resetting the
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  199  	 * level.
bf9b448e drivers/acpi/acpica/utdebug.c    Bob Moore      2013-11-21  200  	 */

:::::: The code at line 192 was first introduced by commit
:::::: 2856846e3a7bee02ce6b498c760376061e41aaed ACPICA: Debug output: small formatting update, no functional change.

:::::: TO: Bob Moore <[email protected]> :::::: CC: Rafael J. Wysocki <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#4 lore raw

Re: [PATCH v3 2/7] Split up struct warn_args

In reply to Emese Revfy
url: https://github.com/0day-ci/linux/commits/Emese-Revfy/Introduce-the-initify-gcc-plugin/20160727-084514 config: arm-u8500_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian…

Hi,

[auto build test ERROR on next-20160726]
[also build test ERROR on v4.7]
[cannot apply to stable/master linus/master linux/master v4.7-rc7 v4.7-rc6 v4.7-rc5] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Emese-Revfy/Introduce-the-initify-gcc-plugin/20160727-084514
config: arm-u8500_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm

All error/warnings (new ones prefixed by >>):

In file included from include/uapi/linux/posix_types.h:4:0,

                    from include/uapi/linux/types.h:13,
                    from include/linux/compiler.h:201,
                    from include/linux/linkage.h:4,
                    from include/linux/kernel.h:6,
                    from include/linux/debug_locks.h:4,
                    from kernel/panic.c:11:
   kernel/panic.c: In function 'warn_slowpath_null':
>> include/linux/stddef.h:7:14: error: incompatible type for argument 7 of '__warn'
    #define NULL ((void *)0)
                 ^
>> kernel/panic.c:544:74: note: in expansion of macro 'NULL'
     __warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, NULL, NULL);
                                                                             ^

kernel/panic.c:478:6: note: expected 'va_list {aka __va_list}' but argument is of type 'void *'
void __warn(const char *file, int line, void *caller, unsigned taint,
^
--
In file included from include/uapi/linux/posix_types.h:4:0,

                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/list.h:4,
                    from lib/bug.c:43:
   lib/bug.c: In function 'report_bug':
>> include/linux/stddef.h:7:14: error: incompatible type for argument 7 of '__warn'
    #define NULL ((void *)0)
                 ^
>> lib/bug.c:171:16: note: in expansion of macro 'NULL'
             NULL, NULL);
                   ^
   In file included from arch/arm/include/asm/bug.h:59:0,
                    from include/linux/bug.h:4,
                    from include/linux/thread_info.h:11,
                    from include/asm-generic/preempt.h:4,
                    from ./arch/arm/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:59,
                    from include/linux/spinlock.h:50,
                    from include/linux/seqlock.h:35,
                    from include/linux/time.h:5,
                    from include/linux/stat.h:18,
                    from include/linux/module.h:10,
                    from lib/bug.c:44:

include/asm-generic/bug.h:84:6: note: expected 'va_list {aka __va_list}' but argument is of type 'void *'
void __warn(const char *file, int line, void *caller, unsigned taint,
^

vim +/__warn +7 include/linux/stddef.h

^1da177e Linus Torvalds   2005-04-16   1  #ifndef _LINUX_STDDEF_H
^1da177e Linus Torvalds   2005-04-16   2  #define _LINUX_STDDEF_H
^1da177e Linus Torvalds   2005-04-16   3  
607ca46e David Howells    2012-10-13   4  #include <uapi/linux/stddef.h>
^1da177e Linus Torvalds   2005-04-16   5  
^1da177e Linus Torvalds   2005-04-16   6  #undef NULL
^1da177e Linus Torvalds   2005-04-16  @7  #define NULL ((void *)0)

6e218287 Richard Knutsson 2006-09-30 8
6e218287 Richard Knutsson 2006-09-30 9 enum {
6e218287 Richard Knutsson 2006-09-30 10 false = 0,

:::::: The code at line 7 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <[email protected]> :::::: CC: Linus Torvalds <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#5 lore raw

PATCH v3 2/7 Split up struct warn_args

In reply to Emese Revfy

Disable the initify plugin on the 6th parameter of __warn() because the va_list type can't be NULL on the tile arch.

---
 include/asm-generic/bug.h |  7 +++++--
 kernel/panic.c            | 32 ++++++++++++++++++++------------
 lib/bug.c                 |  2 +-
 3 files changed, 26 insertions(+), 15 deletions(-)
include/asm-generic/bug.h +5 -2
index 13a9241..f6ae0d7 100644
@@ -81,9 +81,12 @@ extern __nocapture(1) void warn_slowpath_null(const char *file, const int line);
 	do { printk(arg); __WARN_TAINT(taint); } while (0)
 #endif
 
-__nocapture(1, 6)
+/* 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, const char *fmt, va_list args);
+	    struct pt_regs *regs, struct warn_args *args);
 
 #ifndef WARN_ON
 #define WARN_ON(condition) ({						\
kernel/panic.c +20 -12
index 993ad20..ca8cea1 100644
@@ -475,8 +475,13 @@ void oops_exit(void)
 	kmsg_dump(KMSG_DUMP_OOPS);
 }
 
+struct warn_args {
+	const char *fmt;
+	va_list args;
+};
+
 void __warn(const char *file, int line, void *caller, unsigned taint,
-	    struct pt_regs *regs, const char *fmt, va_list args)
+	    struct pt_regs *regs, struct warn_args *args)
 {
 	disable_trace_on_warning();
 
@@ -490,8 +495,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 		pr_warn("WARNING: CPU: %d PID: %d at %pS\n",
 			raw_smp_processor_id(), current->pid, caller);
 
-	if (fmt)
-		vprintk(fmt, args);
+	if (args)
+		vprintk(args->fmt, args->args);
 
 	if (panic_on_warn) {
 		/*
@@ -520,28 +525,31 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 #ifdef WANT_WARN_ON_SLOWPATH
 void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
 {
-	va_list args;
+	struct warn_args args;
 
-	va_start(args, fmt);
-	__warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, fmt, args);
-	va_end(args);
+	args.fmt = fmt;
+	va_start(args.args, fmt);
+	__warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL,
+	       &args);
+	va_end(args.args);
 }
 EXPORT_SYMBOL(warn_slowpath_fmt);
 
 void warn_slowpath_fmt_taint(const char *file, int line,
 			     unsigned taint, const char *fmt, ...)
 {
-	va_list args;
+	struct warn_args args;
 
-	va_start(args, fmt);
-	__warn(file, line, __builtin_return_address(0), taint, NULL, fmt, args);
-	va_end(args);
+	args.fmt = fmt;
+	va_start(args.args, fmt);
+	__warn(file, line, __builtin_return_address(0), taint, NULL, &args);
+	va_end(args.args);
 }
 EXPORT_SYMBOL(warn_slowpath_fmt_taint);
 
 void warn_slowpath_null(const char *file, int line)
 {
-	__warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, NULL, NULL);
+	__warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, NULL);
 }
 EXPORT_SYMBOL(warn_slowpath_null);
 #endif
lib/bug.c +1 -1
index c8bdebb..bc3656e 100644
@@ -168,7 +168,7 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
 	if (warning) {
 		/* this is a WARN_ON rather than BUG/BUG_ON */
 		__warn(file, line, (void *)bugaddr, BUG_GET_TAINT(bug), regs,
-		       NULL, NULL);
+		       NULL);
 		return BUG_TRAP_TYPE_WARN;
 	}
 
Signature · 1 line
2.8.1
#13 lore raw

PATCH v3 6/7 Mark a few functions with the printf attribute

In reply to Emese Revfy

Fixed format strings warnings exposed by the printf attribute.

---
 drivers/acpi/acpica/dbhistry.c     |  2 +-
 drivers/acpi/acpica/dbinput.c      | 10 ++---
 drivers/acpi/acpica/dbstats.c      | 88 +++++++++++++++++++-------------------
 drivers/acpi/acpica/utdebug.c      |  2 +-
 drivers/scsi/esas2r/esas2r_init.c  |  2 +-
 drivers/scsi/esas2r/esas2r_ioctl.c |  2 +-
 drivers/scsi/esas2r/esas2r_main.c  |  4 +-
 7 files changed, 55 insertions(+), 55 deletions(-)
drivers/acpi/acpica/dbhistry.c +1 -1
index 46bd65d..ec9da48 100644
@@ -155,7 +155,7 @@ void acpi_db_display_history(void)
 
 	for (i = 0; i < acpi_gbl_num_history; i++) {
 		if (acpi_gbl_history_buffer[history_index].command) {
-			acpi_os_printf("%3ld %s\n",
+			acpi_os_printf("%3u %s\n",
 				       acpi_gbl_history_buffer[history_index].
 				       cmd_num,
 				       acpi_gbl_history_buffer[history_index].
drivers/acpi/acpica/dbinput.c +5 -5
index 7cd5d2e..a837ce6 100644
@@ -606,7 +606,7 @@ static u32 acpi_db_get_line(char *input_buffer)
 	    (acpi_gbl_db_parsed_buf, sizeof(acpi_gbl_db_parsed_buf),
 	     input_buffer)) {
 		acpi_os_printf
-		    ("Buffer overflow while parsing input line (max %u characters)\n",
+		    ("Buffer overflow while parsing input line (max %lu characters)\n",
 		     sizeof(acpi_gbl_db_parsed_buf));
 		return (0);
 	}
@@ -862,24 +862,24 @@ acpi_db_command_dispatch(char *input_buffer,
 
 		if (param_count == 0) {
 			acpi_os_printf
-			    ("Current debug level for file output is:    %8.8lX\n",
+			    ("Current debug level for file output is:    %8.8X\n",
 			     acpi_gbl_db_debug_level);
 			acpi_os_printf
-			    ("Current debug level for console output is: %8.8lX\n",
+			    ("Current debug level for console output is: %8.8X\n",
 			     acpi_gbl_db_console_debug_level);
 		} else if (param_count == 2) {
 			temp = acpi_gbl_db_console_debug_level;
 			acpi_gbl_db_console_debug_level =
 			    strtoul(acpi_gbl_db_args[1], NULL, 16);
 			acpi_os_printf
-			    ("Debug Level for console output was %8.8lX, now %8.8lX\n",
+			    ("Debug Level for console output was %8.8X, now %8.8X\n",
 			     temp, acpi_gbl_db_console_debug_level);
 		} else {
 			temp = acpi_gbl_db_debug_level;
 			acpi_gbl_db_debug_level =
 			    strtoul(acpi_gbl_db_args[1], NULL, 16);
 			acpi_os_printf
-			    ("Debug Level for file output was %8.8lX, now %8.8lX\n",
+			    ("Debug Level for file output was %8.8X, now %8.8X\n",
 			     temp, acpi_gbl_db_debug_level);
 		}
 		break;
drivers/acpi/acpica/dbstats.c +44 -44

164 lines not on this page · raw message

drivers/acpi/acpica/utdebug.c +1 -1
index 5744222..4ac231a 100644
@@ -189,7 +189,7 @@ acpi_debug_print(u32 requested_debug_level,
 	 * Display the module name, current line number, thread ID (if requested),
 	 * current procedure nesting level, and the current procedure name
 	 */
-	acpi_os_printf("%9s-%04ld ", module_name, line_number);
+	acpi_os_printf("%9s-%04u ", module_name, line_number);
 
 #ifdef ACPI_APPLICATION
 	/*
drivers/scsi/esas2r/esas2r_init.c +1 -1
index 78ce4d61..b3f6ff6 100644
@@ -237,7 +237,7 @@ static void esas2r_claim_interrupts(struct esas2r_adapter *a)
 		flags |= IRQF_SHARED;
 
 	esas2r_log(ESAS2R_LOG_INFO,
-		   "esas2r_claim_interrupts irq=%d (%p, %s, %x)",
+		   "esas2r_claim_interrupts irq=%d (%p, %s, %lx)",
 		   a->pcid->irq, a, a->name, flags);
 
 	if (request_irq(a->pcid->irq,
drivers/scsi/esas2r/esas2r_ioctl.c +1 -1
index 3e84834..34976f9 100644
@@ -1301,7 +1301,7 @@ int esas2r_ioctl_handler(void *hostdata, int cmd, void __user *arg)
 	ioctl = kzalloc(sizeof(struct atto_express_ioctl), GFP_KERNEL);
 	if (ioctl == NULL) {
 		esas2r_log(ESAS2R_LOG_WARN,
-			   "ioctl_handler kzalloc failed for %d bytes",
+			   "ioctl_handler kzalloc failed for %lu bytes",
 			   sizeof(struct atto_express_ioctl));
 		return -ENOMEM;
 	}
drivers/scsi/esas2r/esas2r_main.c +2 -2
index 2aca4d1..cdee863 100644
@@ -198,7 +198,7 @@ static ssize_t write_hw(struct file *file, struct kobject *kobj,
 					      GFP_KERNEL);
 		if (a->local_atto_ioctl == NULL) {
 			esas2r_log(ESAS2R_LOG_WARN,
-				   "write_hw kzalloc failed for %d bytes",
+				   "write_hw kzalloc failed for %lu bytes",
 				   sizeof(struct atto_ioctl));
 			return -ENOMEM;
 		}
@@ -1186,7 +1186,7 @@ retry:
 		} else {
 			esas2r_log(ESAS2R_LOG_CRIT,
 				   "unable to allocate a request for a "
-				   "device reset (%d:%d)!",
+				   "device reset (%d:%llu)!",
 				   cmd->device->id,
 				   cmd->device->lun);
 		}
Signature · 1 line
2.8.1