userns: When the per user per user namespace limit is reached return ENOSPC
The current error codes returned when a the per user per user
namespace limit are hit (EINVAL, EUSERS, and ENFILE) are wrong. I
asked for advice on linux-api and it we made clear that those were
the wrong error code, but a correct effor code was not suggested.
The best general error code I have found for hitting a resource limit
is ENOSPC. It is not perfect but as it is unambiguous it will serve
until someone comes up with a better error code.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index e9e4427..f1dd4b0 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -6354,7 +6354,7 @@
ucounts = inc_cgroup_namespaces(user_ns);
if (!ucounts)
- return ERR_PTR(-ENFILE);
+ return ERR_PTR(-ENOSPC);
/* It is not safe to take cgroup_mutex here */
spin_lock_irq(&css_set_lock);
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 30a7f33..7542b28 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -98,7 +98,7 @@
int i;
int err;
- err = -EINVAL;
+ err = -ENOSPC;
if (level > MAX_PID_NS_LEVEL)
goto out;
ucounts = inc_pid_namespaces(user_ns);
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 0edafe3..f2c5ba5 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -76,7 +76,7 @@
struct ucounts *ucounts;
int ret, i;
- ret = -EUSERS;
+ ret = -ENOSPC;
if (parent_ns->level > 32)
goto fail;
diff --git a/kernel/utsname.c b/kernel/utsname.c
index f3b0bb4..35587b7 100644
--- a/kernel/utsname.c
+++ b/kernel/utsname.c
@@ -49,7 +49,7 @@
struct ucounts *ucounts;
int err;
- err = -ENFILE;
+ err = -ENOSPC;
ucounts = inc_uts_namespaces(user_ns);
if (!ucounts)
goto fail;