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 5BDACC433F5 for ; Tue, 25 Jan 2022 10:33:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B941E6B0074; Tue, 25 Jan 2022 05:33:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B42F26B007D; Tue, 25 Jan 2022 05:33:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A315A6B0080; Tue, 25 Jan 2022 05:33:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id 94F9F6B0074 for ; Tue, 25 Jan 2022 05:33:41 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 469A28EBFC for ; Tue, 25 Jan 2022 10:33:41 +0000 (UTC) X-FDA: 79068448242.31.4ACAFD2 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf24.hostedemail.com (Postfix) with ESMTP id 45975180025 for ; Tue, 25 Jan 2022 10:33:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643106820; x=1674642820; h=date:from:to:cc:subject:message-id:mime-version; bh=MZWc+EyHeVgUtSTvAQft01ATbDa6XBaNm1u0up5hVXw=; b=V7wHvRiiLyiTvHLX/fVMFYUpfj4Hs82X4zyxgJuq7y+7rNJH1GizthWH QnmmHhiFLCh2SRnVIQq+OsWUoUzUt0QdAUJd80vrE8dqXJfCTJCNif3wp iqMoPmcN5R5OI+oieDHQH3okcb0dIWe2ULQLO0KvB/6q9g5q+P6PzVUk0 cy2XBUANe1NakXoFTRqWOZhjKVh4WUDQEQbkKqCRjd+3CeRCMZOb0jf2q qJMpYZup0nBmWcG90zwwUrbr4TAN9u1cMmP3HuC132ptOoKXdUhZ7oa6R PQkZARs0n9tGmjvcO4ObReP7VdMLOiHsKnpF2nhep3SGEr6ivIwmwqCZh Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="270718081" X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="270718081" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2022 02:33:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="627863363" Received: from lkp-server01.sh.intel.com (HELO 276f1b88eecb) ([10.239.97.150]) by orsmga004.jf.intel.com with ESMTP; 25 Jan 2022 02:33:37 -0800 Received: from kbuild by 276f1b88eecb with local (Exim 4.92) (envelope-from ) id 1nCJ8q-000JkB-CV; Tue, 25 Jan 2022 10:33:36 +0000 Date: Tue, 25 Jan 2022 18:33:09 +0800 From: kernel test robot To: Kees Cook Cc: kbuild-all@lists.01.org, Linux Memory Management List Subject: [linux-next:master 1562/1734] include/linux/fortify-string.h:275:25: warning: call to '__read_overflow2_field' declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? Message-ID: <202201251833.Hon4gcuF-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: nil X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 45975180025 X-Stat-Signature: wrcjf7xnnn3nm81wsfe7a1wuw7ocfj59 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=V7wHvRii; spf=none (imf24.hostedemail.com: domain of lkp@intel.com has no SPF policy when checking 192.55.52.88) smtp.mailfrom=lkp@intel.com; dmarc=pass (policy=none) header.from=intel.com X-HE-Tag: 1643106820-347440 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: d25ee88530253138d0b20d43511ca5acbda4e9f7 commit: 602670289b69b2fded3a0b2240c4877e3a015ac6 [1562/1734] fortify: Detect struct member overflows in memcpy() at compile-time config: arm-aspeed_g5_defconfig (https://download.01.org/0day-ci/archive/20220125/202201251833.Hon4gcuF-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=602670289b69b2fded3a0b2240c4877e3a015ac6 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 602670289b69b2fded3a0b2240c4877e3a015ac6 # 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 net/core/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (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/spinlock.h:62, from include/linux/wait.h:9, from include/linux/wait_bit.h:8, from include/linux/fs.h:6, from include/linux/highmem.h:5, from include/linux/bvec.h:10, from include/linux/skbuff.h:17, from net/core/flow_dissector.c:3: In function 'fortify_memcpy_chk', inlined from '__skb_flow_dissect' at net/core/flow_dissector.c:1034:3: >> include/linux/fortify-string.h:275:25: warning: call to '__read_overflow2_field' declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning] 275 | __read_overflow2_field(q_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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.) 220 * 221 * Mitigation coverage 222 * Bounds checking at: 223 * +-------+-------+-------+-------+ 224 * | Compile time | Run time | 225 * memcpy() argument sizes: | write | read | write | read | 226 * +-------+-------+-------+-------+ 227 * memcpy(known, known, constant) | y | y | n/a | n/a | 228 * memcpy(unknown, known, constant) | n | y | V | n/a | 229 * memcpy(known, unknown, constant) | y | n | n/a | V | 230 * memcpy(unknown, unknown, constant) | n | n | V | V | 231 * memcpy(known, known, dynamic) | n | n | b | B | 232 * memcpy(unknown, known, dynamic) | n | n | V | B | 233 * memcpy(known, unknown, dynamic) | n | n | b | V | 234 * memcpy(unknown, unknown, dynamic) | n | n | V | V | 235 * +-------+-------+-------+-------+ 236 * 237 * y = deterministic compile-time bounds checking 238 * n = cannot do deterministic compile-time bounds checking 239 * n/a = no run-time bounds checking needed since compile-time deterministic 240 * b = perform run-time bounds checking 241 * B = can perform run-time bounds checking, but current unenforced 242 * V = vulnerable to run-time overflow 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