[v3,2/7] Split up struct warn_args
diff mbox

Message ID 20160726223813.16d7cfd7f7dc514c6f7f9e9d@gmail.com
State New
Headers show

Commit Message

Emese Revfy July 26, 2016, 8:38 p.m. UTC
to enable dataflow verification by the initify plugin. This allows marking
warn_slowpath* parameters as nocapture and compile time verification of
the related dataflows.

Signed-off-by: Emese Revfy <re.emese@gmail.com>
---
 include/asm-generic/bug.h |  5 +----
 kernel/panic.c            | 32 ++++++++++++--------------------
 lib/bug.c                 |  2 +-
 3 files changed, 14 insertions(+), 25 deletions(-)

Comments

kernel test robot July 27, 2016, 1:15 a.m. UTC | #1
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
kernel test robot July 27, 2016, 2:27 a.m. UTC | #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: 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 <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

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

Patch
diff mbox

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 6f96247..3048d10 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -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) ({						\
diff --git a/kernel/panic.c b/kernel/panic.c
index ca8cea1..993ad20 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -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
diff --git a/lib/bug.c b/lib/bug.c
index bc3656e..c8bdebb 100644
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -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;
 	}