bpf: Re-support uid and gid when mounting bpffs
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 20 Dec 2023 13:38:05 +0000 (14:38 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 21 Dec 2023 13:24:30 +0000 (14:24 +0100)
commitb08c8fc0411dce0fc44b78ce4d67f1b67c35c196
tree4939fe5cb33dab0c69fcb62808f63cc982ce6d7b
parentfc3a5534e2a8855427403113cbeb54af5837bbe0
bpf: Re-support uid and gid when mounting bpffs

For a clean, conflict-free revert of the token-related patches in commit
d17aff807f84 ("Revert BPF token-related functionality"), the bpf fs commit
750e785796bb ("bpf: Support uid and gid when mounting bpffs") was undone
temporarily as well.

This patch manually re-adds the functionality from the original one back
in 750e785796bb, no other functional changes intended.

Testing:

  # mount -t bpf -o uid=65534,gid=65534 bpffs ./foo
  # ls -la . | grep foo
  drwxrwxrwt   2 nobody nogroup          0 Dec 20 13:16 foo
  # mount -t bpf
  bpffs on /root/foo type bpf (rw,relatime,uid=65534,gid=65534)

Also, passing invalid arguments for uid/gid are properly rejected as expected.

Fixes: d17aff807f84 ("Revert BPF token-related functionality")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Cc: Jie Jiang <jiejiang@chromium.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: linux-fsdevel@vger.kernel.org
Link: https://lore.kernel.org/bpf/20231220133805.20953-1-daniel@iogearbox.net
kernel/bpf/inode.c