bpf: fix mount source show for bpffs
Subsystems (3)
PATCH v2 1/1 bpf: fix mount source show for bpffs
We noticed our tc ebpf tools can't start after we upgrade our in-house kernel version from 4.19 to 5.10. That is because of the behaviour change in bpffs caused by commitd2935de7e4fd ("vfs: Convert bpf to use the new mount API").
In our tc ebpf tools, we do strict environment check. If the enrioment is not match, we won't allow to start the ebpf progs. One of the check is whether bpffs is properly mounted. The mount information of bpffs in kernel-4.19 and kernel-5.10 are as follows,
- kenrel 4.19
$ mount -t bpf bpffs /sys/fs/bpf $ mount -t bpf bpffs on /sys/fs/bpf type bpf (rw,relatime)
- kernel 5.10
$ mount -t bpf bpffs /sys/fs/bpf $ mount -t bpf none on /sys/fs/bpf type bpf (rw,relatime)
The device name in kernel-5.10 is displayed as none instead of bpffs, then our environment check fails. Currently we modify the tools to adopt to the kernel behaviour change, but I think we'd better change the kernel code to keep the behavior consistent.
After this change, the mount information will be displayed the same with the behavior in kernel-4.19, for example,
$ mount -t bpf bpffs /sys/fs/bpf $ mount -t bpf bpffs on /sys/fs/bpf type bpf (rw,relatime)
---v1->v2:
use the helper vfs_parse_fs_param_source() instead of open-coded (Daniel)
--- kernel/bpf/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
kernel/bpf/inode.c +12 -2
@@ -648,12 +648,22 @@ static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)int opt; opt =fs_parse (fc, bpf_fs_parameters, param, &result); -if (opt <0 ) +if (opt <0 ) {/* We might like to report bad mount options here, but * traditionally we've ignored all mount options, so we'd * better continue to ignore non-existing options for bpf. */ -return opt == -ENOPARAM ?0 : opt; +if (opt == -ENOPARAM ) { + opt =vfs_parse_fs_param_source (fc, param); +if (opt != -ENOPARAM ) +return opt; + +return 0 ; + } + +if (opt <0 ) +return opt; + }switch (opt) {case OPT_MODE :
Signature · 1 line
2.17.1
Quoted 38 lines · Yafang Shao
We noticed our tc ebpf tools can't start after we upgrade our in-house kernel version from 4.19 to 5.10. That is because of the behaviour change in bpffs caused by commit
d2935de7e4fd("vfs: Convert bpf to use the new mount API").In our tc ebpf tools, we do strict environment check. If the enrioment is not match, we won't allow to start the ebpf progs. One of the check is whether bpffs is properly mounted. The mount information of bpffs in kernel-4.19 and kernel-5.10 are as follows,
- kenrel 4.19
$ mount -t bpf bpffs /sys/fs/bpf $ mount -t bpf bpffs on /sys/fs/bpf type bpf (rw,relatime)- kernel 5.10
$ mount -t bpf bpffs /sys/fs/bpf $ mount -t bpf none on /sys/fs/bpf type bpf (rw,relatime)The device name in kernel-5.10 is displayed as none instead of bpffs, then our environment check fails. Currently we modify the tools to adopt to the kernel behaviour change, but I think we'd better change the kernel code to keep the behavior consistent.
After this change, the mount information will be displayed the same with the behavior in kernel-4.19, for example,
$ mount -t bpf bpffs /sys/fs/bpf $ mount -t bpf bpffs on /sys/fs/bpf type bpf (rw,relatime)Fixes d2935de7e4fd ("vfs: Convert bpf to use the new mount API")Suggested-by Daniel Borkmann <[email protected]>Signed-off-by Yafang Shao <[email protected]>Cc David Howells <[email protected]>Cc Al Viro <[email protected]>
Quoted 4 lines
---
v1->v2:
use the helpervfs_parse_fs_param_source()instead of open-coded (Daniel)
---
Looks good,
This patch was applied to bpf/bpf.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <[email protected]>:
Quoted 11 lines · On Sat, 8 Jan 2022 13:46:23 +0000 you wrote:
We noticed our tc ebpf tools can't start after we upgrade our in-house kernel version from 4.19 to 5.10. That is because of the behaviour change in bpffs caused by commit
d2935de7e4fd("vfs: Convert bpf to use the new mount API").In our tc ebpf tools, we do strict environment check. If the enrioment is not match, we won't allow to start the ebpf progs. One of the check is whether bpffs is properly mounted. The mount information of bpffs in kernel-4.19 and kernel-5.10 are as follows,
[...]
Here is the summary with links:
- [v2] bpf: fix mount source show for bpffs
https://git.kernel.org/bpf/bpf/c/1e9d74660d4d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html