Re: [PATCH] aio: convert active_reqs into a hashtable

From: kernel test robot
Date: Sun Sep 19 2021 - 05:48:41 EST


Hi Hamza,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on linux/master v5.15-rc1 next-20210916]
[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/0day-ci/linux/commits/Hamza-Mahfooz/aio-convert-active_reqs-into-a-hashtable/20210914-174924
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git d0ee23f9d78be5531c4b055ea424ed0b489dfe9b
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: arm-randconfig-c002-20210916 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 8cbbd7e0b2aa21ce7e416cfb63d9965518948c35)
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 arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/0day-ci/linux/commit/ab7dca103bc74aed4baada06420395f4bead4e6c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Hamza-Mahfooz/aio-convert-active_reqs-into-a-hashtable/20210914-174924
git checkout ab7dca103bc74aed4baada06420395f4bead4e6c
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer

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


clang-analyzer warnings: (new ones prefixed by >>)

>> fs/aio.c:2042:36: warning: Dereference of undefined pointer value [clang-analyzer-core.NullDereference]
list = &ctx->active_reqs[hash_min(kiocb->ki_res.obj, ctx->hash_bits)];
^

vim +2042 fs/aio.c

c00d2c7e898800 Al Viro 2016-12-20 2009
^1da177e4c3f41 Linus Torvalds 2005-04-16 2010 /* sys_io_cancel:
^1da177e4c3f41 Linus Torvalds 2005-04-16 2011 * Attempts to cancel an iocb previously passed to io_submit. If
^1da177e4c3f41 Linus Torvalds 2005-04-16 2012 * the operation is successfully cancelled, the resulting event is
^1da177e4c3f41 Linus Torvalds 2005-04-16 2013 * copied into the memory pointed to by result without being placed
^1da177e4c3f41 Linus Torvalds 2005-04-16 2014 * into the completion queue and 0 is returned. May fail with
^1da177e4c3f41 Linus Torvalds 2005-04-16 2015 * -EFAULT if any of the data structures pointed to are invalid.
^1da177e4c3f41 Linus Torvalds 2005-04-16 2016 * May fail with -EINVAL if aio_context specified by ctx_id is
^1da177e4c3f41 Linus Torvalds 2005-04-16 2017 * invalid. May fail with -EAGAIN if the iocb specified was not
^1da177e4c3f41 Linus Torvalds 2005-04-16 2018 * cancelled. Will fail with -ENOSYS if not implemented.
^1da177e4c3f41 Linus Torvalds 2005-04-16 2019 */
002c8976ee5377 Heiko Carstens 2009-01-14 2020 SYSCALL_DEFINE3(io_cancel, aio_context_t, ctx_id, struct iocb __user *, iocb,
002c8976ee5377 Heiko Carstens 2009-01-14 2021 struct io_event __user *, result)
^1da177e4c3f41 Linus Torvalds 2005-04-16 2022 {
^1da177e4c3f41 Linus Torvalds 2005-04-16 2023 struct kioctx *ctx;
04b2fa9f8f36ec Christoph Hellwig 2015-02-02 2024 struct aio_kiocb *kiocb;
888933f8fdf06e Christoph Hellwig 2018-05-23 2025 int ret = -EINVAL;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2026 u32 key;
ab7dca103bc74a Hamza Mahfooz 2021-09-14 2027 struct hlist_head *list;
ab7dca103bc74a Hamza Mahfooz 2021-09-14 2028 struct hlist_node *node;
a9339b7855094b Al Viro 2019-03-07 2029 u64 obj = (u64)(unsigned long)iocb;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2030
f3a2752a43de18 Christoph Hellwig 2018-03-30 2031 if (unlikely(get_user(key, &iocb->aio_key)))
^1da177e4c3f41 Linus Torvalds 2005-04-16 2032 return -EFAULT;
f3a2752a43de18 Christoph Hellwig 2018-03-30 2033 if (unlikely(key != KIOCB_KEY))
f3a2752a43de18 Christoph Hellwig 2018-03-30 2034 return -EINVAL;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2035
^1da177e4c3f41 Linus Torvalds 2005-04-16 2036 ctx = lookup_ioctx(ctx_id);
^1da177e4c3f41 Linus Torvalds 2005-04-16 2037 if (unlikely(!ctx))
^1da177e4c3f41 Linus Torvalds 2005-04-16 2038 return -EINVAL;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2039
^1da177e4c3f41 Linus Torvalds 2005-04-16 2040 spin_lock_irq(&ctx->ctx_lock);
ab7dca103bc74a Hamza Mahfooz 2021-09-14 2041
ab7dca103bc74a Hamza Mahfooz 2021-09-14 @2042 list = &ctx->active_reqs[hash_min(kiocb->ki_res.obj, ctx->hash_bits)];
ab7dca103bc74a Hamza Mahfooz 2021-09-14 2043
ab7dca103bc74a Hamza Mahfooz 2021-09-14 2044 hlist_for_each_entry_safe(kiocb, node, list, ki_node) {
a9339b7855094b Al Viro 2019-03-07 2045 if (kiocb->ki_res.obj == obj) {
888933f8fdf06e Christoph Hellwig 2018-05-23 2046 ret = kiocb->ki_cancel(&kiocb->rw);
ab7dca103bc74a Hamza Mahfooz 2021-09-14 2047 hash_del(&kiocb->ki_node);
833f4154ed5602 Al Viro 2019-03-11 2048 break;
833f4154ed5602 Al Viro 2019-03-11 2049 }
888933f8fdf06e Christoph Hellwig 2018-05-23 2050 }
ab7dca103bc74a Hamza Mahfooz 2021-09-14 2051
^1da177e4c3f41 Linus Torvalds 2005-04-16 2052 spin_unlock_irq(&ctx->ctx_lock);
^1da177e4c3f41 Linus Torvalds 2005-04-16 2053
^1da177e4c3f41 Linus Torvalds 2005-04-16 2054 if (!ret) {
bec68faaf3ba74 Kent Overstreet 2013-05-13 2055 /*
bec68faaf3ba74 Kent Overstreet 2013-05-13 2056 * The result argument is no longer used - the io_event is
bec68faaf3ba74 Kent Overstreet 2013-05-13 2057 * always delivered via the ring buffer. -EINPROGRESS indicates
bec68faaf3ba74 Kent Overstreet 2013-05-13 2058 * cancellation is progress:
^1da177e4c3f41 Linus Torvalds 2005-04-16 2059 */
bec68faaf3ba74 Kent Overstreet 2013-05-13 2060 ret = -EINPROGRESS;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2061 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 2062
723be6e39d1425 Kent Overstreet 2013-05-28 2063 percpu_ref_put(&ctx->users);
^1da177e4c3f41 Linus Torvalds 2005-04-16 2064
^1da177e4c3f41 Linus Torvalds 2005-04-16 2065 return ret;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2066 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 2067

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip