[4/4] powerpc: Add -Wimplicit-fallthrough to arch CFLAGS

Message ID 20181010051308.25422-4-mpe@ellerman.id.au
State New
Headers show
Series
  • [1/4] powerpc: Move core kernel logic into arch/powerpc/Kbuild
Related show

Checks

Context Check Description
snowpatch_ozlabs/build-ppc32 success Test build-ppc32 on branch next
snowpatch_ozlabs/build-ppc64e fail Test build-ppc64e on branch next
snowpatch_ozlabs/build-ppc64be fail Test build-ppc64be on branch next
snowpatch_ozlabs/build-ppc64le fail Test build-ppc64le on branch next
snowpatch_ozlabs/checkpatch success Test checkpatch on branch next
snowpatch_ozlabs/apply_patch success next/apply_patch Successfully applied

Commit Message

Michael Ellerman Oct. 10, 2018, 5:13 a.m.
Warn whenever a switch statement has a fallthrough without a comment
annotating it.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/Kbuild | 1 +
 1 file changed, 1 insertion(+)

Comments

Kees Cook Oct. 10, 2018, 2:47 p.m. | #1
On Tue, Oct 9, 2018 at 10:13 PM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> Warn whenever a switch statement has a fallthrough without a comment
> annotating it.
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Yes please. :)

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  arch/powerpc/Kbuild | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/powerpc/Kbuild b/arch/powerpc/Kbuild
> index 86b261d6bde5..ef625f1db576 100644
> --- a/arch/powerpc/Kbuild
> +++ b/arch/powerpc/Kbuild
> @@ -1,4 +1,5 @@
>  subdir-ccflags-y := $(call cc-option, -Wvla)
> +subdir-ccflags-y += $(call cc-option, -Wimplicit-fallthrough)
>  subdir-ccflags-$(CONFIG_PPC_WERROR) += -Werror
>
>  obj-y += kernel/
> --
> 2.17.1
>
kbuild test robot Oct. 10, 2018, 4:55 p.m. | #2
Hi Michael,

