Skip to content

Commit 6d8cb04

Browse files
qmonnetborkmann
authored andcommitted
bpf: comment why dots in filenames under BPF virtual FS are not allowed
When pinning a file under the BPF virtual file system (traditionally /sys/fs/bpf), using a dot in the name of the location to pin at is not allowed. For example, trying to pin at "/sys/fs/bpf/foo.bar" will be rejected with -EPERM. This check was introduced at the same time as the BPF file system itself, with commit b219775 ("bpf: add support for persistent maps/progs"). At this time, it was checked in a function called "bpf_dname_reserved()", which made clear that using a dot was reserved for future extensions. This function disappeared and the check was moved elsewhere with commit 0c93b7d ("bpf: reject invalid names right in ->lookup()"), and the meaning of the dot ban was lost. The present commit simply adds a comment in the source to explain to the reader that the usage of dots is reserved for future usage. Signed-off-by: Quentin Monnet <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 75a141a commit 6d8cb04

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/bpf/inode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ static int bpf_mkmap(struct dentry *dentry, umode_t mode, void *arg)
178178
static struct dentry *
179179
bpf_lookup(struct inode *dir, struct dentry *dentry, unsigned flags)
180180
{
181+
/* Dots in names (e.g. "/sys/fs/bpf/foo.bar") are reserved for future
182+
* extensions.
183+
*/
181184
if (strchr(dentry->d_name.name, '.'))
182185
return ERR_PTR(-EPERM);
183186

0 commit comments

Comments
 (0)