From: kernel test robot <lkp@intel.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [axboe:io_uring-bpf-restrictions 15/16] io_uring/bpf_filter.c:79:30: sparse: sparse: restricted io_req_flags_t degrades to integer
Date: Fri, 16 Jan 2026 01:27:48 +0800 [thread overview]
Message-ID: <202601160119.OZCBn3F9-lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux.git io_uring-bpf-restrictions
head: 20511f2c3707b6de0f299a3c70a9098a5c98e5c6
commit: 575dae8c0edf27527c2e86d4fce468106bf2c3f9 [15/16] io_uring: add support for BPF filtering for opcode restrictions
config: microblaze-randconfig-r111-20260115 (https://download.01.org/0day-ci/archive/20260116/202601160119.OZCBn3F9-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260116/202601160119.OZCBn3F9-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601160119.OZCBn3F9-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> io_uring/bpf_filter.c:79:30: sparse: sparse: restricted io_req_flags_t degrades to integer
>> io_uring/bpf_filter.c:136:17: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct io_bpf_filter **filters @@ got struct io_bpf_filter [noderef] __rcu **bpf_filters @@
io_uring/bpf_filter.c:136:17: sparse: expected struct io_bpf_filter **filters
io_uring/bpf_filter.c:136:17: sparse: got struct io_bpf_filter [noderef] __rcu **bpf_filters
>> io_uring/bpf_filter.c:149:37: sparse: sparse: incompatible types in comparison expression (different address spaces):
io_uring/bpf_filter.c:149:37: sparse: struct io_bpf_filter **
io_uring/bpf_filter.c:149:37: sparse: struct io_bpf_filter [noderef] __rcu **
io_uring/bpf_filter.c:156:37: sparse: sparse: incompatible types in comparison expression (different address spaces):
io_uring/bpf_filter.c:156:37: sparse: struct io_bpf_filter **
io_uring/bpf_filter.c:156:37: sparse: struct io_bpf_filter [noderef] __rcu **
io_uring/bpf_filter.c:171:30: sparse: sparse: incompatible types in comparison expression (different address spaces):
io_uring/bpf_filter.c:171:30: sparse: struct io_bpf_filter [noderef] __rcu *
io_uring/bpf_filter.c:171:30: sparse: struct io_bpf_filter *
io_uring/bpf_filter.c:174:17: sparse: sparse: incompatible types in comparison expression (different address spaces):
io_uring/bpf_filter.c:174:17: sparse: struct io_bpf_filter [noderef] __rcu *
io_uring/bpf_filter.c:174:17: sparse: struct io_bpf_filter *
io_uring/bpf_filter.c:180:21: sparse: sparse: incompatible types in comparison expression (different address spaces):
io_uring/bpf_filter.c:180:21: sparse: struct io_bpf_filter **
io_uring/bpf_filter.c:180:21: sparse: struct io_bpf_filter [noderef] __rcu **
vim +79 io_uring/bpf_filter.c
72
73 /* Populate BPF context from SQE */
74 static void io_uring_populate_bpf_ctx(struct io_uring_bpf_ctx *bctx,
75 struct io_kiocb *req)
76 {
77 memset(bctx, 0, sizeof(*bctx));
78 bctx->opcode = req->opcode;
> 79 bctx->sqe_flags = req->flags & SQE_VALID_FLAGS;
80 bctx->user_data = req->cqe.user_data;
81
82 switch (req->opcode) {
83 case IORING_OP_SOCKET:
84 io_socket_bpf_populate(bctx, req);
85 break;
86 }
87 }
88
89 /*
90 * Run registered filters for a given opcode. Return of 0 means that the
91 * request should be allowed.
92 */
93 int __io_uring_run_bpf_filters(struct io_restriction *res, struct io_kiocb *req)
94 {
95 struct io_bpf_filter *filter;
96 struct io_uring_bpf_ctx bpf_ctx;
97 int ret;
98
99 rcu_read_lock();
100 filter = rcu_dereference(res->filters.bpf_filters[req->opcode]);
101 if (!filter || !filter->prog) {
102 rcu_read_unlock();
103 return 0;
104 }
105
106 io_uring_populate_bpf_ctx(&bpf_ctx, req);
107
108 do {
109 ret = bpf_prog_run(filter->prog, &bpf_ctx);
110 if (!ret)
111 break;
112 filter = filter->next;
113 } while (filter);
114
115 rcu_read_unlock();
116 return ret ? 0 : -EACCES;
117 }
118
119 int io_register_bpf_filter(struct io_restriction *res,
120 struct io_uring_bpf_filter __user *arg)
121 {
122 struct io_bpf_filter *filter, *old_filter;
123 struct io_uring_bpf_filter reg;
124 struct io_bpf_filter **filters;
125
126 if (copy_from_user(®, arg, sizeof(reg)))
127 return -EFAULT;
128 if (reg.opcode >= IORING_OP_LAST)
129 return -EINVAL;
130 if (reg.flags || !mem_is_zero(reg.reserved, sizeof(reg.reserved)))
131 return -EINVAL;
132
133 /*
134 * No existing filters, allocate set.
135 */
> 136 filters = res->filters.bpf_filters;
137 if (!filters) {
138 filters = kzalloc(IORING_OP_LAST * sizeof(struct io_bpf_filter *), GFP_KERNEL);
139 if (!filters)
140 return -ENOMEM;
141 }
142
143 filter = NULL;
144 if (reg.prog_fd >= 0) {
145 struct bpf_prog *prog;
146
147 prog = bpf_prog_get_type(reg.prog_fd, BPF_PROG_TYPE_IO_URING_FILTER);
148 if (IS_ERR(prog)) {
> 149 if (filters != res->filters.bpf_filters)
150 kfree(filters);
151 return PTR_ERR(prog);
152 }
153
154 filter = kzalloc(sizeof(*filter), GFP_KERNEL);
155 if (!filter) {
156 if (filters != res->filters.bpf_filters)
157 kfree(filters);
158 bpf_prog_put(prog);
159 return -ENOMEM;
160 }
161 filter->prog = prog;
162 res->filters.bpf_filters = filters;
163 }
164
165 /*
166 * Insert filter - if the current opcode already has a filter
167 * attached, add to the set.
168 */
169 if (filter) {
170 spin_lock(&res->filters.lock);
171 old_filter = rcu_dereference(filters[reg.opcode]);
172 if (old_filter)
173 filter->next = old_filter;
174 rcu_assign_pointer(filters[reg.opcode], filter);
175 spin_unlock(&res->filters.lock);
176 res->bpf_registered = 1;
177 return 0;
178 }
179
180 if (filters != res->filters.bpf_filters)
181 kfree(filters);
182 return -EINVAL;
183 }
184
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2026-01-15 17:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202601160119.OZCBn3F9-lkp@intel.com \
--to=lkp@intel.com \
--cc=axboe@kernel.dk \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.