I love your patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.19-rc7 next-20181010]
[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/Michael-Ellerman/powerpc-Move-core-kernel-logic-into-arch-powerpc-Kbuild/20181010-205834
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-socrates_defconfig (attached as .config)
compiler: powerpc-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   arch/powerpc/kernel/align.c: In function 'emulate_spe':
>> arch/powerpc/kernel/align.c:183:8: error: this statement may fall through [-Werror=implicit-fallthrough=]
       ret |= __get_user_inatomic(temp.v[3], p++);
           ^~
   arch/powerpc/kernel/align.c:184:3: note: here
      case 4:
      ^~~~
   arch/powerpc/kernel/align.c:186:8: error: this statement may fall through [-Werror=implicit-fallthrough=]
       ret |= __get_user_inatomic(temp.v[5], p++);
           ^~
   arch/powerpc/kernel/align.c:187:3: note: here
      case 2:
      ^~~~
   arch/powerpc/kernel/align.c:266:8: error: this statement may fall through [-Werror=implicit-fallthrough=]
       ret |= __put_user_inatomic(data.v[3], p++);
           ^~
   arch/powerpc/kernel/align.c:267:3: note: here
      case 4:
      ^~~~
   arch/powerpc/kernel/align.c:269:8: error: this statement may fall through [-Werror=implicit-fallthrough=]
       ret |= __put_user_inatomic(data.v[5], p++);
           ^~
   arch/powerpc/kernel/align.c:270:3: note: here
      case 2:
      ^~~~
   cc1: all warnings being treated as errors

vim +183 arch/powerpc/kernel/align.c

26caeb2e Kumar Gala             2007-08-24  104  
26caeb2e Kumar Gala             2007-08-24  105  /*
26caeb2e Kumar Gala             2007-08-24  106   * Emulate SPE loads and stores.
26caeb2e Kumar Gala             2007-08-24  107   * Only Book-E has these instructions, and it does true little-endian,
26caeb2e Kumar Gala             2007-08-24  108   * so we don't need the address swizzling.
26caeb2e Kumar Gala             2007-08-24  109   */
26caeb2e Kumar Gala             2007-08-24  110  static int emulate_spe(struct pt_regs *regs, unsigned int reg,
26caeb2e Kumar Gala             2007-08-24  111  		       unsigned int instr)
26caeb2e Kumar Gala             2007-08-24  112  {
f626190d Anton Blanchard        2013-09-23  113  	int ret;
26caeb2e Kumar Gala             2007-08-24  114  	union {
26caeb2e Kumar Gala             2007-08-24  115  		u64 ll;
26caeb2e Kumar Gala             2007-08-24  116  		u32 w[2];
26caeb2e Kumar Gala             2007-08-24  117  		u16 h[4];
26caeb2e Kumar Gala             2007-08-24  118  		u8 v[8];
26caeb2e Kumar Gala             2007-08-24  119  	} data, temp;
26caeb2e Kumar Gala             2007-08-24  120  	unsigned char __user *p, *addr;
26caeb2e Kumar Gala             2007-08-24  121  	unsigned long *evr = &current->thread.evr[reg];
26caeb2e Kumar Gala             2007-08-24  122  	unsigned int nb, flags;
26caeb2e Kumar Gala             2007-08-24  123  
26caeb2e Kumar Gala             2007-08-24  124  	instr = (instr >> 1) & 0x1f;
26caeb2e Kumar Gala             2007-08-24  125  
26caeb2e Kumar Gala             2007-08-24  126  	/* DAR has the operand effective address */
26caeb2e Kumar Gala             2007-08-24  127  	addr = (unsigned char __user *)regs->dar;
26caeb2e Kumar Gala             2007-08-24  128  
26caeb2e Kumar Gala             2007-08-24  129  	nb = spe_aligninfo[instr].len;
26caeb2e Kumar Gala             2007-08-24  130  	flags = spe_aligninfo[instr].flags;
26caeb2e Kumar Gala             2007-08-24  131  
26caeb2e Kumar Gala             2007-08-24  132  	/* Verify the address of the operand */
26caeb2e Kumar Gala             2007-08-24  133  	if (unlikely(user_mode(regs) &&
26caeb2e Kumar Gala             2007-08-24  134  		     !access_ok((flags & ST ? VERIFY_WRITE : VERIFY_READ),
26caeb2e Kumar Gala             2007-08-24  135  				addr, nb)))
26caeb2e Kumar Gala             2007-08-24  136  		return -EFAULT;
26caeb2e Kumar Gala             2007-08-24  137  
26caeb2e Kumar Gala             2007-08-24  138  	/* userland only */
26caeb2e Kumar Gala             2007-08-24  139  	if (unlikely(!user_mode(regs)))
26caeb2e Kumar Gala             2007-08-24  140  		return 0;
26caeb2e Kumar Gala             2007-08-24  141  
26caeb2e Kumar Gala             2007-08-24  142  	flush_spe_to_thread(current);
26caeb2e Kumar Gala             2007-08-24  143  
26caeb2e Kumar Gala             2007-08-24  144  	/* If we are loading, get the data from user space, else
26caeb2e Kumar Gala             2007-08-24  145  	 * get it from register values
26caeb2e Kumar Gala             2007-08-24  146  	 */
26caeb2e Kumar Gala             2007-08-24  147  	if (flags & ST) {
26caeb2e Kumar Gala             2007-08-24  148  		data.ll = 0;
26caeb2e Kumar Gala             2007-08-24  149  		switch (instr) {
26caeb2e Kumar Gala             2007-08-24  150  		case EVSTDD:
26caeb2e Kumar Gala             2007-08-24  151  		case EVSTDW:
26caeb2e Kumar Gala             2007-08-24  152  		case EVSTDH:
26caeb2e Kumar Gala             2007-08-24  153  			data.w[0] = *evr;
26caeb2e Kumar Gala             2007-08-24  154  			data.w[1] = regs->gpr[reg];
26caeb2e Kumar Gala             2007-08-24  155  			break;
26caeb2e Kumar Gala             2007-08-24  156  		case EVSTWHE:
26caeb2e Kumar Gala             2007-08-24  157  			data.h[2] = *evr >> 16;
26caeb2e Kumar Gala             2007-08-24  158  			data.h[3] = regs->gpr[reg] >> 16;
26caeb2e Kumar Gala             2007-08-24  159  			break;
26caeb2e Kumar Gala             2007-08-24  160  		case EVSTWHO:
26caeb2e Kumar Gala             2007-08-24  161  			data.h[2] = *evr & 0xffff;
26caeb2e Kumar Gala             2007-08-24  162  			data.h[3] = regs->gpr[reg] & 0xffff;
26caeb2e Kumar Gala             2007-08-24  163  			break;
26caeb2e Kumar Gala             2007-08-24  164  		case EVSTWWE:
26caeb2e Kumar Gala             2007-08-24  165  			data.w[1] = *evr;
26caeb2e Kumar Gala             2007-08-24  166  			break;
26caeb2e Kumar Gala             2007-08-24  167  		case EVSTWWO:
26caeb2e Kumar Gala             2007-08-24  168  			data.w[1] = regs->gpr[reg];
26caeb2e Kumar Gala             2007-08-24  169  			break;
26caeb2e Kumar Gala             2007-08-24  170  		default:
26caeb2e Kumar Gala             2007-08-24  171  			return -EINVAL;
26caeb2e Kumar Gala             2007-08-24  172  		}
26caeb2e Kumar Gala             2007-08-24  173  	} else {
26caeb2e Kumar Gala             2007-08-24  174  		temp.ll = data.ll = 0;
26caeb2e Kumar Gala             2007-08-24  175  		ret = 0;
26caeb2e Kumar Gala             2007-08-24  176  		p = addr;
26caeb2e Kumar Gala             2007-08-24  177  
26caeb2e Kumar Gala             2007-08-24  178  		switch (nb) {
26caeb2e Kumar Gala             2007-08-24  179  		case 8:
26caeb2e Kumar Gala             2007-08-24  180  			ret |= __get_user_inatomic(temp.v[0], p++);
26caeb2e Kumar Gala             2007-08-24  181  			ret |= __get_user_inatomic(temp.v[1], p++);
26caeb2e Kumar Gala             2007-08-24  182  			ret |= __get_user_inatomic(temp.v[2], p++);
26caeb2e Kumar Gala             2007-08-24 @183  			ret |= __get_user_inatomic(temp.v[3], p++);
26caeb2e Kumar Gala             2007-08-24  184  		case 4:
26caeb2e Kumar Gala             2007-08-24  185  			ret |= __get_user_inatomic(temp.v[4], p++);
26caeb2e Kumar Gala             2007-08-24  186  			ret |= __get_user_inatomic(temp.v[5], p++);
26caeb2e Kumar Gala             2007-08-24  187  		case 2:
26caeb2e Kumar Gala             2007-08-24  188  			ret |= __get_user_inatomic(temp.v[6], p++);
26caeb2e Kumar Gala             2007-08-24  189  			ret |= __get_user_inatomic(temp.v[7], p++);
26caeb2e Kumar Gala             2007-08-24  190  			if (unlikely(ret))
26caeb2e Kumar Gala             2007-08-24  191  				return -EFAULT;
26caeb2e Kumar Gala             2007-08-24  192  		}
26caeb2e Kumar Gala             2007-08-24  193  
26caeb2e Kumar Gala             2007-08-24  194  		switch (instr) {
26caeb2e Kumar Gala             2007-08-24  195  		case EVLDD:
26caeb2e Kumar Gala             2007-08-24  196  		case EVLDW:
26caeb2e Kumar Gala             2007-08-24  197  		case EVLDH:
26caeb2e Kumar Gala             2007-08-24  198  			data.ll = temp.ll;
26caeb2e Kumar Gala             2007-08-24  199  			break;
26caeb2e Kumar Gala             2007-08-24  200  		case EVLHHESPLAT:
26caeb2e Kumar Gala             2007-08-24  201  			data.h[0] = temp.h[3];
26caeb2e Kumar Gala             2007-08-24  202  			data.h[2] = temp.h[3];
26caeb2e Kumar Gala             2007-08-24  203  			break;
26caeb2e Kumar Gala             2007-08-24  204  		case EVLHHOUSPLAT:
26caeb2e Kumar Gala             2007-08-24  205  		case EVLHHOSSPLAT:
26caeb2e Kumar Gala             2007-08-24  206  			data.h[1] = temp.h[3];
26caeb2e Kumar Gala             2007-08-24  207  			data.h[3] = temp.h[3];
26caeb2e Kumar Gala             2007-08-24  208  			break;
26caeb2e Kumar Gala             2007-08-24  209  		case EVLWHE:
26caeb2e Kumar Gala             2007-08-24  210  			data.h[0] = temp.h[2];
26caeb2e Kumar Gala             2007-08-24  211  			data.h[2] = temp.h[3];
26caeb2e Kumar Gala             2007-08-24  212  			break;
26caeb2e Kumar Gala             2007-08-24  213  		case EVLWHOU:
26caeb2e Kumar Gala             2007-08-24  214  		case EVLWHOS:
26caeb2e Kumar Gala             2007-08-24  215  			data.h[1] = temp.h[2];
26caeb2e Kumar Gala             2007-08-24  216  			data.h[3] = temp.h[3];
26caeb2e Kumar Gala             2007-08-24  217  			break;
26caeb2e Kumar Gala             2007-08-24  218  		case EVLWWSPLAT:
26caeb2e Kumar Gala             2007-08-24  219  			data.w[0] = temp.w[1];
26caeb2e Kumar Gala             2007-08-24  220  			data.w[1] = temp.w[1];
26caeb2e Kumar Gala             2007-08-24  221  			break;
26caeb2e Kumar Gala             2007-08-24  222  		case EVLWHSPLAT:
26caeb2e Kumar Gala             2007-08-24  223  			data.h[0] = temp.h[2];
26caeb2e Kumar Gala             2007-08-24  224  			data.h[1] = temp.h[2];
26caeb2e Kumar Gala             2007-08-24  225  			data.h[2] = temp.h[3];
26caeb2e Kumar Gala             2007-08-24  226  			data.h[3] = temp.h[3];
26caeb2e Kumar Gala             2007-08-24  227  			break;
26caeb2e Kumar Gala             2007-08-24  228  		default:
26caeb2e Kumar Gala             2007-08-24  229  			return -EINVAL;
26caeb2e Kumar Gala             2007-08-24  230  		}
26caeb2e Kumar Gala             2007-08-24  231  	}
26caeb2e Kumar Gala             2007-08-24  232  
26caeb2e Kumar Gala             2007-08-24  233  	if (flags & SW) {
26caeb2e Kumar Gala             2007-08-24  234  		switch (flags & 0xf0) {
26caeb2e Kumar Gala             2007-08-24  235  		case E8:
f626190d Anton Blanchard        2013-09-23  236  			data.ll = swab64(data.ll);
26caeb2e Kumar Gala             2007-08-24  237  			break;
26caeb2e Kumar Gala             2007-08-24  238  		case E4:
f626190d Anton Blanchard        2013-09-23  239  			data.w[0] = swab32(data.w[0]);
f626190d Anton Blanchard        2013-09-23  240  			data.w[1] = swab32(data.w[1]);
26caeb2e Kumar Gala             2007-08-24  241  			break;
26caeb2e Kumar Gala             2007-08-24  242  		/* Its half word endian */
26caeb2e Kumar Gala             2007-08-24  243  		default:
f626190d Anton Blanchard        2013-09-23  244  			data.h[0] = swab16(data.h[0]);
f626190d Anton Blanchard        2013-09-23  245  			data.h[1] = swab16(data.h[1]);
f626190d Anton Blanchard        2013-09-23  246  			data.h[2] = swab16(data.h[2]);
f626190d Anton Blanchard        2013-09-23  247  			data.h[3] = swab16(data.h[3]);
26caeb2e Kumar Gala             2007-08-24  248  			break;
26caeb2e Kumar Gala             2007-08-24  249  		}
26caeb2e Kumar Gala             2007-08-24  250  	}
26caeb2e Kumar Gala             2007-08-24  251  
26caeb2e Kumar Gala             2007-08-24  252  	if (flags & SE) {
26caeb2e Kumar Gala             2007-08-24  253  		data.w[0] = (s16)data.h[1];
26caeb2e Kumar Gala             2007-08-24  254  		data.w[1] = (s16)data.h[3];
26caeb2e Kumar Gala             2007-08-24  255  	}
26caeb2e Kumar Gala             2007-08-24  256  
26caeb2e Kumar Gala             2007-08-24  257  	/* Store result to memory or update registers */
26caeb2e Kumar Gala             2007-08-24  258  	if (flags & ST) {
26caeb2e Kumar Gala             2007-08-24  259  		ret = 0;
26caeb2e Kumar Gala             2007-08-24  260  		p = addr;
26caeb2e Kumar Gala             2007-08-24  261  		switch (nb) {
26caeb2e Kumar Gala             2007-08-24  262  		case 8:
26caeb2e Kumar Gala             2007-08-24  263  			ret |= __put_user_inatomic(data.v[0], p++);
26caeb2e Kumar Gala             2007-08-24  264  			ret |= __put_user_inatomic(data.v[1], p++);
26caeb2e Kumar Gala             2007-08-24  265  			ret |= __put_user_inatomic(data.v[2], p++);
26caeb2e Kumar Gala             2007-08-24  266  			ret |= __put_user_inatomic(data.v[3], p++);
26caeb2e Kumar Gala             2007-08-24  267  		case 4:
26caeb2e Kumar Gala             2007-08-24  268  			ret |= __put_user_inatomic(data.v[4], p++);
26caeb2e Kumar Gala             2007-08-24  269  			ret |= __put_user_inatomic(data.v[5], p++);
26caeb2e Kumar Gala             2007-08-24  270  		case 2:
26caeb2e Kumar Gala             2007-08-24  271  			ret |= __put_user_inatomic(data.v[6], p++);
26caeb2e Kumar Gala             2007-08-24  272  			ret |= __put_user_inatomic(data.v[7], p++);
26caeb2e Kumar Gala             2007-08-24  273  		}
26caeb2e Kumar Gala             2007-08-24  274  		if (unlikely(ret))
26caeb2e Kumar Gala             2007-08-24  275  			return -EFAULT;
26caeb2e Kumar Gala             2007-08-24  276  	} else {
26caeb2e Kumar Gala             2007-08-24  277  		*evr = data.w[0];
26caeb2e Kumar Gala             2007-08-24  278  		regs->gpr[reg] = data.w[1];
26caeb2e Kumar Gala             2007-08-24  279  	}
26caeb2e Kumar Gala             2007-08-24  280  
26caeb2e Kumar Gala             2007-08-24  281  	return 1;
26caeb2e Kumar Gala             2007-08-24  282  }
26caeb2e Kumar Gala             2007-08-24  283  #endif /* CONFIG_SPE */
5daf9071 Benjamin Herrenschmidt 2005-11-18  284  

:::::: The code at line 183 was first introduced by commit
:::::: 26caeb2ee1924d564e8d8190aa783a569532f81a [POWERPC] Handle alignment faults on SPE load/store instructions

:::::: TO: Kumar Gala <galak@kernel.crashing.org>
:::::: CC: Kumar Gala <galak@kernel.crashing.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kbuild test robot Oct. 10, 2018, 5 p.m. | #3
Hi Michael,

I love your patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.19-rc7 next-20181010]
[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/Michael-Ellerman/powerpc-Move-core-kernel-logic-into-arch-powerpc-Kbuild/20181010-205834
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   In file included from arch/powerpc/kernel/signal_32.c:32:0:
   include/linux/compat.h: In function 'put_compat_sigset':
>> include/linux/compat.h:494:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
     case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3];
                                             ~~~~~~~~~^~~~~~~~~~~~~
   include/linux/compat.h:495:2: note: here
     case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
     ^~~~
   include/linux/compat.h:495:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
     case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
                                             ~~~~~~~~~^~~~~~~~~~~~~
   include/linux/compat.h:496:2: note: here
     case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
     ^~~~
   include/linux/compat.h:496:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
     case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
                                             ~~~~~~~~~^~~~~~~~~~~~~
   include/linux/compat.h:497:2: note: here
     case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0];
     ^~~~
   cc1: all warnings being treated as errors
