io_uring/zcrx.c:223 io_register_zcrx_ifq() warn: missing unwind goto?
PATCH 3999/4377 io_uring/zcrx.c:223 io_register_zcrx_ifq() warn: missing unwind goto?
Hi Pavel,
FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: e5d3fd687aac5eceb1721fa92b9f49afcf4c3717 commit: 035af94b39fd13751abf5f0a2948c9eddede55d0 [3999/4377] io_uring/zcrx: grab a net device config: i386-randconfig-141-20250218 (https://download.01.org/0day-ci/archive/20250219/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:io_uring/zcrx.c:223 io_register_zcrx_ifq() warn: missing unwind goto?
vim +223 io_uring/zcrx.c
6f377873cb2390 David Wei 2025-02-14 160 int io_register_zcrx_ifq(struct io_ring_ctx *ctx,
6f377873cb2390 David Wei 2025-02-14 161 struct io_uring_zcrx_ifq_reg __user *arg)
6f377873cb2390 David Wei 2025-02-14 162 {
cf96310c5f9a0d David Wei 2025-02-14 163 struct io_uring_zcrx_area_reg area;
6f377873cb2390 David Wei 2025-02-14 164 struct io_uring_zcrx_ifq_reg reg;
6f377873cb2390 David Wei 2025-02-14 165 struct io_uring_region_desc rd;
6f377873cb2390 David Wei 2025-02-14 166 struct io_zcrx_ifq *ifq;
6f377873cb2390 David Wei 2025-02-14 167 int ret;
6f377873cb2390 David Wei 2025-02-14 168
6f377873cb2390 David Wei 2025-02-14 169 /*
6f377873cb2390 David Wei 2025-02-14 170 * 1. Interface queue allocation.
6f377873cb2390 David Wei 2025-02-14 171 * 2. It can observe data destined for sockets of other tasks.
6f377873cb2390 David Wei 2025-02-14 172 */
6f377873cb2390 David Wei 2025-02-14 173 if (!capable(CAP_NET_ADMIN))
6f377873cb2390 David Wei 2025-02-14 174 return -EPERM;
6f377873cb2390 David Wei 2025-02-14 175
6f377873cb2390 David Wei 2025-02-14 176 /* mandatory io_uring features for zc rx */
6f377873cb2390 David Wei 2025-02-14 177 if (!(ctx->flags & IORING_SETUP_DEFER_TASKRUN &&
6f377873cb2390 David Wei 2025-02-14 178 ctx->flags & IORING_SETUP_CQE32))
6f377873cb2390 David Wei 2025-02-14 179 return -EINVAL;
6f377873cb2390 David Wei 2025-02-14 180 if (ctx->ifq)
6f377873cb2390 David Wei 2025-02-14 181 return -EBUSY;
6f377873cb2390 David Wei 2025-02-14 182 if (copy_from_user(®, arg, sizeof(reg)))
6f377873cb2390 David Wei 2025-02-14 183 return -EFAULT;
6f377873cb2390 David Wei 2025-02-14 184 if (copy_from_user(&rd, u64_to_user_ptr(reg.region_ptr), sizeof(rd)))
6f377873cb2390 David Wei 2025-02-14 185 return -EFAULT;
6f377873cb2390 David Wei 2025-02-14 186 if (memchr_inv(®.__resv, 0, sizeof(reg.__resv)))
6f377873cb2390 David Wei 2025-02-14 187 return -EINVAL;
6f377873cb2390 David Wei 2025-02-14 188 if (reg.if_rxq == -1 || !reg.rq_entries || reg.flags)
6f377873cb2390 David Wei 2025-02-14 189 return -EINVAL;
6f377873cb2390 David Wei 2025-02-14 190 if (reg.rq_entries > IO_RQ_MAX_ENTRIES) {
6f377873cb2390 David Wei 2025-02-14 191 if (!(ctx->flags & IORING_SETUP_CLAMP))
6f377873cb2390 David Wei 2025-02-14 192 return -EINVAL;
6f377873cb2390 David Wei 2025-02-14 193 reg.rq_entries = IO_RQ_MAX_ENTRIES;
6f377873cb2390 David Wei 2025-02-14 194 }
6f377873cb2390 David Wei 2025-02-14 195 reg.rq_entries = roundup_pow_of_two(reg.rq_entries);
6f377873cb2390 David Wei 2025-02-14 196
cf96310c5f9a0d David Wei 2025-02-14 197 if (copy_from_user(&area, u64_to_user_ptr(reg.area_ptr), sizeof(area)))
6f377873cb2390 David Wei 2025-02-14 198 return -EFAULT;
6f377873cb2390 David Wei 2025-02-14 199
6f377873cb2390 David Wei 2025-02-14 200 ifq = io_zcrx_ifq_alloc(ctx);
6f377873cb2390 David Wei 2025-02-14 201 if (!ifq)
6f377873cb2390 David Wei 2025-02-14 202 return -ENOMEM;
6f377873cb2390 David Wei 2025-02-14 203
6f377873cb2390 David Wei 2025-02-14 204 ret = io_allocate_rbuf_ring(ifq, ®, &rd);
6f377873cb2390 David Wei 2025-02-14 205 if (ret)
6f377873cb2390 David Wei 2025-02-14 206 goto err;
6f377873cb2390 David Wei 2025-02-14 207
cf96310c5f9a0d David Wei 2025-02-14 208 ret = io_zcrx_create_area(ifq, &ifq->area, &area);
cf96310c5f9a0d David Wei 2025-02-14 209 if (ret)
cf96310c5f9a0d David Wei 2025-02-14 210 goto err;
cf96310c5f9a0d David Wei 2025-02-14 211
6f377873cb2390 David Wei 2025-02-14 212 ifq->rq_entries = reg.rq_entries;
6f377873cb2390 David Wei 2025-02-14 213 ifq->if_rxq = reg.if_rxq;
6f377873cb2390 David Wei 2025-02-14 214
035af94b39fd13 Pavel Begunkov 2025-02-14 215 ret = -ENODEV;
035af94b39fd13 Pavel Begunkov 2025-02-14 216 ifq->netdev = netdev_get_by_index(current->nsproxy->net_ns, reg.if_idx,
035af94b39fd13 Pavel Begunkov 2025-02-14 217 &ifq->netdev_tracker, GFP_KERNEL);
035af94b39fd13 Pavel Begunkov 2025-02-14 218 if (!ifq->netdev)
035af94b39fd13 Pavel Begunkov 2025-02-14 219 goto err;
035af94b39fd13 Pavel Begunkov 2025-02-14 220
035af94b39fd13 Pavel Begunkov 2025-02-14 221 ifq->dev = ifq->netdev->dev.parent;
035af94b39fd13 Pavel Begunkov 2025-02-14 222 if (!ifq->dev)035af94b39fd13 Pavel Begunkov 2025-02-14 @223 return -EOPNOTSUPP;
goto err;
035af94b39fd13 Pavel Begunkov 2025-02-14 224 get_device(ifq->dev);
035af94b39fd13 Pavel Begunkov 2025-02-14 225
6f377873cb2390 David Wei 2025-02-14 226 reg.offsets.rqes = sizeof(struct io_uring);
6f377873cb2390 David Wei 2025-02-14 227 reg.offsets.head = offsetof(struct io_uring, head);
6f377873cb2390 David Wei 2025-02-14 228 reg.offsets.tail = offsetof(struct io_uring, tail);
6f377873cb2390 David Wei 2025-02-14 229
6f377873cb2390 David Wei 2025-02-14 230 if (copy_to_user(arg, ®, sizeof(reg)) ||
6f377873cb2390 David Wei 2025-02-14 231 copy_to_user(u64_to_user_ptr(reg.region_ptr), &rd, sizeof(rd))) {
6f377873cb2390 David Wei 2025-02-14 232 ret = -EFAULT;
6f377873cb2390 David Wei 2025-02-14 233 goto err;
6f377873cb2390 David Wei 2025-02-14 234 }
cf96310c5f9a0d David Wei 2025-02-14 235 if (copy_to_user(u64_to_user_ptr(reg.area_ptr), &area, sizeof(area))) {
cf96310c5f9a0d David Wei 2025-02-14 236 ret = -EFAULT;
cf96310c5f9a0d David Wei 2025-02-14 237 goto err;
cf96310c5f9a0d David Wei 2025-02-14 238 }
6f377873cb2390 David Wei 2025-02-14 239 ctx->ifq = ifq;
6f377873cb2390 David Wei 2025-02-14 240 return 0;
6f377873cb2390 David Wei 2025-02-14 241 err:
6f377873cb2390 David Wei 2025-02-14 242 io_zcrx_ifq_free(ifq);
6f377873cb2390 David Wei 2025-02-14 243 return ret;
6f377873cb2390 David Wei 2025-02-14 244 }Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 1 line · Dan Carpenter
Hi Pavel,
...
Quoted 4 lines
smatch warnings:
io_uring/zcrx.c:223io_register_zcrx_ifq()warn: missing unwind goto?vim +223
io_uring/zcrx.c
...
Quoted 11 lines
035af94b39fd13 Pavel Begunkov 2025-02-14 215 ret = -ENODEV; 035af94b39fd13 Pavel Begunkov 2025-02-14 216 ifq->netdev = netdev_get_by_index(current->nsproxy->net_ns, reg.if_idx, 035af94b39fd13 Pavel Begunkov 2025-02-14 217 &ifq->netdev_tracker, GFP_KERNEL); 035af94b39fd13 Pavel Begunkov 2025-02-14 218 if (!ifq->netdev) 035af94b39fd13 Pavel Begunkov 2025-02-14 219 goto err; 035af94b39fd13 Pavel Begunkov 2025-02-14 220 035af94b39fd13 Pavel Begunkov 2025-02-14 221 ifq->dev = ifq->netdev->dev.parent; 035af94b39fd13 Pavel Begunkov 2025-02-14 222 if (!ifq->dev)
035af94b39fd13Pavel Begunkov 2025-02-14 @223 return-EOPNOTSUPP;goto err;
Yes, you're right, thanks for letting us know!
Signature · 1 line
Pavel Begunkov