[linux-next:master 4835/6424] io_uring/io_uring.c:2175:23: sparse: sparse: cast to restricted io_req_flags_t

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jens,

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:   46d4e2eb58e14c8935fa0e27d16d4c62ef82849a
commit: 4bcb982cce74e18155fba0d97394ca9634e0d8f0 [4835/6424] io_uring: expand main struct io_kiocb flags to 64-bits
config: x86_64-randconfig-123-20240213 (https://download.01.org/0day-ci/archive/20240214/202402140601.uNW0oVSb-lkp@xxxxxxxxx/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240214/202402140601.uNW0oVSb-lkp@xxxxxxxxx/reproduce)

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 <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402140601.uNW0oVSb-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
   io_uring/io_uring.c: note: in included file (through include/linux/io_uring/cmd.h):
   include/linux/io_uring_types.h:341:48: sparse: sparse: array of flexible structures
   include/linux/io_uring_types.h:182:37: sparse: sparse: array of flexible structures
>> io_uring/io_uring.c:2175:23: sparse: sparse: cast to restricted io_req_flags_t
   io_uring/io_uring.c: note: in included file (through include/linux/wait.h, include/linux/wait_bit.h, include/linux/fs.h, ...):
   include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
   include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
   io_uring/io_uring.c:656:36: sparse: sparse: context imbalance in 'io_fill_cqe_req_aux' - unexpected unlock
   include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
   io_uring/io_uring.c:658:17: sparse: sparse: context imbalance in '__io_submit_flush_completions' - different lock contexts for basic block
   include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true
   include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates to true

vim +2175 io_uring/io_uring.c

  2161	
  2162	static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
  2163			       const struct io_uring_sqe *sqe)
  2164		__must_hold(&ctx->uring_lock)
  2165	{
  2166		const struct io_issue_def *def;
  2167		unsigned int sqe_flags;
  2168		int personality;
  2169		u8 opcode;
  2170	
  2171		/* req is partially pre-initialised, see io_preinit_req() */
  2172		req->opcode = opcode = READ_ONCE(sqe->opcode);
  2173		/* same numerical values with corresponding REQ_F_*, safe to copy */
  2174		sqe_flags = READ_ONCE(sqe->flags);
> 2175		req->flags = (io_req_flags_t) sqe_flags;
  2176		req->cqe.user_data = READ_ONCE(sqe->user_data);
  2177		req->file = NULL;
  2178		req->rsrc_node = NULL;
  2179		req->task = current;
  2180	
  2181		if (unlikely(opcode >= IORING_OP_LAST)) {
  2182			req->opcode = 0;
  2183			return -EINVAL;
  2184		}
  2185		def = &io_issue_defs[opcode];
  2186		if (unlikely(sqe_flags & ~SQE_COMMON_FLAGS)) {
  2187			/* enforce forwards compatibility on users */
  2188			if (sqe_flags & ~SQE_VALID_FLAGS)
  2189				return -EINVAL;
  2190			if (sqe_flags & IOSQE_BUFFER_SELECT) {
  2191				if (!def->buffer_select)
  2192					return -EOPNOTSUPP;
  2193				req->buf_index = READ_ONCE(sqe->buf_group);
  2194			}
  2195			if (sqe_flags & IOSQE_CQE_SKIP_SUCCESS)
  2196				ctx->drain_disabled = true;
  2197			if (sqe_flags & IOSQE_IO_DRAIN) {
  2198				if (ctx->drain_disabled)
  2199					return -EOPNOTSUPP;
  2200				io_init_req_drain(req);
  2201			}
  2202		}
  2203		if (unlikely(ctx->restricted || ctx->drain_active || ctx->drain_next)) {
  2204			if (ctx->restricted && !io_check_restriction(ctx, req, sqe_flags))
  2205				return -EACCES;
  2206			/* knock it to the slow queue path, will be drained there */
  2207			if (ctx->drain_active)
  2208				req->flags |= REQ_F_FORCE_ASYNC;
  2209			/* if there is no link, we're at "next" request and need to drain */
  2210			if (unlikely(ctx->drain_next) && !ctx->submit_state.link.head) {
  2211				ctx->drain_next = false;
  2212				ctx->drain_active = true;
  2213				req->flags |= REQ_F_IO_DRAIN | REQ_F_FORCE_ASYNC;
  2214			}
  2215		}
  2216	
  2217		if (!def->ioprio && sqe->ioprio)
  2218			return -EINVAL;
  2219		if (!def->iopoll && (ctx->flags & IORING_SETUP_IOPOLL))
  2220			return -EINVAL;
  2221	
  2222		if (def->needs_file) {
  2223			struct io_submit_state *state = &ctx->submit_state;
  2224	
  2225			req->cqe.fd = READ_ONCE(sqe->fd);
  2226	
  2227			/*
  2228			 * Plug now if we have more than 2 IO left after this, and the
  2229			 * target is potentially a read/write to block based storage.
  2230			 */
  2231			if (state->need_plug && def->plug) {
  2232				state->plug_started = true;
  2233				state->need_plug = false;
  2234				blk_start_plug_nr_ios(&state->plug, state->submit_nr);
  2235			}
  2236		}
  2237	
  2238		personality = READ_ONCE(sqe->personality);
  2239		if (personality) {
  2240			int ret;
  2241	
  2242			req->creds = xa_load(&ctx->personalities, personality);
  2243			if (!req->creds)
  2244				return -EINVAL;
  2245			get_cred(req->creds);
  2246			ret = security_uring_override_creds(req->creds);
  2247			if (ret) {
  2248				put_cred(req->creds);
  2249				return ret;
  2250			}
  2251			req->flags |= REQ_F_CREDS;
  2252		}
  2253	
  2254		return def->prep(req, sqe);
  2255	}
  2256	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux