[kbuild] [block:for-5.13/io_uring 143/149] fs/io_uring.c:8234 io_sqe_buffer_register() warn: this array is probably non-NULL. 'imu->bvec'
tree: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-5.13/io_uring head: a2a7cc32a5e8cd983912f25a242820107e5613dc commit: 41edf1a5ec967bf4bddedb83c48e02dfea8315b4 [143/149] io_uring: keep table of pointers to ubufs config: x86_64-randconfig-m031-20210425 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot Reported-by: Dan Carpenter New smatch warnings: fs/io_uring.c:8234 io_sqe_buffer_register() warn: this array is probably non-NULL. 'imu->bvec' Old smatch warnings: fs/io_uring.c:4639 io_recv() error: uninitialized symbol 'flags'. fs/io_uring.c:4934 io_poll_double_wake() warn: variable dereferenced before check 'poll' (see line 4929) vim +8234 fs/io_uring.c 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8205 static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov, 41edf1a5ec967b Pavel Begunkov2021-04-25 8206 struct io_mapped_ubuf **pimu, 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8207 struct page **last_hpage) edafccee56ff31 Jens Axboe2019-01-09 8208 { 41edf1a5ec967b Pavel Begunkov2021-04-25 8209 struct io_mapped_ubuf *imu = NULL; edafccee56ff31 Jens Axboe2019-01-09 8210 struct vm_area_struct **vmas = NULL; edafccee56ff31 Jens Axboe2019-01-09 8211 struct page **pages = NULL; edafccee56ff31 Jens Axboe2019-01-09 8212 unsigned long off, start, end, ubuf; edafccee56ff31 Jens Axboe2019-01-09 8213 size_t size; 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8214 int ret, pret, nr_pages, i; edafccee56ff31 Jens Axboe2019-01-09 8215 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8216 ubuf = (unsigned long) iov->iov_base; 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8217 end = (ubuf + iov->iov_len + PAGE_SIZE - 1) >> PAGE_SHIFT; edafccee56ff31 Jens Axboe2019-01-09 8218 start = ubuf >> PAGE_SHIFT; edafccee56ff31 Jens Axboe2019-01-09 8219 nr_pages = end - start; edafccee56ff31 Jens Axboe2019-01-09 8220 41edf1a5ec967b Pavel Begunkov2021-04-25 8221 *pimu = NULL; edafccee56ff31 Jens Axboe2019-01-09 8222 ret = -ENOMEM; 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8223 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8224 pages = kvmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL); 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8225 if (!pages) 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8226 goto done; 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8227 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8228 vmas = kvmalloc_array(nr_pages, sizeof(struct vm_area_struct *), 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8229 GFP_KERNEL); 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8230 if (!vmas) 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8231 goto done; edafccee56ff31 Jens Axboe2019-01-09 8232 41edf1a5ec967b Pavel Begunkov2021-04-25 8233 imu = kvmalloc(struct_size(imu, bvec, nr_pages), GFP_KERNEL); de2939388be564 Jens Axboe2020-09-17 @8234 if (!imu->bvec) This should be "if (!imu)" 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8235 goto done; edafccee56ff31 Jens Axboe2019-01-09 8236 edafccee56ff31 Jens Axboe2019-01-09 8237 ret = 0; d8ed45c5dcd455 Michel Lespinasse 2020-06-08 8238 mmap_read_lock(current->mm); 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8239 pret = pin_user_pages(ubuf, nr_pages, FOLL_WRITE | FOLL_LONGTERM, edafccee56ff31 Jens Axboe2019-01-09 8240 pages, vmas); edafccee56ff31 Jens Axboe2019-01-09 8241 if (pret == nr_pages) { edafccee56ff31 Jens Axboe2019-01-09 8242 /* don't support file backed memory */ 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8243 for (i = 0; i < nr_pages; i++) { 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8244 struct vm_area_struct *vma = vmas[i]; edafccee56ff31 Jens Axboe2019-01-09 8245 edafccee56ff31 Jens Axboe2019-01-09 8246 if (vma->vm_file && edafccee56ff31 Jens Axboe2019-01-09 8247 !is_file_hugepages(vma->vm_file)) { edafccee56ff31 Jens Axboe2019-01-09 8248 ret = -EOPNOTSUPP; edafccee56ff31 Jens Axboe2019-01-09 8249 break; edafccee56ff31 Jens Axboe2019-01-09 8250 } edafccee56ff31 Jens Axboe2019-01-09 8251 } edafccee56ff31 Jens Axboe2019-01-09 8252 } else { edafccee56ff31 Jens Axboe2019-01-09 8253 ret = pret < 0 ? pret : -EFAULT;
[kbuild] [block:for-5.13/io_uring 143/149] fs/io_uring.c:8234 io_sqe_buffer_register() warn: this array is probably non-NULL. 'imu->bvec'
CC: kbuild-...@lists.01.org TO: Pavel Begunkov CC: Jens Axboe tree: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-5.13/io_uring head: a2a7cc32a5e8cd983912f25a242820107e5613dc commit: 41edf1a5ec967bf4bddedb83c48e02dfea8315b4 [143/149] io_uring: keep table of pointers to ubufs :: branch date: 6 hours ago :: commit date: 6 hours ago config: x86_64-randconfig-m031-20210425 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot Reported-by: Dan Carpenter New smatch warnings: fs/io_uring.c:8234 io_sqe_buffer_register() warn: this array is probably non-NULL. 'imu->bvec' Old smatch warnings: fs/io_uring.c:4639 io_recv() error: uninitialized symbol 'flags'. fs/io_uring.c:4934 io_poll_double_wake() warn: variable dereferenced before check 'poll' (see line 4929) vim +8234 fs/io_uring.c edafccee56ff31 Jens Axboe2019-01-09 8204 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8205 static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov, 41edf1a5ec967b Pavel Begunkov2021-04-25 8206 struct io_mapped_ubuf **pimu, 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8207 struct page **last_hpage) edafccee56ff31 Jens Axboe2019-01-09 8208 { 41edf1a5ec967b Pavel Begunkov2021-04-25 8209 struct io_mapped_ubuf *imu = NULL; edafccee56ff31 Jens Axboe2019-01-09 8210 struct vm_area_struct **vmas = NULL; edafccee56ff31 Jens Axboe2019-01-09 8211 struct page **pages = NULL; edafccee56ff31 Jens Axboe2019-01-09 8212 unsigned long off, start, end, ubuf; edafccee56ff31 Jens Axboe2019-01-09 8213 size_t size; 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8214 int ret, pret, nr_pages, i; edafccee56ff31 Jens Axboe2019-01-09 8215 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8216 ubuf = (unsigned long) iov->iov_base; 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8217 end = (ubuf + iov->iov_len + PAGE_SIZE - 1) >> PAGE_SHIFT; edafccee56ff31 Jens Axboe2019-01-09 8218 start = ubuf >> PAGE_SHIFT; edafccee56ff31 Jens Axboe2019-01-09 8219 nr_pages = end - start; edafccee56ff31 Jens Axboe2019-01-09 8220 41edf1a5ec967b Pavel Begunkov2021-04-25 8221 *pimu = NULL; edafccee56ff31 Jens Axboe2019-01-09 8222 ret = -ENOMEM; 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8223 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8224 pages = kvmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL); 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8225 if (!pages) 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8226 goto done; 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8227 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8228 vmas = kvmalloc_array(nr_pages, sizeof(struct vm_area_struct *), 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8229 GFP_KERNEL); 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8230 if (!vmas) 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8231 goto done; edafccee56ff31 Jens Axboe2019-01-09 8232 41edf1a5ec967b Pavel Begunkov2021-04-25 8233 imu = kvmalloc(struct_size(imu, bvec, nr_pages), GFP_KERNEL); de2939388be564 Jens Axboe2020-09-17 @8234 if (!imu->bvec) 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8235 goto done; edafccee56ff31 Jens Axboe2019-01-09 8236 edafccee56ff31 Jens Axboe2019-01-09 8237 ret = 0; d8ed45c5dcd455 Michel Lespinasse 2020-06-08 8238 mmap_read_lock(current->mm); 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8239 pret = pin_user_pages(ubuf, nr_pages, FOLL_WRITE | FOLL_LONGTERM, edafccee56ff31 Jens Axboe2019-01-09 8240 pages, vmas); edafccee56ff31 Jens Axboe2019-01-09 8241 if (pret == nr_pages) { edafccee56ff31 Jens Axboe2019-01-09 8242 /* don't support file backed memory */ 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8243 for (i = 0; i < nr_pages; i++) { 0a96bbe49994a4 Bijan Mottahedeh 2021-01-06 8244 struct vm_area_struct *vma = vmas[i]; edafccee56ff31 Jens Axboe2019-01-09 8245 edafccee56ff31 Jens Axboe2019-01-09 8246 if (vma->vm_file && edafccee56ff31 Jens Axboe2019-01-09 8247 !is_file_hugepages(vma->vm_file)) { edafccee56ff31 Jens Axboe2019-01-09 8248 ret = -EOPNOTSUPP; edafccee56ff31 Jens Axboe2019-01-09 8249 break; edafccee56ff31 Jens Axboe2019-01-09 8250 } edafccee56ff31 Jens Axboe2019-01-09 8251 } edafccee56ff31