tree: https://github.com/ammarfaizi2/linux-block viro/vfs/untested.blk-map head: a4d354f96b0ba54c70a420f797477619a550cecf commit: e988b46f35821f08cafe55c89ddb4b5fcbcc05b1 [10/22] sg_io(): switch to setting bio chain first config: s390-randconfig-r044-20221211 compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 6e4cea55f0d1104408b26ac574566a0e4de48036) 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 # install s390 cross compiling tool for clang build # apt-get install binutils-s390x-linux-gnu # https://github.com/ammarfaizi2/linux-block/commit/e988b46f35821f08cafe55c89ddb4b5fcbcc05b1 git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block git fetch --no-tags ammarfaizi2-block viro/vfs/untested.blk-map git checkout e988b46f35821f08cafe55c89ddb4b5fcbcc05b1 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot All warnings (new ones prefixed by >>): In file included from drivers/scsi/scsi_ioctl.c:19: In file included from include/scsi/scsi.h:10: In file included from include/linux/scatterlist.h:9: In file included from arch/s390/include/asm/io.h:75: include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __raw_readb(PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu' #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x)) ^ include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16' #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x)) ^ In file included from drivers/scsi/scsi_ioctl.c:19: In file included from include/scsi/scsi.h:10: In file included from include/linux/scatterlist.h:9: In file included from arch/s390/include/asm/io.h:75: include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu' #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x)) ^ include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32' #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x)) ^ In file included from drivers/scsi/scsi_ioctl.c:19: In file included from include/scsi/scsi.h:10: In file included from include/linux/scatterlist.h:9: In file included from arch/s390/include/asm/io.h:75: include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writeb(value, PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsb(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsw(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] readsl(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesb(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesw(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] writesl(PCI_IOBASE + addr, buffer, count); ~~~~~~~~~~ ^ >> drivers/scsi/scsi_ioctl.c:394:6: warning: variable 'writing' set but not used [-Wunused-but-set-variable] int writing = 0; ^ 13 warnings generated. vim +/writing +394 drivers/scsi/scsi_ioctl.c f2542a3be3277a Christoph Hellwig 2021-07-24 389 a30e3441325ba4 Christoph Hellwig 2021-11-26 390 static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode) f2542a3be3277a Christoph Hellwig 2021-07-24 391 { f2542a3be3277a Christoph Hellwig 2021-07-24 392 unsigned long start_time; f2542a3be3277a Christoph Hellwig 2021-07-24 393 ssize_t ret = 0; f2542a3be3277a Christoph Hellwig 2021-07-24 @394 int writing = 0; f2542a3be3277a Christoph Hellwig 2021-07-24 395 int at_head = 0; f2542a3be3277a Christoph Hellwig 2021-07-24 396 struct request *rq; ce70fd9a551af7 Christoph Hellwig 2022-02-24 397 struct scsi_cmnd *scmd; f2542a3be3277a Christoph Hellwig 2021-07-24 398 struct bio *bio; e988b46f35821f Al Viro 2022-12-06 399 unsigned char sense[SCSI_SENSE_BUFFERSIZE]; e988b46f35821f Al Viro 2022-12-06 400 unsigned char cmnd[sizeof(scmd->cmnd)]; e988b46f35821f Al Viro 2022-12-06 401 blk_opf_t opf = REQ_OP_DRV_IN; f2542a3be3277a Christoph Hellwig 2021-07-24 402 f2542a3be3277a Christoph Hellwig 2021-07-24 403 if (hdr->interface_id != 'S') f2542a3be3277a Christoph Hellwig 2021-07-24 404 return -EINVAL; f2542a3be3277a Christoph Hellwig 2021-07-24 405 1e61c1a804d2a2 Christoph Hellwig 2021-07-29 406 if (hdr->dxfer_len > (queue_max_hw_sectors(sdev->request_queue) << 9)) f2542a3be3277a Christoph Hellwig 2021-07-24 407 return -EIO; f2542a3be3277a Christoph Hellwig 2021-07-24 408 f2542a3be3277a Christoph Hellwig 2021-07-24 409 if (hdr->dxfer_len) f2542a3be3277a Christoph Hellwig 2021-07-24 410 switch (hdr->dxfer_direction) { f2542a3be3277a Christoph Hellwig 2021-07-24 411 default: f2542a3be3277a Christoph Hellwig 2021-07-24 412 return -EINVAL; f2542a3be3277a Christoph Hellwig 2021-07-24 413 case SG_DXFER_TO_DEV: f2542a3be3277a Christoph Hellwig 2021-07-24 414 writing = 1; e988b46f35821f Al Viro 2022-12-06 415 opf = REQ_OP_DRV_OUT; f2542a3be3277a Christoph Hellwig 2021-07-24 416 break; f2542a3be3277a Christoph Hellwig 2021-07-24 417 case SG_DXFER_TO_FROM_DEV: f2542a3be3277a Christoph Hellwig 2021-07-24 418 case SG_DXFER_FROM_DEV: f2542a3be3277a Christoph Hellwig 2021-07-24 419 break; f2542a3be3277a Christoph Hellwig 2021-07-24 420 } f2542a3be3277a Christoph Hellwig 2021-07-24 421 if (hdr->flags & SG_FLAG_Q_AT_HEAD) f2542a3be3277a Christoph Hellwig 2021-07-24 422 at_head = 1; f2542a3be3277a Christoph Hellwig 2021-07-24 423 e988b46f35821f Al Viro 2022-12-06 424 if (hdr->cmd_len > sizeof(cmnd)) e988b46f35821f Al Viro 2022-12-06 425 return -EINVAL; f2542a3be3277a Christoph Hellwig 2021-07-24 426 e988b46f35821f Al Viro 2022-12-06 427 if (hdr->cmd_len < 6) e988b46f35821f Al Viro 2022-12-06 428 return -EMSGSIZE; e988b46f35821f Al Viro 2022-12-06 429 if (copy_from_user(cmnd, hdr->cmdp, hdr->cmd_len)) e988b46f35821f Al Viro 2022-12-06 430 return -EFAULT; e988b46f35821f Al Viro 2022-12-06 431 if (!scsi_cmd_allowed(cmnd, mode)) e988b46f35821f Al Viro 2022-12-06 432 return -EPERM; f2542a3be3277a Christoph Hellwig 2021-07-24 433 e988b46f35821f Al Viro 2022-12-06 434 bio = blk_map_user_io(sdev->request_queue, opf, NULL, e988b46f35821f Al Viro 2022-12-06 435 hdr->dxferp, hdr->dxfer_len, e988b46f35821f Al Viro 2022-12-06 436 hdr->iovec_count && hdr->dxfer_len, e988b46f35821f Al Viro 2022-12-06 437 hdr->iovec_count, 0); e988b46f35821f Al Viro 2022-12-06 438 if (IS_ERR(bio)) e988b46f35821f Al Viro 2022-12-06 439 return PTR_ERR(bio); f2542a3be3277a Christoph Hellwig 2021-07-24 440 e988b46f35821f Al Viro 2022-12-06 441 rq = scsi_alloc_request(sdev->request_queue, opf, 0); e988b46f35821f Al Viro 2022-12-06 442 if (IS_ERR(rq)) { e988b46f35821f Al Viro 2022-12-06 443 blk_rq_unmap_user(bio); e988b46f35821f Al Viro 2022-12-06 444 return PTR_ERR(rq); e988b46f35821f Al Viro 2022-12-06 445 } e988b46f35821f Al Viro 2022-12-06 446 e988b46f35821f Al Viro 2022-12-06 447 blk_rq_attach_bios(rq, bio); f2542a3be3277a Christoph Hellwig 2021-07-24 448 e988b46f35821f Al Viro 2022-12-06 449 scmd = blk_mq_rq_to_pdu(rq); e988b46f35821f Al Viro 2022-12-06 450 scsi_fill_sghdr_rq(sdev, rq, hdr, cmnd); 6aded12b10e0c9 Christoph Hellwig 2022-02-24 451 scmd->allowed = 0; f2542a3be3277a Christoph Hellwig 2021-07-24 452 f2542a3be3277a Christoph Hellwig 2021-07-24 453 start_time = jiffies; f2542a3be3277a Christoph Hellwig 2021-07-24 454 b84ba30b6c7a75 Christoph Hellwig 2021-11-26 455 blk_execute_rq(rq, at_head); f2542a3be3277a Christoph Hellwig 2021-07-24 456 f2542a3be3277a Christoph Hellwig 2021-07-24 457 hdr->duration = jiffies_to_msecs(jiffies - start_time); e988b46f35821f Al Viro 2022-12-06 458 scsi_complete_sghdr_rq(rq, hdr, sense); f2542a3be3277a Christoph Hellwig 2021-07-24 459 0bf6d96cb82940 Christoph Hellwig 2021-10-25 460 blk_mq_free_request(rq); e988b46f35821f Al Viro 2022-12-06 461 ret = blk_rq_unmap_user(bio); e988b46f35821f Al Viro 2022-12-06 462 if (hdr->sb_len_wr && copy_to_user(hdr->sbp, sense, hdr->sb_len_wr)) e988b46f35821f Al Viro 2022-12-06 463 ret = -EFAULT; f2542a3be3277a Christoph Hellwig 2021-07-24 464 return ret; f2542a3be3277a Christoph Hellwig 2021-07-24 465 } f2542a3be3277a Christoph Hellwig 2021-07-24 466 :::::: The code at line 394 was first introduced by commit :::::: f2542a3be3277a65c766fa6e86b930d3d839f79e scsi: scsi_ioctl: Move the "block layer" SCSI ioctl handling to drivers/scsi :::::: TO: Christoph Hellwig :::::: CC: Martin K. Petersen -- 0-DAY CI Kernel Test Service https://01.org/lkp