Commit a45ea48e authored by David Howells's avatar David Howells Committed by Linus Torvalds
Browse files

afs: Fix characters allowed into cell names

The afs filesystem needs to prohibit certain characters from cell names,
such as '/', as these are used to form filenames in procfs, leading to
the following warning being generated:

	WARNING: CPU: 0 PID: 3489 at fs/proc/generic.c:178

Fix afs_alloc_cell() to disallow nonprintable characters, '/', '@' and
names that begin with a dot.

Remove the check for "@cell" as that is then redundant.

This can be tested by running:

	echo add foo/.bar >/proc/fs/afs/cells

Note that we will also need to deal with:

 - Names ending in ".invalid" shouldn't be passed to the DNS.

 - Names that contain non-valid domainname chars shouldn't be passed to
   the DNS.

 - DNS replies that say "your-dns-needs-immediate-attention.<gTLD>" and
   replies containing A records that say should be
   considered invalid.


but these need to be dealt with by the kafs-client DNS program rather
than the kernel.

Signed-off-by: default avatarDavid Howells <>
Signed-off-by: default avatarLinus Torvalds <>
parent 2821e26f
......@@ -134,8 +134,17 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net,
_leave(" = -ENAMETOOLONG");
if (namelen == 5 && memcmp(name, "@cell", 5) == 0)
/* Prohibit cell names that contain unprintable chars, '/' and '@' or
* that begin with a dot. This also precludes "@cell".
if (name[0] == '.')
return ERR_PTR(-EINVAL);
for (i = 0; i < namelen; i++) {
char ch = name[i];
if (!isprint(ch) || ch == '/' || ch == '@')
return ERR_PTR(-EINVAL);
_enter("%*.*s,%s", namelen, namelen, name, addresses);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment