[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202308162316.PIY9owc8-lkp@intel.com>
Date: Thu, 17 Aug 2023 00:04:20 +0800
From: kernel test robot <lkp@...el.com>
To: Roberto Sassu <roberto.sassu@...wei.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
Alexei Starovoitov <ast@...nel.org>
Subject: kernel/trace/bpf_trace.c:1216:17: warning: no previous declaration
for 'bpf_lookup_user_key'
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4853c74bd7ab7fdb83f319bd9ace8a08c031e9b6
commit: f3cf4134c5c6c47b9b5c7aa3cb2d67e107887a7b bpf: Add bpf_lookup_*_key() and bpf_key_put() kfuncs
date: 11 months ago
config: x86_64-randconfig-x012-20230816 (https://download.01.org/0day-ci/archive/20230816/202308162316.PIY9owc8-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce: (https://download.01.org/0day-ci/archive/20230816/202308162316.PIY9owc8-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@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308162316.PIY9owc8-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> kernel/trace/bpf_trace.c:1216:17: warning: no previous declaration for 'bpf_lookup_user_key' [-Wmissing-declarations]
struct bpf_key *bpf_lookup_user_key(u32 serial, u64 flags)
^~~~~~~~~~~~~~~~~~~
>> kernel/trace/bpf_trace.c:1265:17: warning: no previous declaration for 'bpf_lookup_system_key' [-Wmissing-declarations]
struct bpf_key *bpf_lookup_system_key(u64 id)
^~~~~~~~~~~~~~~~~~~~~
>> kernel/trace/bpf_trace.c:1289:6: warning: no previous declaration for 'bpf_key_put' [-Wmissing-declarations]
void bpf_key_put(struct bpf_key *bkey)
^~~~~~~~~~~
vim +/bpf_lookup_user_key +1216 kernel/trace/bpf_trace.c
1185
1186 #ifdef CONFIG_KEYS
1187 __diag_push();
1188 __diag_ignore_all("-Wmissing-prototypes",
1189 "kfuncs which will be used in BPF programs");
1190
1191 /**
1192 * bpf_lookup_user_key - lookup a key by its serial
1193 * @serial: key handle serial number
1194 * @flags: lookup-specific flags
1195 *
1196 * Search a key with a given *serial* and the provided *flags*.
1197 * If found, increment the reference count of the key by one, and
1198 * return it in the bpf_key structure.
1199 *
1200 * The bpf_key structure must be passed to bpf_key_put() when done
1201 * with it, so that the key reference count is decremented and the
1202 * bpf_key structure is freed.
1203 *
1204 * Permission checks are deferred to the time the key is used by
1205 * one of the available key-specific kfuncs.
1206 *
1207 * Set *flags* with KEY_LOOKUP_CREATE, to attempt creating a requested
1208 * special keyring (e.g. session keyring), if it doesn't yet exist.
1209 * Set *flags* with KEY_LOOKUP_PARTIAL, to lookup a key without waiting
1210 * for the key construction, and to retrieve uninstantiated keys (keys
1211 * without data attached to them).
1212 *
1213 * Return: a bpf_key pointer with a valid key pointer if the key is found, a
1214 * NULL pointer otherwise.
1215 */
> 1216 struct bpf_key *bpf_lookup_user_key(u32 serial, u64 flags)
1217 {
1218 key_ref_t key_ref;
1219 struct bpf_key *bkey;
1220
1221 if (flags & ~KEY_LOOKUP_ALL)
1222 return NULL;
1223
1224 /*
1225 * Permission check is deferred until the key is used, as the
1226 * intent of the caller is unknown here.
1227 */
1228 key_ref = lookup_user_key(serial, flags, KEY_DEFER_PERM_CHECK);
1229 if (IS_ERR(key_ref))
1230 return NULL;
1231
1232 bkey = kmalloc(sizeof(*bkey), GFP_KERNEL);
1233 if (!bkey) {
1234 key_put(key_ref_to_ptr(key_ref));
1235 return NULL;
1236 }
1237
1238 bkey->key = key_ref_to_ptr(key_ref);
1239 bkey->has_ref = true;
1240
1241 return bkey;
1242 }
1243
1244 /**
1245 * bpf_lookup_system_key - lookup a key by a system-defined ID
1246 * @id: key ID
1247 *
1248 * Obtain a bpf_key structure with a key pointer set to the passed key ID.
1249 * The key pointer is marked as invalid, to prevent bpf_key_put() from
1250 * attempting to decrement the key reference count on that pointer. The key
1251 * pointer set in such way is currently understood only by
1252 * verify_pkcs7_signature().
1253 *
1254 * Set *id* to one of the values defined in include/linux/verification.h:
1255 * 0 for the primary keyring (immutable keyring of system keys);
1256 * VERIFY_USE_SECONDARY_KEYRING for both the primary and secondary keyring
1257 * (where keys can be added only if they are vouched for by existing keys
1258 * in those keyrings); VERIFY_USE_PLATFORM_KEYRING for the platform
1259 * keyring (primarily used by the integrity subsystem to verify a kexec'ed
1260 * kerned image and, possibly, the initramfs signature).
1261 *
1262 * Return: a bpf_key pointer with an invalid key pointer set from the
1263 * pre-determined ID on success, a NULL pointer otherwise
1264 */
> 1265 struct bpf_key *bpf_lookup_system_key(u64 id)
1266 {
1267 struct bpf_key *bkey;
1268
1269 if (system_keyring_id_check(id) < 0)
1270 return NULL;
1271
1272 bkey = kmalloc(sizeof(*bkey), GFP_ATOMIC);
1273 if (!bkey)
1274 return NULL;
1275
1276 bkey->key = (struct key *)(unsigned long)id;
1277 bkey->has_ref = false;
1278
1279 return bkey;
1280 }
1281
1282 /**
1283 * bpf_key_put - decrement key reference count if key is valid and free bpf_key
1284 * @bkey: bpf_key structure
1285 *
1286 * Decrement the reference count of the key inside *bkey*, if the pointer
1287 * is valid, and free *bkey*.
1288 */
> 1289 void bpf_key_put(struct bpf_key *bkey)
1290 {
1291 if (bkey->has_ref)
1292 key_put(bkey->key);
1293
1294 kfree(bkey);
1295 }
1296
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists