From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4F42C433F5 for ; Sun, 13 Feb 2022 13:25:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 076076B0072; Sun, 13 Feb 2022 08:25:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F41866B0073; Sun, 13 Feb 2022 08:25:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE0C86B0078; Sun, 13 Feb 2022 08:25:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id C906C6B0072 for ; Sun, 13 Feb 2022 08:25:00 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7AA2E9637D for ; Sun, 13 Feb 2022 13:25:00 +0000 (UTC) X-FDA: 79137827160.27.0B15FB8 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by imf25.hostedemail.com (Postfix) with ESMTP id 0E49DA0002 for ; Sun, 13 Feb 2022 13:24:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644758699; x=1676294699; h=date:from:to:cc:subject:message-id:mime-version; bh=K8MLfc96LZUKn4L3xBL6Opty/SC0w5oFFwzZwR+TI4A=; b=X53ptbouaRRCx9deEtcUcOzsHhLLFsruaCigf9ZZbxcStklYtPsGp3aK 72ceeqgo4xPqAtvgWAG5vVIrjG4Cy+2MFHyShdrvbteoA249feLxByLZU Z7+uCT4odflRGBoZ79cd9jOJ3K2KgUnz2jkLRMMKzH/QhFDN91yIs9F0h 7OtaE65gJ8BCZbFCjmQxrTKUJ4+vF9US9n/G5R87vIVic8JAhXUrajA/o x2cipMYix9+myrrILUaj+gEjqHIuctAbdyeFFt2mrL/J3QO4AmxJYsU8B Yq0IbdzZd9K1SKY27RnVZTrP0P+eVUnMowB3pKpFyySUnCU65QUYbuI8U g==; X-IronPort-AV: E=McAfee;i="6200,9189,10256"; a="310686064" X-IronPort-AV: E=Sophos;i="5.88,365,1635231600"; d="scan'208";a="310686064" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2022 05:24:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,365,1635231600"; d="scan'208";a="586825892" Received: from lkp-server01.sh.intel.com (HELO d95dc2dabeb1) ([10.239.97.150]) by fmsmga008.fm.intel.com with ESMTP; 13 Feb 2022 05:24:56 -0800 Received: from kbuild by d95dc2dabeb1 with local (Exim 4.92) (envelope-from ) id 1nJEs3-0007XP-Nk; Sun, 13 Feb 2022 13:24:55 +0000 Date: Sun, 13 Feb 2022 21:23:56 +0800 From: kernel test robot To: Kees Cook Cc: kbuild-all@lists.01.org, Linux Memory Management List Subject: [linux-next:master 4413/5417] include/linux/fortify-string.h:275:25: error: call to '__read_overflow2_field' declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? Message-ID: <202202132148.O500YcwH-lkp@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0E49DA0002 X-Stat-Signature: aoqwr3o9xu4to1t85cnkibe4scahdco3 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=X53ptbou; spf=none (imf25.hostedemail.com: domain of lkp@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=lkp@intel.com; dmarc=pass (policy=none) header.from=intel.com X-HE-Tag: 1644758698-358062 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 6d9bd4ad4ca08b1114e814c2c42383b8b13be631 commit: 9b106a9037d705d0c5cbc747b6fed7cbb33b0e00 [4413/5417] fortify: Detect struct member overflows in memcpy() at compile-time config: arm-randconfig-c002-20220213 (https://download.01.org/0day-ci/archive/20220213/202202132148.O500YcwH-lkp@intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 11.2.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/next/linux-next.git/commit/?id=9b106a9037d705d0c5cbc747b6fed7cbb33b0e00 git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git fetch --no-tags linux-next master git checkout 9b106a9037d705d0c5cbc747b6fed7cbb33b0e00 # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash drivers/nfc/pn533/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): In file included from include/linux/string.h:253, from include/linux/bitmap.h:11, from include/linux/cpumask.h:12, from include/linux/smp.h:13, from include/linux/lockdep.h:14, from include/linux/rcupdate.h:29, from include/linux/rculist.h:11, from include/linux/pid.h:5, from include/linux/sched.h:14, from include/linux/ratelimit.h:6, from include/linux/dev_printk.h:16, from include/linux/device.h:15, from drivers/nfc/pn533/pn533.c:9: In function 'fortify_memcpy_chk', inlined from 'pn533_target_found_felica.part.0' at drivers/nfc/pn533/pn533.c:781:2: >> include/linux/fortify-string.h:275:25: error: call to '__read_overflow2_field' declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning] 275 | __read_overflow2_field(q_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors vim +/__read_overflow2_field +275 include/linux/fortify-string.h 213 214 /* 215 * To make sure the compiler can enforce protection against buffer overflows, 216 * memcpy(), memmove(), and memset() must not be used beyond individual 217 * struct members. If you need to copy across multiple members, please use 218 * struct_group() to create a named mirror of an anonymous struct union. 219 * (e.g. see struct sk_buff.) Read overflow checking is currently only 220 * done when a write overflow is also present, or when building with W=1. 221 * 222 * Mitigation coverage matrix 223 * Bounds checking at: 224 * +-------+-------+-------+-------+ 225 * | Compile time | Run time | 226 * memcpy() argument sizes: | write | read | write | read | 227 * dest source length +-------+-------+-------+-------+ 228 * memcpy(known, known, constant) | y | y | n/a | n/a | 229 * memcpy(known, unknown, constant) | y | n | n/a | V | 230 * memcpy(known, known, dynamic) | n | n | B | B | 231 * memcpy(known, unknown, dynamic) | n | n | B | V | 232 * memcpy(unknown, known, constant) | n | y | V | n/a | 233 * memcpy(unknown, unknown, constant) | n | n | V | V | 234 * memcpy(unknown, known, dynamic) | n | n | V | B | 235 * memcpy(unknown, unknown, dynamic) | n | n | V | V | 236 * +-------+-------+-------+-------+ 237 * 238 * y = perform deterministic compile-time bounds checking 239 * n = cannot perform deterministic compile-time bounds checking 240 * n/a = no run-time bounds checking needed since compile-time deterministic 241 * B = can perform run-time bounds checking (currently unimplemented) 242 * V = vulnerable to run-time overflow (will need refactoring to solve) 243 * 244 */ 245 __FORTIFY_INLINE void fortify_memcpy_chk(__kernel_size_t size, 246 const size_t p_size, 247 const size_t q_size, 248 const size_t p_size_field, 249 const size_t q_size_field, 250 const char *func) 251 { 252 if (__builtin_constant_p(size)) { 253 /* 254 * Length argument is a constant expression, so we 255 * can perform compile-time bounds checking where 256 * buffer sizes are known. 257 */ 258 259 /* Error when size is larger than enclosing struct. */ 260 if (p_size > p_size_field && p_size < size) 261 __write_overflow(); 262 if (q_size > q_size_field && q_size < size) 263 __read_overflow2(); 264 265 /* Warn when write size argument larger than dest field. */ 266 if (p_size_field < size) 267 __write_overflow_field(p_size_field, size); 268 /* 269 * Warn for source field over-read when building with W=1 270 * or when an over-write happened, so both can be fixed at 271 * the same time. 272 */ 273 if ((IS_ENABLED(KBUILD_EXTRA_WARN1) || p_size_field < size) && 274 q_size_field < size) > 275 __read_overflow2_field(q_size_field, size); 276 } 277 /* 278 * At this point, length argument may not be a constant expression, 279 * so run-time bounds checking can be done where buffer sizes are 280 * known. (This is not an "else" because the above checks may only 281 * be compile-time warnings, and we want to still warn for run-time 282 * overflows.) 283 */ 284 285 /* 286 * Always stop accesses beyond the struct that contains the 287 * field, when the buffer's remaining size is known. 288 * (The -1 test is to optimize away checks where the buffer 289 * lengths are unknown.) 290 */ 291 if ((p_size != (size_t)(-1) && p_size < size) || 292 (q_size != (size_t)(-1) && q_size < size)) 293 fortify_panic(func); 294 } 295 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org