1. 25 Jan, 2023 1 commit
    • David Vernet's avatar
      bpf: Enable annotating trusted nested pointers · 57539b1c
      David Vernet authored
      In kfuncs, a "trusted" pointer is a pointer that the kfunc can assume is
      safe, and which the verifier will allow to be passed to a
      KF_TRUSTED_ARGS kfunc. Currently, a KF_TRUSTED_ARGS kfunc disallows any
      pointer to be passed at a nonzero offset, but sometimes this is in fact
      safe if the "nested" pointer's lifetime is inherited from its parent.
      For example, the const cpumask_t *cpus_ptr field in a struct task_struct
      will remain valid until the task itself is destroyed, and thus would
      also be safe to pass to a KF_TRUSTED_ARGS kfunc.
      
      While it would be conceptually simple to enable this by using BTF tags,
      gcc unfortunately does not yet support this. In the interim, this patch
      enables support for this by using a type-naming convention. A new
      BTF_TYPE_SAFE_NESTED macro is defined in verifier.c which allows a
      developer to specify the nested fields of a type which are considered
      trusted if its parent is also trusted. The verifier is also updated to
      account for this. A patch with selftests will be added in a follow-on
      change, along with documentation for this feature.
      Signed-off-by: default avatarDavid Vernet <void@manifault.com>
      Link: https://lore.kernel.org/r/20230120192523.3650503-2-void@manifault.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      57539b1c
  2. 24 Jan, 2023 1 commit
  3. 23 Jan, 2023 38 commits