All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Douglas Gilbert <dgilbert@interlog.com>, linux-scsi@vger.kernel.org
Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org,
	martin.petersen@oracle.com, jejb@linux.vnet.ibm.com,
	hare@suse.de, bvanassche@acm.org, hch@lst.de
Subject: Re: [PATCH 1/6] scsi_cmnd: reinstate support for cmd_len > 32
Date: Fri, 8 Apr 2022 15:59:52 +0800	[thread overview]
Message-ID: <202204081548.EhdacQg9-lkp@intel.com> (raw)
In-Reply-To: <20220408035651.6472-2-dgilbert@interlog.com>

Hi Douglas,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on jejb-scsi/for-next]
[also build test WARNING on mkp-scsi/for-next v5.18-rc1 next-20220407]
[cannot apply to hch-configfs/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/intel-lab-lkp/linux/commits/Douglas-Gilbert/scsi-fix-scsi_cmd-cmd_len/20220408-121036
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: hexagon-randconfig-r041-20220408 (https://download.01.org/0day-ci/archive/20220408/202204081548.EhdacQg9-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c29a51b3a257908aebc01cd7c4655665db317d66)
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://github.com/intel-lab-lkp/linux/commit/efdf7335424993375502b298131c1d106fc5e6d4
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Douglas-Gilbert/scsi-fix-scsi_cmd-cmd_len/20220408-121036
        git checkout efdf7335424993375502b298131c1d106fc5e6d4
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/scsi/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/scsi/scsi_ioctl.c:444:28: warning: result of comparison of constant 260 with expression of type 'unsigned char' is always false [-Wtautological-constant-out-of-range-compare]
           if (unlikely(hdr->cmd_len > SCSI_MAX_RUN_TIME_CDB_LEN)) {
                        ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:48:41: note: expanded from macro 'unlikely'
   #  define unlikely(x)   (__branch_check__(x, 0, __builtin_constant_p(x)))
                                             ^
   include/linux/compiler.h:33:34: note: expanded from macro '__branch_check__'
                           ______r = __builtin_expect(!!(x), expect);      \
                                                         ^
>> drivers/scsi/scsi_ioctl.c:444:28: warning: result of comparison of constant 260 with expression of type 'unsigned char' is always false [-Wtautological-constant-out-of-range-compare]
           if (unlikely(hdr->cmd_len > SCSI_MAX_RUN_TIME_CDB_LEN)) {
                        ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:48:68: note: expanded from macro 'unlikely'
   #  define unlikely(x)   (__branch_check__(x, 0, __builtin_constant_p(x)))
                                                                        ^
   include/linux/compiler.h:35:19: note: expanded from macro '__branch_check__'
                                                expect, is_constant);      \
                                                        ^~~~~~~~~~~
   2 warnings generated.


vim +444 drivers/scsi/scsi_ioctl.c

   407	
   408	static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode)
   409	{
   410		unsigned long start_time;
   411		ssize_t ret = 0;
   412		int writing = 0;
   413		int at_head = 0;
   414		struct request *rq;
   415		struct scsi_cmnd *scmd;
   416		struct bio *bio;
   417	
   418		if (hdr->interface_id != 'S')
   419			return -EINVAL;
   420	
   421		if (hdr->dxfer_len > (queue_max_hw_sectors(sdev->request_queue) << 9))
   422			return -EIO;
   423	
   424		if (hdr->dxfer_len)
   425			switch (hdr->dxfer_direction) {
   426			default:
   427				return -EINVAL;
   428			case SG_DXFER_TO_DEV:
   429				writing = 1;
   430				break;
   431			case SG_DXFER_TO_FROM_DEV:
   432			case SG_DXFER_FROM_DEV:
   433				break;
   434			}
   435		if (hdr->flags & SG_FLAG_Q_AT_HEAD)
   436			at_head = 1;
   437	
   438		rq = scsi_alloc_request(sdev->request_queue, writing ?
   439				     REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0);
   440		if (IS_ERR(rq))
   441			return PTR_ERR(rq);
   442		scmd = blk_mq_rq_to_pdu(rq);
   443	
 > 444		if (unlikely(hdr->cmd_len > SCSI_MAX_RUN_TIME_CDB_LEN)) {
   445			ret = -EINVAL;
   446			goto out_put_request;
   447		}
   448	
   449		ret = scsi_fill_sghdr_rq(sdev, rq, hdr, mode);
   450		if (ret < 0)
   451			goto out_put_request;
   452	
   453		ret = 0;
   454		if (hdr->iovec_count) {
   455			struct iov_iter i;
   456			struct iovec *iov = NULL;
   457	
   458			ret = import_iovec(rq_data_dir(rq), hdr->dxferp,
   459					   hdr->iovec_count, 0, &iov, &i);
   460			if (ret < 0)
   461				goto out_put_request;
   462	
   463			/* SG_IO howto says that the shorter of the two wins */
   464			iov_iter_truncate(&i, hdr->dxfer_len);
   465	
   466			ret = blk_rq_map_user_iov(rq->q, rq, NULL, &i, GFP_KERNEL);
   467			kfree(iov);
   468		} else if (hdr->dxfer_len)
   469			ret = blk_rq_map_user(rq->q, rq, NULL, hdr->dxferp,
   470					      hdr->dxfer_len, GFP_KERNEL);
   471	
   472		if (ret)
   473			goto out_put_request;
   474	
   475		bio = rq->bio;
   476		scmd->allowed = 0;
   477	
   478		start_time = jiffies;
   479	
   480		blk_execute_rq(rq, at_head);
   481	
   482		hdr->duration = jiffies_to_msecs(jiffies - start_time);
   483	
   484		ret = scsi_complete_sghdr_rq(rq, hdr, bio);
   485	
   486	out_put_request:
   487		scsi_free_cmnd(scmd);
   488		return ret;
   489	}
   490	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

  parent reply	other threads:[~2022-04-08  8:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08  3:56 [PATCH 0/6] scsi: fix scsi_cmd::cmd_len Douglas Gilbert
2022-04-08  3:56 ` [PATCH 1/6] scsi_cmnd: reinstate support for cmd_len > 32 Douglas Gilbert
2022-04-08  5:16   ` Christoph Hellwig
2022-04-08  7:59   ` kernel test robot [this message]
2022-04-08 14:55   ` Bart Van Assche
2022-04-09  4:42     ` Douglas Gilbert
2022-04-09 21:38       ` Bart Van Assche
2022-04-08  3:56 ` [PATCH 2/6] sd, sd_zbc: use scsi_cmnd cdb access functions Douglas Gilbert
2022-04-08  3:56 ` [PATCH 3/6] sg: reinstate cmd_len > 32 Douglas Gilbert
2022-04-08  3:56 ` [PATCH 4/6] bsg: allow " Douglas Gilbert
2022-04-08  3:56 ` [PATCH 5/6] scsi_debug: reinstate " Douglas Gilbert
2022-04-08  3:56 ` [PATCH 6/6] st,sr: use scsi_cmnd cdb access functions and dtor Douglas Gilbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202204081548.EhdacQg9-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=bvanassche@acm.org \
    --cc=dgilbert@interlog.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.