From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============8719569475017124169==" MIME-Version: 1.0 From: kernel test robot To: kbuild-all@lists.01.org Subject: Re: [PATCH 06/17] fortify: Detect struct member overflows in memcpy() at compile-time Date: Tue, 14 Dec 2021 11:56:21 +0800 Message-ID: <202112141126.S8eWMmlc-lkp@intel.com> In-Reply-To: <20211213223331.135412-7-keescook@chromium.org> List-Id: --===============8719569475017124169== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Kees, I love your patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on v5.16-rc5] [cannot apply to rdma/for-next axboe-block/for-next kvm/queue tip/x86/core = mkp-scsi/for-next jejb-scsi/for-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Kees-Cook/Enable-strict-co= mpile-time-memcpy-fortify-checks/20211214-064002 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git = aa50faff4416c869b52dff68a937c84d29e12f4b config: i386-randconfig-s002-20211213 (https://download.01.org/0day-ci/arch= ive/20211214/202112141126.S8eWMmlc-lkp(a)intel.com/config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.4-dirty # https://github.com/0day-ci/linux/commit/80c8d2aae95aae6bd09e3ef84= b74d0afe631abae git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Kees-Cook/Enable-strict-compile-ti= me-memcpy-fortify-checks/20211214-064002 git checkout 80c8d2aae95aae6bd09e3ef84b74d0afe631abae # save the config file to linux build tree mkdir build_dir make W=3D1 C=3D1 CF=3D'-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=3D= build_dir ARCH=3Di386 SHELL=3D/bin/bash drivers/pci/endpoint/functions/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot sparse warnings: (new ones prefixed by >>) >> drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: sparse: in= correct type in argument 1 (different address spaces) @@ expected void = const * @@ got void [noderef] __iomem *[assigned] dst_addr @@ drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: expect= ed void const * drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: got vo= id [noderef] __iomem *[assigned] dst_addr drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: sparse: in= correct type in argument 1 (different address spaces) @@ expected void = const * @@ got void [noderef] __iomem *[assigned] src_addr @@ drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: expect= ed void const * drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: got vo= id [noderef] __iomem *[assigned] src_addr >> drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: sparse: in= correct type in argument 1 (different address spaces) @@ expected void = const * @@ got void [noderef] __iomem *[assigned] dst_addr @@ drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: expect= ed void const * drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: got vo= id [noderef] __iomem *[assigned] dst_addr drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: sparse: in= correct type in argument 1 (different address spaces) @@ expected void = const * @@ got void [noderef] __iomem *[assigned] src_addr @@ drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: expect= ed void const * drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: got vo= id [noderef] __iomem *[assigned] src_addr drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: sparse: in= correct type in argument 1 (different address spaces) @@ expected void = * @@ got void [noderef] __iomem *[assigned] dst_addr @@ drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: expect= ed void * drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: got vo= id [noderef] __iomem *[assigned] dst_addr drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: sparse: in= correct type in argument 2 (different address spaces) @@ expected void = const * @@ got void [noderef] __iomem *[assigned] src_addr @@ drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: expect= ed void const * drivers/pci/endpoint/functions/pci-epf-test.c:288:17: sparse: got vo= id [noderef] __iomem *[assigned] src_addr vim +288 drivers/pci/endpoint/functions/pci-epf-test.c 5893c2e5353bb9a Kishon Vijay Abraham I 2020-03-16 226 = 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 227 static int pci_epf_= test_copy(struct pci_epf_test *epf_test) 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 228 { 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 229 int ret; 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 230 bool use_dma; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 231 void __iomem *src_= addr; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 232 void __iomem *dst_= addr; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 233 phys_addr_t src_ph= ys_addr; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 234 phys_addr_t dst_ph= ys_addr; 5893c2e5353bb9a Kishon Vijay Abraham I 2020-03-16 235 struct timespec64 = start, end; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 236 struct pci_epf *ep= f =3D epf_test->epf; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 237 struct device *dev= =3D &epf->dev; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 238 struct pci_epc *ep= c =3D epf->epc; 3235b994950d84d Kishon Vijay Abraham I 2017-08-18 239 enum pci_barno tes= t_reg_bar =3D epf_test->test_reg_bar; 3235b994950d84d Kishon Vijay Abraham I 2017-08-18 240 struct pci_epf_tes= t_reg *reg =3D epf_test->reg[test_reg_bar]; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 241 = 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 242 src_addr =3D pci_e= pc_mem_alloc_addr(epc, &src_phys_addr, reg->size); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 243 if (!src_addr) { 798c0441bec8c46 Gustavo Pimentel 2018-05-14 244 dev_err(dev, "Fai= led to allocate source address\n"); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 245 reg->status =3D S= TATUS_SRC_ADDR_INVALID; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 246 ret =3D -ENOMEM; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 247 goto err; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 248 } 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 249 = 53fd3cbe5e9d791 Kishon Vijay Abraham I 2021-08-19 250 ret =3D pci_epc_ma= p_addr(epc, epf->func_no, epf->vfunc_no, src_phys_addr, 53fd3cbe5e9d791 Kishon Vijay Abraham I 2021-08-19 251 reg->src_= addr, reg->size); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 252 if (ret) { 798c0441bec8c46 Gustavo Pimentel 2018-05-14 253 dev_err(dev, "Fai= led to map source address\n"); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 254 reg->status =3D S= TATUS_SRC_ADDR_INVALID; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 255 goto err_src_addr; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 256 } 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 257 = 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 258 dst_addr =3D pci_e= pc_mem_alloc_addr(epc, &dst_phys_addr, reg->size); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 259 if (!dst_addr) { 798c0441bec8c46 Gustavo Pimentel 2018-05-14 260 dev_err(dev, "Fai= led to allocate destination address\n"); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 261 reg->status =3D S= TATUS_DST_ADDR_INVALID; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 262 ret =3D -ENOMEM; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 263 goto err_src_map_= addr; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 264 } 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 265 = 53fd3cbe5e9d791 Kishon Vijay Abraham I 2021-08-19 266 ret =3D pci_epc_ma= p_addr(epc, epf->func_no, epf->vfunc_no, dst_phys_addr, 53fd3cbe5e9d791 Kishon Vijay Abraham I 2021-08-19 267 reg->dst_= addr, reg->size); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 268 if (ret) { 798c0441bec8c46 Gustavo Pimentel 2018-05-14 269 dev_err(dev, "Fai= led to map destination address\n"); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 270 reg->status =3D S= TATUS_DST_ADDR_INVALID; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 271 goto err_dst_addr; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 272 } 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 273 = 5893c2e5353bb9a Kishon Vijay Abraham I 2020-03-16 274 ktime_get_ts64(&st= art); 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 275 use_dma =3D !!(reg= ->flags & FLAG_USE_DMA); 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 276 if (use_dma) { 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 277 if (!epf_test->dm= a_supported) { 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 278 dev_err(dev, "Ca= nnot transfer data using DMA\n"); 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 279 ret =3D -EINVAL; 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 280 goto err_map_add= r; 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 281 } 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 282 = 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 283 ret =3D pci_epf_t= est_data_transfer(epf_test, dst_phys_addr, 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 284 src_phys_add= r, reg->size); 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 285 if (ret) 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 286 dev_err(dev, "Da= ta transfer failed\n"); 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 287 } else { 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 @288 memcpy(dst_addr, = src_addr, reg->size); 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 289 } 5893c2e5353bb9a Kishon Vijay Abraham I 2020-03-16 290 ktime_get_ts64(&en= d); 5893c2e5353bb9a Kishon Vijay Abraham I 2020-03-16 291 pci_epf_test_print= _rate("COPY", reg->size, &start, &end, use_dma); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 292 = 5ebf3fc59bd20d1 Kishon Vijay Abraham I 2020-03-16 293 err_map_addr: 53fd3cbe5e9d791 Kishon Vijay Abraham I 2021-08-19 294 pci_epc_unmap_addr= (epc, epf->func_no, epf->vfunc_no, dst_phys_addr); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 295 = 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 296 err_dst_addr: 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 297 pci_epc_mem_free_a= ddr(epc, dst_phys_addr, dst_addr, reg->size); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 298 = 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 299 err_src_map_addr: 53fd3cbe5e9d791 Kishon Vijay Abraham I 2021-08-19 300 pci_epc_unmap_addr= (epc, epf->func_no, epf->vfunc_no, src_phys_addr); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 301 = 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 302 err_src_addr: 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 303 pci_epc_mem_free_a= ddr(epc, src_phys_addr, src_addr, reg->size); 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 304 = 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 305 err: 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 306 return ret; 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 307 } 349e7a85b25fa6e Kishon Vijay Abraham I 2017-03-27 308 = --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org --===============8719569475017124169==--