Skip to content

Commit b77d70d

Browse files
Alexey Dobriyantorvalds
authored andcommitted
proc: reject "." and ".." as filenames
Various subsystems can create files and directories in /proc with names directly controlled by userspace. Which means "/", "." and ".." are no-no. "/" split is already taken care of, do the other 2 prohibited names. Link: http://lkml.kernel.org/r/20180310001223.GB12443@avx2 Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Acked-by: Florian Westphal <fw@strlen.de> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Cong Wang <xiyou.wangcong@gmail.com> Cc: Pavel Machek <pavel@ucw.cz> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5de3d40 commit b77d70d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎fs/proc/generic.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,14 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
366366
WARN(1, "name len %u\n", qstr.len);
367367
return NULL;
368368
}
369+
if (qstr.len == 1 && fn[0] == '.') {
370+
WARN(1, "name '.'\n");
371+
return NULL;
372+
}
373+
if (qstr.len == 2 && fn[0] == '.' && fn[1] == '.') {
374+
WARN(1, "name '..'\n");
375+
return NULL;
376+
}
369377
if (*parent == &proc_root && name_to_int(&qstr) != ~0U) {
370378
WARN(1, "create '/proc/%s' by hand\n", qstr.name);
371379
return NULL;

0 commit comments

Comments
 (0)