--
   arch/powerpc/kernel/nvram_64.c: In function 'dev_nvram_ioctl':
>> arch/powerpc/kernel/nvram_64.c:811:3: error: this statement may fall through [-Werror=implicit-fallthrough=]
      printk(KERN_WARNING "nvram: Using obsolete PMAC_NVRAM_GET_OFFSET ioctl\n");
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/kernel/nvram_64.c:812:2: note: here
     case IOC_NVRAM_GET_OFFSET: {
     ^~~~
   cc1: all warnings being treated as errors
--
   In file included from include/linux/kvm_host.h:14:0,
                    from arch/powerpc/kvm/../../../virt/kvm/kvm_main.c:21:
   include/linux/signal.h: In function 'sigemptyset':
>> include/linux/signal.h:180:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
     case 2: set->sig[1] = 0;
             ~~~~~~~~~~~~^~~
   include/linux/signal.h:181:2: note: here
     case 1: set->sig[0] = 0;
     ^~~~
   cc1: all warnings being treated as errors
--
   arch/powerpc/platforms/powermac/feature.c: In function 'g5_i2s_enable':
>> arch/powerpc/platforms/powermac/feature.c:1477:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
      if (macio->type == macio_shasta)
         ^
   arch/powerpc/platforms/powermac/feature.c:1479:2: note: here
     default:
     ^~~~~~~
   cc1: all warnings being treated as errors
--
   arch/powerpc/xmon/xmon.c: In function 'do_spu_cmd':
>> arch/powerpc/xmon/xmon.c:4023:24: error: this statement may fall through [-Werror=implicit-fallthrough=]
      if (isxdigit(subcmd) || subcmd == '\n')
   arch/powerpc/xmon/xmon.c:4025:2: note: here
     case 'f':
     ^~~~
   cc1: all warnings being treated as errors

vim +494 include/linux/compat.h

fde9fc76 Matt Redfearn 2018-02-19  481  
fde9fc76 Matt Redfearn 2018-02-19  482  /*
fde9fc76 Matt Redfearn 2018-02-19  483   * Defined inline such that size can be compile time constant, which avoids
fde9fc76 Matt Redfearn 2018-02-19  484   * CONFIG_HARDENED_USERCOPY complaining about copies from task_struct
fde9fc76 Matt Redfearn 2018-02-19  485   */
fde9fc76 Matt Redfearn 2018-02-19  486  static inline int
fde9fc76 Matt Redfearn 2018-02-19  487  put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set,
fde9fc76 Matt Redfearn 2018-02-19  488  		  unsigned int size)
fde9fc76 Matt Redfearn 2018-02-19  489  {
fde9fc76 Matt Redfearn 2018-02-19  490  	/* size <= sizeof(compat_sigset_t) <= sizeof(sigset_t) */
fde9fc76 Matt Redfearn 2018-02-19  491  #ifdef __BIG_ENDIAN
fde9fc76 Matt Redfearn 2018-02-19  492  	compat_sigset_t v;
fde9fc76 Matt Redfearn 2018-02-19  493  	switch (_NSIG_WORDS) {
fde9fc76 Matt Redfearn 2018-02-19 @494  	case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3];
fde9fc76 Matt Redfearn 2018-02-19  495  	case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
fde9fc76 Matt Redfearn 2018-02-19  496  	case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
fde9fc76 Matt Redfearn 2018-02-19  497  	case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0];
fde9fc76 Matt Redfearn 2018-02-19  498  	}
fde9fc76 Matt Redfearn 2018-02-19  499  	return copy_to_user(compat, &v, size) ? -EFAULT : 0;
fde9fc76 Matt Redfearn 2018-02-19  500  #else
fde9fc76 Matt Redfearn 2018-02-19  501  	return copy_to_user(compat, set, size) ? -EFAULT : 0;
fde9fc76 Matt Redfearn 2018-02-19  502  #endif
fde9fc76 Matt Redfearn 2018-02-19  503  }
bebfa101 Andi Kleen    2006-06-26  504  

