lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <201812260515.ZT3AtaMb%fengguang.wu@intel.com>
Date:   Wed, 26 Dec 2018 05:11:55 +0800
From:   kbuild test robot <lkp@...el.com>
To:     Kangjie Lu <kjlu@....edu>
Cc:     kbuild-all@...org, kjlu@....edu, pakki001@....edu,
        Doug Gilbert <dgilbert@...erlog.com>,
        "James E.J. Bottomley" <jejb@...ux.vnet.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] scsi: avoid a double-fetch and a redundant copy

Hi Kangjie,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on scsi/for-next]
[also build test ERROR on v4.20 next-20181224]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Kangjie-Lu/scsi-avoid-a-double-fetch-and-a-redundant-copy/20181226-042018
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: i386-randconfig-x079-201851 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/uaccess.h:14:0,
                    from include/linux/poll.h:12,
                    from drivers//scsi/sg.c:42:
   drivers//scsi/sg.c: In function 'sg_read':
>> drivers//scsi/sg.c:450:27: error: request for member 'pack_id' in something not a structure or union
          &((sg_io_hdr_t *)buf->pack_id));
                              ^
   arch/x86/include/asm/uaccess.h:138:41: note: in definition of macro '__inttype'
    __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
                                            ^
>> drivers//scsi/sg.c:449:14: note: in expansion of macro 'get_user'
        retval = get_user(req_pack_id,
                 ^~~~~~~~
>> arch/x86/include/asm/uaccess.h:138:12: error: first argument to '__builtin_choose_expr' not a constant
    __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
               ^
>> arch/x86/include/asm/uaccess.h:174:11: note: in expansion of macro '__inttype'
     register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX);  \
              ^~~~~~~~~
>> drivers//scsi/sg.c:449:14: note: in expansion of macro 'get_user'
        retval = get_user(req_pack_id,
                 ^~~~~~~~
>> drivers//scsi/sg.c:450:27: error: request for member 'pack_id' in something not a structure or union
          &((sg_io_hdr_t *)buf->pack_id));
                              ^
   arch/x86/include/asm/uaccess.h:180:15: note: in definition of macro 'get_user'
           : "0" (ptr), "i" (sizeof(*(ptr))));  \
                  ^~~
>> drivers//scsi/sg.c:450:27: error: request for member 'pack_id' in something not a structure or union
          &((sg_io_hdr_t *)buf->pack_id));
                              ^
   arch/x86/include/asm/uaccess.h:180:35: note: in definition of macro 'get_user'
           : "0" (ptr), "i" (sizeof(*(ptr))));  \
                                      ^~~
>> drivers//scsi/sg.c:450:27: error: request for member 'pack_id' in something not a structure or union
          &((sg_io_hdr_t *)buf->pack_id));
                              ^
   arch/x86/include/asm/uaccess.h:181:30: note: in definition of macro 'get_user'
     (x) = (__force __typeof__(*(ptr))) __val_gu;   \
                                 ^~~
--
   In file included from include/linux/uaccess.h:14:0,
                    from include/linux/poll.h:12,
                    from drivers/scsi/sg.c:42:
   drivers/scsi/sg.c: In function 'sg_read':
   drivers/scsi/sg.c:450:27: error: request for member 'pack_id' in something not a structure or union
          &((sg_io_hdr_t *)buf->pack_id));
                              ^
   arch/x86/include/asm/uaccess.h:138:41: note: in definition of macro '__inttype'
    __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
                                            ^
   drivers/scsi/sg.c:449:14: note: in expansion of macro 'get_user'
        retval = get_user(req_pack_id,
                 ^~~~~~~~
>> arch/x86/include/asm/uaccess.h:138:12: error: first argument to '__builtin_choose_expr' not a constant
    __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
               ^
>> arch/x86/include/asm/uaccess.h:174:11: note: in expansion of macro '__inttype'
     register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX);  \
              ^~~~~~~~~
   drivers/scsi/sg.c:449:14: note: in expansion of macro 'get_user'
        retval = get_user(req_pack_id,
                 ^~~~~~~~
   drivers/scsi/sg.c:450:27: error: request for member 'pack_id' in something not a structure or union
          &((sg_io_hdr_t *)buf->pack_id));
                              ^
   arch/x86/include/asm/uaccess.h:180:15: note: in definition of macro 'get_user'
           : "0" (ptr), "i" (sizeof(*(ptr))));  \
                  ^~~
   drivers/scsi/sg.c:450:27: error: request for member 'pack_id' in something not a structure or union
          &((sg_io_hdr_t *)buf->pack_id));
                              ^
   arch/x86/include/asm/uaccess.h:180:35: note: in definition of macro 'get_user'
           : "0" (ptr), "i" (sizeof(*(ptr))));  \
                                      ^~~
   drivers/scsi/sg.c:450:27: error: request for member 'pack_id' in something not a structure or union
          &((sg_io_hdr_t *)buf->pack_id));
                              ^
   arch/x86/include/asm/uaccess.h:181:30: note: in definition of macro 'get_user'
     (x) = (__force __typeof__(*(ptr))) __val_gu;   \
                                 ^~~

