Skip to content

Commit a45ea48

Browse files
dhowellstorvalds
authored andcommitted
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 1.2.3.4 >/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 127.0.53.53 should be considered invalid. [https://www.icann.org/en/system/files/files/name-collision-mitigation-01aug14-en.pdf] but these need to be dealt with by the kafs-client DNS program rather than the kernel. Reported-by: syzbot+b904ba7c947a37b4b291@syzkaller.appspotmail.com Cc: stable@kernel.org Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2821e26 commit a45ea48

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

fs/afs/cell.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,17 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net,
134134
_leave(" = -ENAMETOOLONG");
135135
return ERR_PTR(-ENAMETOOLONG);
136136
}
137-
if (namelen == 5 && memcmp(name, "@cell", 5) == 0)
137+
138+
/* Prohibit cell names that contain unprintable chars, '/' and '@' or
139+
* that begin with a dot. This also precludes "@cell".
140+
*/
141+
if (name[0] == '.')
138142
return ERR_PTR(-EINVAL);
143+
for (i = 0; i < namelen; i++) {
144+
char ch = name[i];
145+
if (!isprint(ch) || ch == '/' || ch == '@')
146+
return ERR_PTR(-EINVAL);
147+
}
139148

140149
_enter("%*.*s,%s", namelen, namelen, name, addresses);
141150

0 commit comments

Comments
 (0)