:::::: The code at line 494 was first introduced by commit
:::::: fde9fc766e96c494b82931b1d270a9a751be07c0 signals: Move put_compat_sigset to compat.h to silence hardened usercopy

:::::: TO: Matt Redfearn <matt.redfearn@mips.com>
:::::: CC: James Hogan <jhogan@kernel.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Michael Ellerman Oct. 11, 2018, 12:32 a.m. | #4
Kees Cook <keescook@chromium.org> writes:
> On Tue, Oct 9, 2018 at 10:13 PM, Michael Ellerman <mpe@ellerman.id.au> wrote:
>> Warn whenever a switch statement has a fallthrough without a comment
>> annotating it.
>>
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>
> Yes please. :)
>
> Reviewed-by: Kees Cook <keescook@chromium.org>

Haha, thanks.

It still pops a few errors, including in linux/signal.h & compat.h, so
it's somewhat aspirational until we can get those fixed up :)

cheers
Kees Cook Oct. 11, 2018, 1:35 a.m. | #5
On Wed, Oct 10, 2018 at 5:32 PM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> Kees Cook <keescook@chromium.org> writes:
>> On Tue, Oct 9, 2018 at 10:13 PM, Michael Ellerman <mpe@ellerman.id.au> wrote:
>>> Warn whenever a switch statement has a fallthrough without a comment
>>> annotating it.
>>>
>>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>>
>> Yes please. :)
>>
>> Reviewed-by: Kees Cook <keescook@chromium.org>
>
> Haha, thanks.
>
> It still pops a few errors, including in linux/signal.h & compat.h, so
> it's somewhat aspirational until we can get those fixed up :)

