netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] netfilter: nft_set: remove one argument from lookup and update functions
@ 2025-08-04  8:46 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2025-08-04  8:46 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

Hello Florian Westphal,

Commit 17a20e09f086 ("netfilter: nft_set: remove one argument from
lookup and update functions") from Jul 9, 2025 (linux-next), leads to
the following Smatch static checker warning:

	net/netfilter/nft_set_pipapo_avx2.c:1269 nft_pipapo_avx2_lookup()
	error: uninitialized symbol 'ext'.

net/netfilter/nft_set_pipapo_avx2.c
    1148 const struct nft_set_ext *
    1149 nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
    1150                        const u32 *key)
    1151 {
    1152         struct nft_pipapo *priv = nft_set_priv(set);
    1153         struct nft_pipapo_scratch *scratch;
    1154         u8 genmask = nft_genmask_cur(net);
    1155         const struct nft_pipapo_match *m;
    1156         const struct nft_pipapo_field *f;
    1157         const u8 *rp = (const u8 *)key;
    1158         const struct nft_set_ext *ext;
    1159         unsigned long *res, *fill;
    1160         bool map_index;
    1161         int i;
    1162 
    1163         local_bh_disable();
    1164 
    1165         if (unlikely(!irq_fpu_usable())) {
    1166                 ext = nft_pipapo_lookup(net, set, key);
    1167 
    1168                 local_bh_enable();
    1169                 return ext;
    1170         }
    1171 
    1172         m = rcu_dereference(priv->match);
    1173 
    1174         /* This also protects access to all data related to scratch maps.
    1175          *
    1176          * Note that we don't need a valid MXCSR state for any of the
    1177          * operations we use here, so pass 0 as mask and spare a LDMXCSR
    1178          * instruction.
    1179          */
    1180         kernel_fpu_begin_mask(0);
    1181 
    1182         scratch = *raw_cpu_ptr(m->scratch);
    1183         if (unlikely(!scratch)) {
    1184                 kernel_fpu_end();
    1185                 local_bh_enable();
    1186                 return NULL;
    1187         }
    1188 
    1189         map_index = scratch->map_index;
    1190 
    1191         res  = scratch->map + (map_index ? m->bsize_max : 0);
    1192         fill = scratch->map + (map_index ? 0 : m->bsize_max);
    1193 
    1194         pipapo_resmap_init_avx2(m, res);
    1195 
    1196         nft_pipapo_avx2_prepare();
    1197 
    1198 next_match:
    1199         nft_pipapo_for_each_field(f, i, m) {
    1200                 bool last = i == m->field_count - 1, first = !i;
    1201                 int ret = 0;
    1202 
    1203 #define NFT_SET_PIPAPO_AVX2_LOOKUP(b, n)                                \
    1204                 (ret = nft_pipapo_avx2_lookup_##b##b_##n(res, fill, f,        \
    1205                                                          ret, rp,        \
    1206                                                          first, last))
    1207 
    1208                 if (likely(f->bb == 8)) {
    1209                         if (f->groups == 1) {
    1210                                 NFT_SET_PIPAPO_AVX2_LOOKUP(8, 1);
    1211                         } else if (f->groups == 2) {
    1212                                 NFT_SET_PIPAPO_AVX2_LOOKUP(8, 2);
    1213                         } else if (f->groups == 4) {
    1214                                 NFT_SET_PIPAPO_AVX2_LOOKUP(8, 4);
    1215                         } else if (f->groups == 6) {
    1216                                 NFT_SET_PIPAPO_AVX2_LOOKUP(8, 6);
    1217                         } else if (f->groups == 16) {
    1218                                 NFT_SET_PIPAPO_AVX2_LOOKUP(8, 16);
    1219                         } else {
    1220                                 ret = nft_pipapo_avx2_lookup_slow(m, res, fill, f,
    1221                                                                   ret, rp,
    1222                                                                   first, last);
    1223                         }
    1224                 } else {
    1225                         if (f->groups == 2) {
    1226                                 NFT_SET_PIPAPO_AVX2_LOOKUP(4, 2);
    1227                         } else if (f->groups == 4) {
    1228                                 NFT_SET_PIPAPO_AVX2_LOOKUP(4, 4);
    1229                         } else if (f->groups == 8) {
    1230                                 NFT_SET_PIPAPO_AVX2_LOOKUP(4, 8);
    1231                         } else if (f->groups == 12) {
    1232                                 NFT_SET_PIPAPO_AVX2_LOOKUP(4, 12);
    1233                         } else if (f->groups == 32) {
    1234                                 NFT_SET_PIPAPO_AVX2_LOOKUP(4, 32);
    1235                         } else {
    1236                                 ret = nft_pipapo_avx2_lookup_slow(m, res, fill, f,
    1237                                                                   ret, rp,
    1238                                                                   first, last);
    1239                         }
    1240                 }
    1241                 NFT_PIPAPO_GROUP_BITS_ARE_8_OR_4;
    1242 
    1243 #undef NFT_SET_PIPAPO_AVX2_LOOKUP
    1244 
    1245                 if (ret < 0)
    1246                         goto out;

Needs an "ext = NULL;"?

    1247 
    1248                 if (last) {
    1249                         ext = &f->mt[ret].e->ext;
    1250                         if (unlikely(nft_set_elem_expired(ext) ||
    1251                                      !nft_set_elem_active(ext, genmask))) {
    1252                                 ext = NULL;
    1253                                 goto next_match;
    1254                         }
    1255 
    1256                         goto out;
    1257                 }
    1258 
    1259                 swap(res, fill);
    1260                 rp += NFT_PIPAPO_GROUPS_PADDED_SIZE(f);
    1261         }
    1262 
    1263 out:
    1264         if (i % 2)
    1265                 scratch->map_index = !map_index;
    1266         kernel_fpu_end();
    1267         local_bh_enable();
    1268 
--> 1269         return ext;
    1270 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-08-04  8:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-04  8:46 [bug report] netfilter: nft_set: remove one argument from lookup and update functions Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).