Skip to content

Commit

Permalink
userns: When the per user per user namespace limit is reached return …
Browse files Browse the repository at this point in the history
…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" <[email protected]>
  • Loading branch information
ebiederm committed Sep 22, 2016
1 parent 9c722e4 commit df75e77
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2754,7 +2754,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)

ucounts = inc_mnt_namespaces(user_ns);
if (!ucounts)
return ERR_PTR(-ENFILE);
return ERR_PTR(-ENOSPC);

new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
if (!new_ns) {
Expand Down
2 changes: 1 addition & 1 deletion ipc/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
struct ucounts *ucounts;
int err;

err = -ENFILE;
err = -ENOSPC;
ucounts = inc_ipc_namespaces(user_ns);
if (!ucounts)
goto fail;
Expand Down
2 changes: 1 addition & 1 deletion kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -6354,7 +6354,7 @@ struct cgroup_namespace *copy_cgroup_ns(unsigned long flags,

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);
Expand Down
2 changes: 1 addition & 1 deletion kernel/pid_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns
int i;
int err;

err = -EINVAL;
err = -ENOSPC;
if (level > MAX_PID_NS_LEVEL)
goto out;
ucounts = inc_pid_namespaces(user_ns);
Expand Down
2 changes: 1 addition & 1 deletion kernel/user_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int create_user_ns(struct cred *new)
struct ucounts *ucounts;
int ret, i;

ret = -EUSERS;
ret = -ENOSPC;
if (parent_ns->level > 32)
goto fail;

Expand Down
2 changes: 1 addition & 1 deletion kernel/utsname.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns,
struct ucounts *ucounts;
int err;

err = -ENFILE;
err = -ENOSPC;
ucounts = inc_uts_namespaces(user_ns);
if (!ucounts)
goto fail;
Expand Down
2 changes: 1 addition & 1 deletion net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ struct net *copy_net_ns(unsigned long flags,

ucounts = inc_net_namespaces(user_ns);
if (!ucounts)
return ERR_PTR(-ENFILE);
return ERR_PTR(-ENOSPC);

net = net_alloc();
if (!net) {
Expand Down

0 comments on commit df75e77

Please sign in to comment.