bpf: Allow storing referenced kptr in map
[linux-block.git] / tools / include / uapi / linux / bpf.h
index d14b10b85e51f1f6097b54186694b42c9ad8e741..444fe6f1cf35894d254c17de6e475c4f913f34d8 100644 (file)
@@ -5143,6 +5143,17 @@ union bpf_attr {
  *             The **hash_algo** is returned on success,
  *             **-EOPNOTSUP** if the hash calculation failed or **-EINVAL** if
  *             invalid arguments are passed.
+ *
+ * void *bpf_kptr_xchg(void *map_value, void *ptr)
+ *     Description
+ *             Exchange kptr at pointer *map_value* with *ptr*, and return the
+ *             old value. *ptr* can be NULL, otherwise it must be a referenced
+ *             pointer which will be released when this helper is called.
+ *     Return
+ *             The old value of kptr (which can be NULL). The returned pointer
+ *             if not NULL, is a reference which must be released using its
+ *             corresponding release function, or moved into a BPF map before
+ *             program exit.
  */
 #define __BPF_FUNC_MAPPER(FN)          \
        FN(unspec),                     \
@@ -5339,6 +5350,7 @@ union bpf_attr {
        FN(copy_from_user_task),        \
        FN(skb_set_tstamp),             \
        FN(ima_file_hash),              \
+       FN(kptr_xchg),                  \
        /* */
 
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper