diff options
author | Andrew Morton <akpm@linux-foundation.org> | 2012-03-28 17:42:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-28 20:14:37 -0400 |
commit | 4c619aa0ba171c092a0ae5d969364deb82dbe371 (patch) | |
tree | bc710f9a419f1f87712f5fa4c341330f7293c3d8 | |
parent | f4507164e7796b66c371ff9a63154f1c884a2433 (diff) |
fs/proc/namespaces.c: prevent crash when ns_entries[] is empty
If CONFIG_NET_NS, CONFIG_UTS_NS and CONFIG_IPC_NS are disabled,
ns_entries[] becomes empty and things like
ns_entries[ARRAY_SIZE(ns_entries) - 1] will explode.
Reported-by: Richard Weinberger <richard@nod.at>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Daniel Lezcano <daniel.lezcano@free.fr>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/proc/namespaces.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c index 3551f1f839eb..0d9e23a39e49 100644 --- a/fs/proc/namespaces.c +++ b/fs/proc/namespaces.c | |||
@@ -156,15 +156,15 @@ static struct dentry *proc_ns_dir_lookup(struct inode *dir, | |||
156 | if (!ptrace_may_access(task, PTRACE_MODE_READ)) | 156 | if (!ptrace_may_access(task, PTRACE_MODE_READ)) |
157 | goto out; | 157 | goto out; |
158 | 158 | ||
159 | last = &ns_entries[ARRAY_SIZE(ns_entries) - 1]; | 159 | last = &ns_entries[ARRAY_SIZE(ns_entries)]; |
160 | for (entry = ns_entries; entry <= last; entry++) { | 160 | for (entry = ns_entries; entry < last; entry++) { |
161 | if (strlen((*entry)->name) != len) | 161 | if (strlen((*entry)->name) != len) |
162 | continue; | 162 | continue; |
163 | if (!memcmp(dentry->d_name.name, (*entry)->name, len)) | 163 | if (!memcmp(dentry->d_name.name, (*entry)->name, len)) |
164 | break; | 164 | break; |
165 | } | 165 | } |
166 | error = ERR_PTR(-ENOENT); | 166 | error = ERR_PTR(-ENOENT); |
167 | if (entry > last) | 167 | if (entry == last) |
168 | goto out; | 168 | goto out; |
169 | 169 | ||
170 | error = proc_ns_instantiate(dir, dentry, task, *entry); | 170 | error = proc_ns_instantiate(dir, dentry, task, *entry); |