vim +/pack_id +450 drivers//scsi/sg.c

   412	
   413	static ssize_t
   414	sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
   415	{
   416		Sg_device *sdp;
   417		Sg_fd *sfp;
   418		Sg_request *srp;
   419		int req_pack_id = -1;
   420		sg_io_hdr_t *hp;
   421		struct sg_header *old_hdr = NULL;
   422		int retval = 0;
   423	
   424		/*
   425		 * This could cause a response to be stranded. Close the associated
   426		 * file descriptor to free up any resources being held.
   427		 */
   428		retval = sg_check_file_access(filp, __func__);
   429		if (retval)
   430			return retval;
   431	
   432		if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
   433			return -ENXIO;
   434		SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
   435					      "sg_read: count=%d\n", (int) count));
   436	
   437		if (!access_ok(VERIFY_WRITE, buf, count))
   438			return -EFAULT;
   439		if (sfp->force_packid && (count >= SZ_SG_HEADER)) {
   440			old_hdr = kmalloc(SZ_SG_HEADER, GFP_KERNEL);
   441			if (!old_hdr)
   442				return -ENOMEM;
   443			if (__copy_from_user(old_hdr, buf, SZ_SG_HEADER)) {
   444				retval = -EFAULT;
   445				goto free_old_hdr;
   446			}
   447			if (old_hdr->reply_len < 0) {
   448				if (count >= SZ_SG_IO_HDR) {
 > 449					retval = get_user(req_pack_id,
 > 450							&((sg_io_hdr_t *)buf->pack_id));
   451					if (retval) {
   452						retval = -EFAULT;
   453						goto free_old_hdr;
   454					}
   455				}
   456			} else
   457				req_pack_id = old_hdr->pack_id;
   458		}
   459		srp = sg_get_rq_mark(sfp, req_pack_id);
   460		if (!srp) {		/* now wait on packet to arrive */
   461			if (atomic_read(&sdp->detaching)) {
   462				retval = -ENODEV;
   463				goto free_old_hdr;
   464			}
   465			if (filp->f_flags & O_NONBLOCK) {
   466				retval = -EAGAIN;
   467				goto free_old_hdr;
   468			}
   469			retval = wait_event_interruptible(sfp->read_wait,
   470				(atomic_read(&sdp->detaching) ||
   471				(srp = sg_get_rq_mark(sfp, req_pack_id))));
   472			if (atomic_read(&sdp->detaching)) {
   473				retval = -ENODEV;
   474				goto free_old_hdr;
   475			}
   476			if (retval) {
   477				/* -ERESTARTSYS as signal hit process */
   478				goto free_old_hdr;
   479			}
   480		}
   481		if (srp->header.interface_id != '\0') {
   482			retval = sg_new_read(sfp, buf, count, srp);
   483			goto free_old_hdr;
   484		}
   485	
   486		hp = &srp->header;
   487		if (old_hdr == NULL) {
   488			old_hdr = kmalloc(SZ_SG_HEADER, GFP_KERNEL);
   489			if (! old_hdr) {
   490				retval = -ENOMEM;
   491				goto free_old_hdr;
   492			}
   493		}
   494		memset(old_hdr, 0, SZ_SG_HEADER);
   495		old_hdr->reply_len = (int) hp->timeout;
   496		old_hdr->pack_len = old_hdr->reply_len; /* old, strange behaviour */
   497		old_hdr->pack_id = hp->pack_id;
   498		old_hdr->twelve_byte =
   499		    ((srp->data.cmd_opcode >= 0xc0) && (12 == hp->cmd_len)) ? 1 : 0;
   500		old_hdr->target_status = hp->masked_status;
   501		old_hdr->host_status = hp->host_status;
   502		old_hdr->driver_status = hp->driver_status;
   503		if ((CHECK_CONDITION & hp->masked_status) ||
   504		    (DRIVER_SENSE & hp->driver_status))
   505			memcpy(old_hdr->sense_buffer, srp->sense_b,
   506			       sizeof (old_hdr->sense_buffer));
   507		switch (hp->host_status) {
   508		/* This setup of 'result' is for backward compatibility and is best
   509		   ignored by the user who should use target, host + driver status */
   510		case DID_OK:
   511		case DID_PASSTHROUGH:
   512		case DID_SOFT_ERROR:
   513			old_hdr->result = 0;
   514			break;
   515		case DID_NO_CONNECT:
   516		case DID_BUS_BUSY:
   517		case DID_TIME_OUT:
   518			old_hdr->result = EBUSY;
   519			break;
   520		case DID_BAD_TARGET:
   521		case DID_ABORT:
   522		case DID_PARITY:
   523		case DID_RESET:
   524		case DID_BAD_INTR:
   525			old_hdr->result = EIO;
   526			break;
   527		case DID_ERROR:
   528			old_hdr->result = (srp->sense_b[0] == 0 && 
   529					  hp->masked_status == GOOD) ? 0 : EIO;
   530			break;
   531		default:
   532			old_hdr->result = EIO;
   533			break;
   534		}
   535	
   536		/* Now copy the result back to the user buffer.  */
   537		if (count >= SZ_SG_HEADER) {
   538			if (__copy_to_user(buf, old_hdr, SZ_SG_HEADER)) {
   539				retval = -EFAULT;
   540				goto free_old_hdr;
   541			}
   542			buf += SZ_SG_HEADER;
   543			if (count > old_hdr->reply_len)
   544				count = old_hdr->reply_len;
   545			if (count > SZ_SG_HEADER) {
   546				if (sg_read_oxfer(srp, buf, count - SZ_SG_HEADER)) {
   547					retval = -EFAULT;
   548					goto free_old_hdr;
   549				}
   550			}
   551		} else
   552			count = (old_hdr->result == 0) ? 0 : -EIO;
   553		sg_finish_rem_req(srp);
   554		sg_remove_request(sfp, srp);
   555		retval = count;
   556	free_old_hdr:
   557		kfree(old_hdr);
   558		return retval;
   559	}
   560	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Download attachment ".config.gz" of type "application/gzip" (30978 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