Gustavo, any chance you can target those two files? It could get us a
whole architecture using the flag. :)

-Kees
Gustavo A. R. Silva Oct. 11, 2018, 1:11 p.m. | #6
On 10/11/18 3:35 AM, Kees Cook wrote:
> On Wed, Oct 10, 2018 at 5:32 PM, Michael Ellerman <mpe@ellerman.id.au> wrote:
>> Kees Cook <keescook@chromium.org> writes:
>>> On Tue, Oct 9, 2018 at 10:13 PM, Michael Ellerman <mpe@ellerman.id.au> wrote:
>>>> Warn whenever a switch statement has a fallthrough without a comment
>>>> annotating it.
>>>>
>>>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>>>
>>> Yes please. :)
>>>
>>> Reviewed-by: Kees Cook <keescook@chromium.org>
>>
>> Haha, thanks.
>>
>> It still pops a few errors, including in linux/signal.h & compat.h, so
>> it's somewhat aspirational until we can get those fixed up :)
> 
> Gustavo, any chance you can target those two files? It could get us a
> whole architecture using the flag. :)
> 

Yep. Sure thing.

I'm already taking a look.

Thanks
--
Gustavo
Gustavo A. R. Silva Oct. 11, 2018, 3:23 p.m. | #7
Hi Michael,

