mbox series

[v3,bpf-next,0/3] introduce new VFS based BPF kfuncs

Message ID 20240726085604.2369469-1-mattbobrowski@google.com (mailing list archive)
Headers show
Series introduce new VFS based BPF kfuncs | expand

Message

Matt Bobrowski July 26, 2024, 8:56 a.m. UTC
G'day!

The original cover letter providing background context and motivating
factors around the needs for these new VFS related BPF kfuncs
introduced within this patch series can be found here [0]. Please do
reference that if needed.

The changes contained within this version of the patch series mainly
came at the back of discussions held with Christian at LSFMMBPF
recently. In summary, the primary difference within this patch series
when compared to the last [1] is that I've reduced the number of VFS
related BPF kfuncs being introduced, housed them under fs/, and added
more selftests.

Changes since v2 [1]:

* All new VFS related BPF kfuncs now reside in fs/bpf_fs_kfuncs.c
  rather than kernel/trace/bpf_trace.c. This was something that was
  explicitly requested by Christian after discussing these new VFS
  related BPF kfuncs recently at LSFMMBPF.
  
* Dropped other initially proposed VFS related BPF kfuncs, including
  bpf_get_mm_exe_file(), bpf_get_task_fs_root(),
  bpf_get_task_fs_pwd(), and bpf_put_path().

* bpf_path_d_path() now makes use of __sz argument annotations such
  that the BPF verifier can enforce relevant size checks on the
  supplied buf that ends up being passed to d_path(). Relevant
  selftests have been added to assert __sz checking semantics are
  enforced.

[0] https://lore.kernel.org/bpf/cover.1708377880.git.mattbobrowski@google.com/
[1] https://lore.kernel.org/bpf/cover.1709675979.git.mattbobrowski@google.com/

Matt Bobrowski (3):
  bpf: introduce new VFS based BPF kfuncs
  selftests/bpf: add negative tests for new VFS based BPF kfuncs
  selftests/bpf: add positive tests for new VFS based BPF kfuncs

 fs/Makefile                                   |   1 +
 fs/bpf_fs_kfuncs.c                            | 133 ++++++++++++
 .../testing/selftests/bpf/bpf_experimental.h  |  26 +++
 .../selftests/bpf/prog_tests/verifier.c       |   4 +
 .../selftests/bpf/progs/verifier_vfs_accept.c |  71 +++++++
 .../selftests/bpf/progs/verifier_vfs_reject.c | 196 ++++++++++++++++++
 6 files changed, 431 insertions(+)
 create mode 100644 fs/bpf_fs_kfuncs.c
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_vfs_reject.c

Comments

Christian Brauner July 26, 2024, 1:22 p.m. UTC | #1
On Fri, Jul 26, 2024 at 08:56:01AM GMT, Matt Bobrowski wrote:
> G'day!
> 
> The original cover letter providing background context and motivating
> factors around the needs for these new VFS related BPF kfuncs
> introduced within this patch series can be found here [0]. Please do
> reference that if needed.
> 
> The changes contained within this version of the patch series mainly
> came at the back of discussions held with Christian at LSFMMBPF
> recently. In summary, the primary difference within this patch series
> when compared to the last [1] is that I've reduced the number of VFS
> related BPF kfuncs being introduced, housed them under fs/, and added
> more selftests.

I have no complaints about this now that it's been boiled down.
So as far as I'm concerned I'm happy to pick this up. (I also wouldn't
mind follow-up patches that move the xattr bpf kfuncs under fs/ as
well.)
Matt Bobrowski July 26, 2024, 8:22 p.m. UTC | #2
On Fri, Jul 26, 2024 at 03:22:09PM +0200, Christian Brauner wrote:
> On Fri, Jul 26, 2024 at 08:56:01AM GMT, Matt Bobrowski wrote:
> > G'day!
> > 
> > The original cover letter providing background context and motivating
> > factors around the needs for these new VFS related BPF kfuncs
> > introduced within this patch series can be found here [0]. Please do
> > reference that if needed.
> > 
> > The changes contained within this version of the patch series mainly
> > came at the back of discussions held with Christian at LSFMMBPF
> > recently. In summary, the primary difference within this patch series
> > when compared to the last [1] is that I've reduced the number of VFS
> > related BPF kfuncs being introduced, housed them under fs/, and added
> > more selftests.
> 
> I have no complaints about this now that it's been boiled down.
> So as far as I'm concerned I'm happy to pick this up. (I also wouldn't
> mind follow-up patches that move the xattr bpf kfuncs under fs/ as
> well.)

Wonderful, thank you Christian!

I agree, those should also reside in alongside these newly added BPF
kfuncs. I'll send through a patch addressing this
separately. Generally, I think the same applies for any other VFS
related BPF kfuncs that end up getting introduced moving forward.

/M
Alexei Starovoitov July 26, 2024, 8:35 p.m. UTC | #3
On Fri, Jul 26, 2024 at 6:22 AM Christian Brauner <brauner@kernel.org> wrote:
>
> On Fri, Jul 26, 2024 at 08:56:01AM GMT, Matt Bobrowski wrote:
> > G'day!
> >
> > The original cover letter providing background context and motivating
> > factors around the needs for these new VFS related BPF kfuncs
> > introduced within this patch series can be found here [0]. Please do
> > reference that if needed.
> >
> > The changes contained within this version of the patch series mainly
> > came at the back of discussions held with Christian at LSFMMBPF
> > recently. In summary, the primary difference within this patch series
> > when compared to the last [1] is that I've reduced the number of VFS
> > related BPF kfuncs being introduced, housed them under fs/, and added
> > more selftests.
>
> I have no complaints about this now that it's been boiled down.
> So as far as I'm concerned I'm happy to pick this up.

We very much prefer to go standard route via bpf-next
like we do for all kfuncs to avoid conflicts in selftests,
and where these patches will be actively tested by CI and developers.

So please provide an Ack.
I can fix up <= while applying.

> (I also wouldn't
> mind follow-up patches that move the xattr bpf kfuncs under fs/ as
> well.)

np. I'm sure Song can move xattr kfunc to this newly added file.
Christian Brauner July 30, 2024, 7:37 a.m. UTC | #4
Acked-by: Christian Brauner <brauner@kernel.org>