[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202108061705.Uyfk6x5a-lkp@intel.com>
Date: Fri, 6 Aug 2021 17:12:13 +0800
From: kernel test robot <lkp@...el.com>
To: Christoph Hellwig <hch@....de>
Cc: kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
"Martin K. Petersen" <martin.petersen@...cle.com>
Subject: [mkp-scsi:for-next 85/148] drivers/scsi/scsi_ioctl.c:206:28: sparse:
sparse: incorrect type in initializer (different address spaces)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
head: f5efd4fe78de871515444b660029074be17ec11f
commit: f2542a3be3277a65c766fa6e86b930d3d839f79e [85/148] scsi: scsi_ioctl: Move the "block layer" SCSI ioctl handling to drivers/scsi
config: sh-randconfig-s032-20210728 (attached as .config)
compiler: sh4-linux-gcc (GCC) 10.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-348-gf0e6938b-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git/commit/?id=f2542a3be3277a65c766fa6e86b930d3d839f79e
git remote add mkp-scsi https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
git fetch --no-tags mkp-scsi for-next
git checkout f2542a3be3277a65c766fa6e86b930d3d839f79e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sh
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
sparse warnings: (new ones prefixed by >>)
drivers/scsi/scsi_ioctl.c:49:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned int const *__gu_addr @@ got unsigned int [noderef] __user * @@
drivers/scsi/scsi_ioctl.c:49:21: sparse: expected unsigned int const *__gu_addr
drivers/scsi/scsi_ioctl.c:49:21: sparse: got unsigned int [noderef] __user *
drivers/scsi/scsi_ioctl.c:49:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned int const *__gu_addr @@
drivers/scsi/scsi_ioctl.c:49:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/scsi/scsi_ioctl.c:49:21: sparse: got unsigned int const *__gu_addr
>> drivers/scsi/scsi_ioctl.c:206:28: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *p @@
drivers/scsi/scsi_ioctl.c:206:28: sparse: expected int const *__gu_addr
drivers/scsi/scsi_ioctl.c:206:28: sparse: got int [noderef] __user *p
>> drivers/scsi/scsi_ioctl.c:206:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/scsi/scsi_ioctl.c:206:28: sparse: expected void const volatile [noderef] __user *ptr
drivers/scsi/scsi_ioctl.c:206:28: sparse: got int const *__gu_addr
drivers/scsi/scsi_ioctl.c:223:25: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *p @@
drivers/scsi/scsi_ioctl.c:223:25: sparse: expected int const *__gu_addr
drivers/scsi/scsi_ioctl.c:223:25: sparse: got int [noderef] __user *p
drivers/scsi/scsi_ioctl.c:223:25: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/scsi/scsi_ioctl.c:223:25: sparse: expected void const volatile [noderef] __user *ptr
drivers/scsi/scsi_ioctl.c:223:25: sparse: got int const *__gu_addr
drivers/scsi/scsi_ioctl.c:575:13: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned int const *__gu_addr @@ got unsigned int [noderef] __user * @@
drivers/scsi/scsi_ioctl.c:575:13: sparse: expected unsigned int const *__gu_addr
drivers/scsi/scsi_ioctl.c:575:13: sparse: got unsigned int [noderef] __user *
drivers/scsi/scsi_ioctl.c:575:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned int const *__gu_addr @@
drivers/scsi/scsi_ioctl.c:575:13: sparse: expected void const volatile [noderef] __user *ptr
drivers/scsi/scsi_ioctl.c:575:13: sparse: got unsigned int const *__gu_addr
drivers/scsi/scsi_ioctl.c:577:13: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned int const *__gu_addr @@ got unsigned int [noderef] __user * @@
drivers/scsi/scsi_ioctl.c:577:13: sparse: expected unsigned int const *__gu_addr
drivers/scsi/scsi_ioctl.c:577:13: sparse: got unsigned int [noderef] __user *
drivers/scsi/scsi_ioctl.c:577:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned int const *__gu_addr @@
drivers/scsi/scsi_ioctl.c:577:13: sparse: expected void const volatile [noderef] __user *ptr
drivers/scsi/scsi_ioctl.c:577:13: sparse: got unsigned int const *__gu_addr
>> drivers/scsi/scsi_ioctl.c:581:13: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char const *__gu_addr @@ got unsigned char [noderef] __user * @@
drivers/scsi/scsi_ioctl.c:581:13: sparse: expected unsigned char const *__gu_addr
drivers/scsi/scsi_ioctl.c:581:13: sparse: got unsigned char [noderef] __user *
>> drivers/scsi/scsi_ioctl.c:581:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned char const *__gu_addr @@
drivers/scsi/scsi_ioctl.c:581:13: sparse: expected void const volatile [noderef] __user *ptr
drivers/scsi/scsi_ioctl.c:581:13: sparse: got unsigned char const *__gu_addr
vim +206 drivers/scsi/scsi_ioctl.c
34
35 /**
36 * ioctl_probe -- return host identification
37 * @host: host to identify
38 * @buffer: userspace buffer for identification
39 *
40 * Return an identifying string at @buffer, if @buffer is non-NULL, filling
41 * to the length stored at * (int *) @buffer.
42 */
43 static int ioctl_probe(struct Scsi_Host *host, void __user *buffer)
44 {
45 unsigned int len, slen;
46 const char *string;
47
48 if (buffer) {
> 49 if (get_user(len, (unsigned int __user *) buffer))
50 return -EFAULT;
51
52 if (host->hostt->info)
53 string = host->hostt->info(host);
54 else
55 string = host->hostt->name;
56 if (string) {
57 slen = strlen(string);
58 if (len > slen)
59 len = slen + 1;
60 if (copy_to_user(buffer, string, len))
61 return -EFAULT;
62 }
63 }
64 return 1;
65 }
66
67 /*
68
69 * The SCSI_IOCTL_SEND_COMMAND ioctl sends a command out to the SCSI host.
70 * The IOCTL_NORMAL_TIMEOUT and NORMAL_RETRIES variables are used.
71 *
72 * dev is the SCSI device struct ptr, *(int *) arg is the length of the
73 * input data, if any, not including the command string & counts,
74 * *((int *)arg + 1) is the output buffer size in bytes.
75 *
76 * *(char *) ((int *) arg)[2] the actual command byte.
77 *
78 * Note that if more than MAX_BUF bytes are requested to be transferred,
79 * the ioctl will fail with error EINVAL.
80 *
81 * This size *does not* include the initial lengths that were passed.
82 *
83 * The SCSI command is read from the memory location immediately after the
84 * length words, and the input data is right after the command. The SCSI
85 * routines know the command size based on the opcode decode.
86 *
87 * The output area is then filled in starting from the command byte.
88 */
89
90 static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
91 int timeout, int retries)
92 {
93 int result;
94 struct scsi_sense_hdr sshdr;
95
96 SCSI_LOG_IOCTL(1, sdev_printk(KERN_INFO, sdev,
97 "Trying ioctl with scsi command %d\n", *cmd));
98
99 result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
100 &sshdr, timeout, retries, NULL);
101
102 SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
103 "Ioctl returned 0x%x\n", result));
104
105 if (result < 0)
106 goto out;
107 if (scsi_sense_valid(&sshdr)) {
108 switch (sshdr.sense_key) {
109 case ILLEGAL_REQUEST:
110 if (cmd[0] == ALLOW_MEDIUM_REMOVAL)
111 sdev->lockable = 0;
112 else
113 sdev_printk(KERN_INFO, sdev,
114 "ioctl_internal_command: "
115 "ILLEGAL REQUEST "
116 "asc=0x%x ascq=0x%x\n",
117 sshdr.asc, sshdr.ascq);
118 break;
119 case NOT_READY: /* This happens if there is no disc in drive */
120 if (sdev->removable)
121 break;
122 fallthrough;
123 case UNIT_ATTENTION:
124 if (sdev->removable) {
125 sdev->changed = 1;
126 result = 0; /* This is no longer considered an error */
127 break;
128 }
129 fallthrough; /* for non-removable media */
130 default:
131 sdev_printk(KERN_INFO, sdev,
132 "ioctl_internal_command return code = %x\n",
133 result);
134 scsi_print_sense_hdr(sdev, NULL, &sshdr);
135 break;
136 }
137 }
138 out:
139 SCSI_LOG_IOCTL(2, sdev_printk(KERN_INFO, sdev,
140 "IOCTL Releasing command\n"));
141 return result;
142 }
143
144 int scsi_set_medium_removal(struct scsi_device *sdev, char state)
145 {
146 char scsi_cmd[MAX_COMMAND_SIZE];
147 int ret;
148
149 if (!sdev->removable || !sdev->lockable)
150 return 0;
151
152 scsi_cmd[0] = ALLOW_MEDIUM_REMOVAL;
153 scsi_cmd[1] = 0;
154 scsi_cmd[2] = 0;
155 scsi_cmd[3] = 0;
156 scsi_cmd[4] = state;
157 scsi_cmd[5] = 0;
158
159 ret = ioctl_internal_command(sdev, scsi_cmd,
160 IOCTL_NORMAL_TIMEOUT, NORMAL_RETRIES);
161 if (ret == 0)
162 sdev->locked = (state == SCSI_REMOVAL_PREVENT);
163 return ret;
164 }
165 EXPORT_SYMBOL(scsi_set_medium_removal);
166
167 /*
168 * The scsi_ioctl_get_pci() function places into arg the value
169 * pci_dev::slot_name (8 characters) for the PCI device (if any).
170 * Returns: 0 on success
171 * -ENXIO if there isn't a PCI device pointer
172 * (could be because the SCSI driver hasn't been
173 * updated yet, or because it isn't a SCSI
174 * device)
175 * any copy_to_user() error on failure there
176 */
177 static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg)
178 {
179 struct device *dev = scsi_get_device(sdev->host);
180 const char *name;
181
182 if (!dev)
183 return -ENXIO;
184
185 name = dev_name(dev);
186
187 /* compatibility with old ioctl which only returned
188 * 20 characters */
189 return copy_to_user(arg, name, min(strlen(name), (size_t)20))
190 ? -EFAULT: 0;
191 }
192
193 static int sg_get_version(int __user *p)
194 {
195 static const int sg_version_num = 30527;
196 return put_user(sg_version_num, p);
197 }
198
199 static int sg_get_timeout(struct request_queue *q)
200 {
201 return jiffies_to_clock_t(q->sg_timeout);
202 }
203
204 static int sg_set_timeout(struct request_queue *q, int __user *p)
205 {
> 206 int timeout, err = get_user(timeout, p);
207
208 if (!err)
209 q->sg_timeout = clock_t_to_jiffies(timeout);
210
211 return err;
212 }
213
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (21492 bytes)
Powered by blists - more mailing lists