On 10/11/18 2:32 AM, Michael Ellerman wrote:

> It still pops a few errors, including in linux/signal.h & compat.h, so
> it's somewhat aspirational until we can get those fixed up :)
> 

I wonder if you have a log containing those warnings that you can
share with me.

I'd like to fix them up.

Thanks
--
Gustavo
Michael Ellerman Oct. 12, 2018, 9:32 a.m. | #8
"Gustavo A. R. Silva" <gustavo@embeddedor.com> writes:

> Hi Michael,
>
> On 10/11/18 2:32 AM, Michael Ellerman wrote:
>
>> It still pops a few errors, including in linux/signal.h & compat.h, so
>> it's somewhat aspirational until we can get those fixed up :)
>> 
>
> I wonder if you have a log containing those warnings that you can
> share with me.

Sure. The kbuild report up thread has some or most of them.

But here's a full list:

Failed 279/290
http://kisskb.ellerman.id.au/kisskb/head/1d59e2c78793d8aea9949ca71323c4583c78f488/
  Failed: powerpc-next/ppc64_defconfig/powerpc-gcc8		(http://kisskb.ellerman.id.au/kisskb/buildresult/13542791/log/)
    /kisskb/src/arch/powerpc/platforms/powermac/feature.c:1477:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
    /kisskb/src/include/linux/signal.h:180:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
    /kisskb/src/include/linux/compat.h:495:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
    /kisskb/src/include/linux/compat.h:496:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
    /kisskb/src/include/linux/compat.h:494:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
  Failed: powerpc-next/corenet64_smp_defconfig/powerpc-gcc8		(http://kisskb.ellerman.id.au/kisskb/buildresult/13542786/log/)
    /kisskb/src/include/linux/compat.h:494:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
    /kisskb/src/include/linux/compat.h:495:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
    /kisskb/src/include/linux/compat.h:496:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
  Failed: powerpc-next/ppc64le_defconfig/powerpc-gcc8		(http://kisskb.ellerman.id.au/kisskb/buildresult/13542777/log/)
    /kisskb/src/include/linux/signal.h:180:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
  Failed: powerpc-next/powernv_defconfig/powerpc-gcc8		(http://kisskb.ellerman.id.au/kisskb/buildresult/13542776/log/)
    /kisskb/src/include/linux/signal.h:180:22: error: this statement may fall through [-Werror=implicit-fallthrough=]

cheers
Gustavo A. R. Silva Oct. 12, 2018, 9:59 a.m. | #9
On 10/12/18 11:32 AM, Michael Ellerman wrote:
> 
> Sure. The kbuild report up thread has some or most of them.
> 
> But here's a full list:
> 
> Failed 279/290
> http://kisskb.ellerman.id.au/kisskb/head/1d59e2c78793d8aea9949ca71323c4583c78f488/
>   Failed: powerpc-next/ppc64_defconfig/powerpc-gcc8		(http://kisskb.ellerman.id.au/kisskb/buildresult/13542791/log/)
>     /kisskb/src/arch/powerpc/platforms/powermac/feature.c:1477:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
>     /kisskb/src/include/linux/signal.h:180:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
>     /kisskb/src/include/linux/compat.h:495:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>     /kisskb/src/include/linux/compat.h:496:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>     /kisskb/src/include/linux/compat.h:494:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>   Failed: powerpc-next/corenet64_smp_defconfig/powerpc-gcc8		(http://kisskb.ellerman.id.au/kisskb/buildresult/13542786/log/)
>     /kisskb/src/include/linux/compat.h:494:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>     /kisskb/src/include/linux/compat.h:495:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>     /kisskb/src/include/linux/compat.h:496:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>   Failed: powerpc-next/ppc64le_defconfig/powerpc-gcc8		(http://kisskb.ellerman.id.au/kisskb/buildresult/13542777/log/)
>     /kisskb/src/include/linux/signal.h:180:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
>   Failed: powerpc-next/powernv_defconfig/powerpc-gcc8		(http://kisskb.ellerman.id.au/kisskb/buildresult/13542776/log/)
>     /kisskb/src/include/linux/signal.h:180:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
>

Thanks, Michael.


Kees, can you take the patches?

Apparently, neither signal.h nor compat.h have a dedicated maintainer:

$ scripts/get_maintainer.pl --nokeywords --nogit --nogit-fallback include/linux/signal.h
linux-kernel@vger.kernel.org (open list)

$ scripts/get_maintainer.pl --nokeywords --nogit --nogit-fallback include/linux/compat.h
linux-kernel@vger.kernel.org (open list)

Thanks
--
Gustavo
Kees Cook Oct. 13, 2018, 1:23 a.m. | #10
On Fri, Oct 12, 2018 at 2:59 AM, Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
>
>
> On 10/12/18 11:32 AM, Michael Ellerman wrote:
>>
>> Sure. The kbuild report up thread has some or most of them.
>>
>> But here's a full list:
>>
>> Failed 279/290
>> http://kisskb.ellerman.id.au/kisskb/head/1d59e2c78793d8aea9949ca71323c4583c78f488/
>>   Failed: powerpc-next/ppc64_defconfig/powerpc-gcc8           (http://kisskb.ellerman.id.au/kisskb/buildresult/13542791/log/)
>>     /kisskb/src/arch/powerpc/platforms/powermac/feature.c:1477:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
>>     /kisskb/src/include/linux/signal.h:180:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
>>     /kisskb/src/include/linux/compat.h:495:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>>     /kisskb/src/include/linux/compat.h:496:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>>     /kisskb/src/include/linux/compat.h:494:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>>   Failed: powerpc-next/corenet64_smp_defconfig/powerpc-gcc8           (http://kisskb.ellerman.id.au/kisskb/buildresult/13542786/log/)
>>     /kisskb/src/include/linux/compat.h:494:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>>     /kisskb/src/include/linux/compat.h:495:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>>     /kisskb/src/include/linux/compat.h:496:51: error: this statement may fall through [-Werror=implicit-fallthrough=]
>>   Failed: powerpc-next/ppc64le_defconfig/powerpc-gcc8         (http://kisskb.ellerman.id.au/kisskb/buildresult/13542777/log/)
>>     /kisskb/src/include/linux/signal.h:180:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
>>   Failed: powerpc-next/powernv_defconfig/powerpc-gcc8         (http://kisskb.ellerman.id.au/kisskb/buildresult/13542776/log/)
>>     /kisskb/src/include/linux/signal.h:180:22: error: this statement may fall through [-Werror=implicit-fallthrough=]
>>
>
> Thanks, Michael.
>
>
> Kees, can you take the patches?
>
> Apparently, neither signal.h nor compat.h have a dedicated maintainer:
>
> $ scripts/get_maintainer.pl --nokeywords --nogit --nogit-fallback include/linux/signal.h
> linux-kernel@vger.kernel.org (open list)
>
> $ scripts/get_maintainer.pl --nokeywords --nogit --nogit-fallback include/linux/compat.h
> linux-kernel@vger.kernel.org (open list)

Normally things like that go through akpm, but I'm happy to carry them
if needed.

-Kees
Gustavo A. R. Silva Oct. 13, 2018, 7:39 a.m. | #11
On 10/13/18 3:23 AM, Kees Cook wrote:

>>
>> $ scripts/get_maintainer.pl --nokeywords --nogit --nogit-fallback include/linux/compat.h
>> linux-kernel@vger.kernel.org (open list)
> 
> Normally things like that go through akpm, but I'm happy to carry them
> if needed.
> 

Oh okay. Let me try through apkm first. :)

Thanks
--
Gustavo

Patch

diff --git a/arch/powerpc/Kbuild b/arch/powerpc/Kbuild
index 86b261d6bde5..ef625f1db576 100644
--- a/arch/powerpc/Kbuild
+++ b/arch/powerpc/Kbuild
@@ -1,4 +1,5 @@ 
 subdir-ccflags-y := $(call cc-option, -Wvla)
+subdir-ccflags-y += $(call cc-option, -Wimplicit-fallthrough)
 subdir-ccflags-$(CONFIG_PPC_WERROR) += -Werror
 
 obj-y += kernel/