From: Al Viro Date: Fri, 30 Nov 2012 03:17:21 +0000 (-0500) Subject: lookup_one_len: don't accept . and .. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=21d8a15a;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git lookup_one_len: don't accept . and .. Signed-off-by: Al Viro --- diff --git a/fs/namei.c b/fs/namei.c index 937f9d50c84b..5f4cdf3ad913 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2131,6 +2131,11 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) if (!len) return ERR_PTR(-EACCES); + if (unlikely(name[0] == '.')) { + if (len < 2 || (len == 2 && name[1] == '.')) + return ERR_PTR(-EACCES); + } + while (len--) { c = *(const unsigned char *)name++; if (c == '/' || c == '\0')