Skip to content

Commit df75e77

Browse files
committed
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>
1 parent 9c722e4 commit df75e77

7 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎fs/namespace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2754,7 +2754,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
27542754

27552755
ucounts = inc_mnt_namespaces(user_ns);
27562756
if (!ucounts)
2757-
return ERR_PTR(-ENFILE);
2757+
return ERR_PTR(-ENOSPC);
27582758

27592759
new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
27602760
if (!new_ns) {

‎ipc/namespace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
3333
struct ucounts *ucounts;
3434
int err;
3535

36-
err = -ENFILE;
36+
err = -ENOSPC;
3737
ucounts = inc_ipc_namespaces(user_ns);
3838
if (!ucounts)
3939
goto fail;

‎kernel/cgroup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6354,7 +6354,7 @@ struct cgroup_namespace *copy_cgroup_ns(unsigned long flags,
63546354

63556355
ucounts = inc_cgroup_namespaces(user_ns);
63566356
if (!ucounts)
6357-
return ERR_PTR(-ENFILE);
6357+
return ERR_PTR(-ENOSPC);
63586358

63596359
/* It is not safe to take cgroup_mutex here */
63606360
spin_lock_irq(&css_set_lock);

‎kernel/pid_namespace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns
9898
int i;
9999
int err;
100100

101-
err = -EINVAL;
101+
err = -ENOSPC;
102102
if (level > MAX_PID_NS_LEVEL)
103103
goto out;
104104
ucounts = inc_pid_namespaces(user_ns);

‎kernel/user_namespace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ int create_user_ns(struct cred *new)
7676
struct ucounts *ucounts;
7777
int ret, i;
7878

79-
ret = -EUSERS;
79+
ret = -ENOSPC;
8080
if (parent_ns->level > 32)
8181
goto fail;
8282

‎kernel/utsname.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns,
4949
struct ucounts *ucounts;
5050
int err;
5151

52-
err = -ENFILE;
52+
err = -ENOSPC;
5353
ucounts = inc_uts_namespaces(user_ns);
5454
if (!ucounts)
5555
goto fail;

‎net/core/net_namespace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ struct net *copy_net_ns(unsigned long flags,
370370

371371
ucounts = inc_net_namespaces(user_ns);
372372
if (!ucounts)
373-
return ERR_PTR(-ENFILE);
373+
return ERR_PTR(-ENOSPC);
374374

375375
net = net_alloc();
376376
if (!net) {

0 commit comments

Comments
 (0)