All of lore.kernel.org
 help / color / mirror / Atom feed
* [kees:kspp/memcpy/next-20210621/v0 76/86] include/linux/fortify-string.h:194:4: warning: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()?
@ 2021-06-22  1:33 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-06-22  1:33 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4458 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git kspp/memcpy/next-20210621/v0
head:   711a2c0c23d479d212e8d80f5dcaaf267162c8de
commit: bcd1e43915effef8bcc583726d55e91780ad7a63 [76/86] fortify: Detect struct member overflows in memset()
config: mips-randconfig-r011-20210621 (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=bcd1e43915effef8bcc583726d55e91780ad7a63
        git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
        git fetch --no-tags kees kspp/memcpy/next-20210621/v0
        git checkout bcd1e43915effef8bcc583726d55e91780ad7a63
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/string.h:253,
                    from include/linux/bitmap.h:10,
                    from include/linux/cpumask.h:12,
                    from arch/mips/include/asm/processor.h:15,
                    from arch/mips/include/asm/thread_info.h:16,
                    from include/linux/thread_info.h:60,
                    from include/linux/uio.h:9,
                    from include/linux/socket.h:8,
                    from include/uapi/linux/can.h:50,
                    from drivers/net/can/flexcan.c:14:
   In function '__fortify_memset',
       inlined from 'flexcan_ram_init' at arch/mips/include/asm/io.h:495:2,
       inlined from 'flexcan_chip_start' at drivers/net/can/flexcan.c:1485:3:
>> include/linux/fortify-string.h:194:4: warning: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning]
     194 |    __write_overflow_field();
         |    ^~~~~~~~~~~~~~~~~~~~~~~~
   In function '__fortify_memset',
       inlined from 'flexcan_ram_init' at arch/mips/include/asm/io.h:495:2,
       inlined from 'flexcan_chip_start' at drivers/net/can/flexcan.c:1485:3:
>> include/linux/fortify-string.h:194:4: warning: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning]
     194 |    __write_overflow_field();
         |    ^~~~~~~~~~~~~~~~~~~~~~~~


vim +/__write_overflow_field +194 include/linux/fortify-string.h

   178	
   179	#define memset(p, c, s) __fortify_memset(p, c, s)
   180	__FORTIFY_INLINE void *__fortify_memset(void *p, int c, __kernel_size_t size)
   181	{
   182		size_t p_size = __builtin_object_size(p, 0);
   183		size_t p_size_field = __builtin_object_size(p, 1);
   184	
   185		if (__builtin_constant_p(size)) {
   186			/*
   187			 * Length argument is a constant expression, so we
   188			 * can perform compile-time bounds checking where
   189			 * buffer sizes are known.
   190			 */
   191	
   192			/* Disallow size argument larger than dest field. */
   193			if (p_size_field < size)
 > 194				__write_overflow_field();
   195		} else {
   196			/*
   197			 * Length argument is not a constant expression, so
   198			 * run-time bounds checking can happen where buffer
   199			 * sizes are known.
   200			 */
   201	
   202			/*
   203			 * Warn when writing beyond destination field size.
   204			 * Since flexible-arrays are considered 0 bytes, we
   205			 * must ignore 0 sizes at runtime for now.
   206			 */
   207			if (p_size_field && p_size != p_size_field && p_size_field < size)
   208				fortify_warn_write("memset", p_size_field, size);
   209	
   210			/*
   211			 * Always stop accesses beyond the struct that contains the
   212			 * field, when the buffer's remaining size is known.
   213			 */
   214			if (p_size != (size_t)(-1) && p_size < size)
   215				fortify_panic("memset");
   216		}
   217		return __underlying_memset(p, c, size);
   218	}
   219	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35965 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-22  1:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22  1:33 [kees:kspp/memcpy/next-20210621/v0 76/86] include/linux/fortify-string.h:194:4: warning: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.