On Tue, Nov 22, 2022 at 10:17:47AM +0300, Dan Carpenter wrote: > Hi Ming, > > https://git-scm.com/docs/git-format-patch#_base_tree_information] > > url: https://github.com/intel-lab-lkp/linux/commits/Ming-Lei/ublk_drv-add-mechanism-for-supporting-unprivileged-ublk-device/20221116-141131 > patch link: https://lore.kernel.org/r/20221116060835.159945-7-ming.lei%40redhat.com > patch subject: [PATCH 6/6] ublk_drv: add mechanism for supporting unprivileged ublk device > config: x86_64-randconfig-m001-20221121 > compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 > > If you fix the issue, kindly add following tag where applicable > | Reported-by: kernel test robot <lkp@xxxxxxxxx> > | Reported-by: Dan Carpenter <error27@xxxxxxxxx> > > smatch warnings: > drivers/block/ublk_drv.c:2107 ublk_ctrl_uring_cmd_permission() error: uninitialized symbol 'mask'. > > vim +/mask +2107 drivers/block/ublk_drv.c > > a922b5da71a7776 Ming Lei 2022-11-16 2043 static int ublk_ctrl_uring_cmd_permission(struct ublk_device *ub, > a922b5da71a7776 Ming Lei 2022-11-16 2044 struct io_uring_cmd *cmd) > a922b5da71a7776 Ming Lei 2022-11-16 2045 { > a922b5da71a7776 Ming Lei 2022-11-16 2046 struct ublksrv_ctrl_cmd *header = (struct ublksrv_ctrl_cmd *)cmd->cmd; > a922b5da71a7776 Ming Lei 2022-11-16 2047 bool unprivileged = ub->dev_info.flags & UBLK_F_UNPRIVILEGED_DEV; > a922b5da71a7776 Ming Lei 2022-11-16 2048 void __user *argp = (void __user *)(unsigned long)header->addr; > a922b5da71a7776 Ming Lei 2022-11-16 2049 char *dev_path = NULL; > a922b5da71a7776 Ming Lei 2022-11-16 2050 int ret = 0; > a922b5da71a7776 Ming Lei 2022-11-16 2051 int mask; > a922b5da71a7776 Ming Lei 2022-11-16 2052 > a922b5da71a7776 Ming Lei 2022-11-16 2053 if (!unprivileged) { > a922b5da71a7776 Ming Lei 2022-11-16 2054 if (!capable(CAP_SYS_ADMIN)) > a922b5da71a7776 Ming Lei 2022-11-16 2055 return -EPERM; > a922b5da71a7776 Ming Lei 2022-11-16 2056 /* > a922b5da71a7776 Ming Lei 2022-11-16 2057 * The new added command of UBLK_CMD_GET_DEV_INFO2 includes > a922b5da71a7776 Ming Lei 2022-11-16 2058 * char_dev_path in payload too, since userspace may not > a922b5da71a7776 Ming Lei 2022-11-16 2059 * know if the specified device is created as unprivileged > a922b5da71a7776 Ming Lei 2022-11-16 2060 * mode. > a922b5da71a7776 Ming Lei 2022-11-16 2061 */ > a922b5da71a7776 Ming Lei 2022-11-16 2062 if (cmd->cmd_op != UBLK_CMD_GET_DEV_INFO2) > a922b5da71a7776 Ming Lei 2022-11-16 2063 return 0; > a922b5da71a7776 Ming Lei 2022-11-16 2064 } > a922b5da71a7776 Ming Lei 2022-11-16 2065 > a922b5da71a7776 Ming Lei 2022-11-16 2066 /* > a922b5da71a7776 Ming Lei 2022-11-16 2067 * User has to provide the char device path for unprivileged ublk > a922b5da71a7776 Ming Lei 2022-11-16 2068 * > a922b5da71a7776 Ming Lei 2022-11-16 2069 * header->addr always points to the dev path buffer, and > a922b5da71a7776 Ming Lei 2022-11-16 2070 * header->dev_path_len records length of dev path buffer. > a922b5da71a7776 Ming Lei 2022-11-16 2071 */ > a922b5da71a7776 Ming Lei 2022-11-16 2072 if (!header->dev_path_len || header->dev_path_len > PATH_MAX) > a922b5da71a7776 Ming Lei 2022-11-16 2073 return -EINVAL; > a922b5da71a7776 Ming Lei 2022-11-16 2074 > a922b5da71a7776 Ming Lei 2022-11-16 2075 if (header->len < header->dev_path_len) > a922b5da71a7776 Ming Lei 2022-11-16 2076 return -EINVAL; > a922b5da71a7776 Ming Lei 2022-11-16 2077 > a922b5da71a7776 Ming Lei 2022-11-16 2078 dev_path = kmalloc(header->dev_path_len, GFP_KERNEL); > a922b5da71a7776 Ming Lei 2022-11-16 2079 if (!dev_path) > a922b5da71a7776 Ming Lei 2022-11-16 2080 return -ENOMEM; > a922b5da71a7776 Ming Lei 2022-11-16 2081 > a922b5da71a7776 Ming Lei 2022-11-16 2082 ret = -EFAULT; > a922b5da71a7776 Ming Lei 2022-11-16 2083 if (copy_from_user(dev_path, argp, header->dev_path_len)) > a922b5da71a7776 Ming Lei 2022-11-16 2084 goto exit; > a922b5da71a7776 Ming Lei 2022-11-16 2085 dev_path[header->dev_path_len] = 0; > a922b5da71a7776 Ming Lei 2022-11-16 2086 > a922b5da71a7776 Ming Lei 2022-11-16 2087 switch (cmd->cmd_op) { > a922b5da71a7776 Ming Lei 2022-11-16 2088 case UBLK_CMD_GET_DEV_INFO: > a922b5da71a7776 Ming Lei 2022-11-16 2089 case UBLK_CMD_GET_DEV_INFO2: > a922b5da71a7776 Ming Lei 2022-11-16 2090 case UBLK_CMD_GET_QUEUE_AFFINITY: > a922b5da71a7776 Ming Lei 2022-11-16 2091 case UBLK_CMD_GET_PARAMS: > a922b5da71a7776 Ming Lei 2022-11-16 2092 mask = MAY_READ; > a922b5da71a7776 Ming Lei 2022-11-16 2093 break; > a922b5da71a7776 Ming Lei 2022-11-16 2094 case UBLK_CMD_START_DEV: > a922b5da71a7776 Ming Lei 2022-11-16 2095 case UBLK_CMD_STOP_DEV: > a922b5da71a7776 Ming Lei 2022-11-16 2096 case UBLK_CMD_ADD_DEV: > a922b5da71a7776 Ming Lei 2022-11-16 2097 case UBLK_CMD_DEL_DEV: > a922b5da71a7776 Ming Lei 2022-11-16 2098 case UBLK_CMD_SET_PARAMS: > a922b5da71a7776 Ming Lei 2022-11-16 2099 case UBLK_CMD_START_USER_RECOVERY: > a922b5da71a7776 Ming Lei 2022-11-16 2100 case UBLK_CMD_END_USER_RECOVERY: > a922b5da71a7776 Ming Lei 2022-11-16 2101 mask = MAY_READ | MAY_WRITE; > a922b5da71a7776 Ming Lei 2022-11-16 2102 break; > a922b5da71a7776 Ming Lei 2022-11-16 2103 default: > > mask not set on default path. Good catch, and it is really one bug, will fix it in V2. Thanks, Ming