cgroup: Fix task counter common ancestor logic
Subsystems (2)
PATCH 1/1 cgroup: Fix task counter common ancestor logic
The task counter subsystem has been written assuming that can_attach_task/attach_task/cancel_attach_task calls are serialized per task. This is true when we attach only one task but not when we attach a whole thread group, in which case the sequence is:
for each thread if (can_attach_task() < 0) goto rollback for each_thread attach_task()
rollback:
for each thread
cancel_attach_task()
The common ancestor, searched on task_counter_attach_task(), can thus change between each of these calls for a given task. This breaks if some tasks in the thread group are not in the same cgroup origin. The uncharge made in attach_task() or the rollback in cancel_attach_task() there would have an erroneous propagation.
This can even break seriously is some scenario. For example there with $PID beeing the pid of a multithread process:
mkdir /dev/cgroup/cgroup0
echo $PID > /dev/cgroup/cgroup0/cgroup.procs echo $PID > /dev/cgroup/tasks
echo $PID > /dev/cgroup/cgroup0/cgroup.procs
On the last move, attach_task() is called on the thread leader with the wrong common_ancestor, leading to a crash because we uncharge a res_counter that doesn't exist:
[ 149.805063] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 [ 149.806013] IP: [<ffffffff810a0172>] __lock_acquire+0x62/0x15d0 [ 149.806013] PGD 51d38067 PUD 5119e067 PMD 0 [ 149.806013] Oops: 0000 [#1] PREEMPT SMP [ 149.806013] Dumping ftrace buffer: [ 149.806013] (ftrace buffer empty) [ 149.806013] CPU 3 [ 149.806013] Modules linked in: [ 149.806013] [ 149.806013] Pid: 1111, comm: spread_thread_g Not tainted 3.1.0-rc3+ #165 FUJITSU SIEMENS AMD690VM-FMH/AMD690VM-FMH [ 149.806013] RIP: 0010:[<ffffffff810a0172>] [<ffffffff810a0172>] __lock_acquire+0x62/0x15d0 [ 149.806013] RSP: 0018:ffff880051479b38 EFLAGS: 00010046 [ 149.806013] RAX: 0000000000000046 RBX: 0000000000000040 RCX: 0000000000000000 [ 149.868002] RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000000000000040 [ 149.868002] RBP: ffff880051479c08 R08: 0000000000000002 R09: 0000000000000001 [ 149.868002] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000002 [ 149.868002] R13: 0000000000000000 R14: 0000000000000000 R15: ffff880051f120a0 [ 149.868002] FS: 00007f1e01dd7700(0000) GS:ffff880057d80000(0000) knlGS:0000000000000000 [ 149.868002] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 149.868002] CR2: 0000000000000040 CR3: 0000000051c59000 CR4: 00000000000006e0 [ 149.868002] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 149.868002] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 149.868002] Process spread_thread_g (pid: 1111, threadinfo ffff880051478000, task ffff880051f120a0) [ 149.868002] Stack: [ 149.868002] 0000000000000000 0000000000000000 0000000000000000 0000000000000000 [ 149.868002] 0000000000000000 0000000000000000 0000000000000000 0000000000000000 [ 149.868002] 0000000000000000 0000000000000000 0000000000000000 0000000000000000 [ 149.868002] Call Trace: [ 149.868002] [<ffffffff810a1d32>] lock_acquire+0xa2/0x1a0 [ 149.868002] [<ffffffff810c373c>] ? res_counter_uncharge_until+0x4c/0xb0 [ 149.868002] [<ffffffff8180802b>] _raw_spin_lock+0x3b/0x50 [ 149.868002] [<ffffffff810c373c>] ? res_counter_uncharge_until+0x4c/0xb0 [ 149.868002] [<ffffffff810c373c>] res_counter_uncharge_until+0x4c/0xb0 [ 149.868002] [<ffffffff810c26c4>] task_counter_attach_task+0x44/0x50 [ 149.868002] [<ffffffff810bffcd>] cgroup_attach_proc+0x5ad/0x720 [ 149.868002] [<ffffffff810bfa99>] ? cgroup_attach_proc+0x79/0x720 [ 149.868002] [<ffffffff810c01cf>] attach_task_by_pid+0x8f/0x220 [ 149.868002] [<ffffffff810c0230>] ? attach_task_by_pid+0xf0/0x220 [ 149.868002] [<ffffffff810c0230>] ? attach_task_by_pid+0xf0/0x220 [ 149.868002] [<ffffffff810c0388>] cgroup_procs_write+0x28/0x40 [ 149.868002] [<ffffffff810c0bd9>] cgroup_file_write+0x209/0x2f0 [ 149.868002] [<ffffffff812b8d08>] ? apparmor_file_permission+0x18/0x20 [ 149.868002] [<ffffffff8127ef43>] ? security_file_permission+0x23/0x90 [ 149.868002] [<ffffffff81157038>] vfs_write+0xc8/0x190 [ 149.868002] [<ffffffff811571f1>] sys_write+0x51/0x90 [ 149.868002] [<ffffffff818102c2>] system_call_fastpath+0x16/0x1b
To solve this, keep the original cgroup of each thread in the thread group cached in the flex array and pass it to can_attach_task()/attach_task() and cancel_attach_task() so that the correct common ancestor between the old and new cgroup can be safely retrieved for each task.
This is inspired by a previous patch from Li Zefan:
"[PATCH] cgroups: don't cache common ancestor in task counter subsys".
--- Documentation/cgroups/cgroups.txt | 3 +- include/linux/cgroup.h | 2 +- kernel/cgroup.c | 48 ++++++++++++++++++++++-------------- kernel/cgroup_task_counter.c | 26 +++++++++++-------- 4 files changed, 47 insertions(+), 32 deletions(-)
Documentation/cgroups/cgroups.txt +2 -1
@@ -623,7 +623,8 @@ function, so that the subsystem can implement a rollback. If not, not necessary. This will be called only about subsystems whose can_attach() operation have succeeded. -void cancel_attach_task(struct cgroup *cgrp, struct task_struct *tsk) +void cancel_attach_task(struct cgroup *cgrp, struct cgroup *old_cgrp, + struct task_struct *tsk) (cgroup_mutex held by caller) As cancel_attach, but for operations that must be cancelled once per
include/linux/cgroup.h +1 -1
@@ -475,7 +475,7 @@ struct cgroup_subsys { struct task_struct *tsk);void (*cancel_attach)(struct cgroup_subsys *ss,struct cgroup *cgrp,struct task_struct *tsk); -void (*cancel_attach_task)(struct cgroup *cgrp, +void (*cancel_attach_task)(struct cgroup *cgrp,struct cgroup *old_cgrp,struct task_struct *tsk);void (*pre_attach)(struct cgroup *cgrp); void (*attach_task)(struct cgroup *cgrp, struct cgroup *old_cgrp,
kernel/cgroup.c +29 -19
127 lines not on this page · raw message
kernel/cgroup_task_counter.c +15 -11
@@ -95,12 +95,6 @@ static void task_counter_exit(struct cgroup_subsys *ss, struct cgroup *cgrp, }/* -* Protected amongst can_attach_task/attach_task/cancel_attach_task by -* cgroup mutex -*/ -static struct res_counter *common_ancestor; - -/* * This does more than just probing the ability to attach to the dest cgroup. * We can not just _check_ if we can attach to the destination and do the real * attachment later in task_counter_attach_task() because a task in the dest
@@ -111,9 +105,10 @@ static int task_counter_can_attach_task(struct cgroup *cgrp,struct cgroup *old_cgrp, struct task_struct *tsk) { + int err; +struct res_counter *common_ancestor;struct res_counter *res =cgroup_task_res_counter (cgrp);struct res_counter *old_res =cgroup_task_res_counter (old_cgrp); -int err;/* * When moving a task from a cgroup to another, we don't want
@@ -138,10 +133,15 @@ static int task_counter_can_attach_task(struct cgroup *cgrp,/* Uncharge the dest cgroup that we charged in task_counter_can_attach_task() */ static void task_counter_cancel_attach_task (struct cgroup *cgrp, +struct cgroup *old_cgrp,struct task_struct *tsk) { -res_counter_uncharge_until (cgroup_task_res_counter (cgrp), - common_ancestor,1 ); +struct res_counter *common_ancestor; +struct res_counter *res =cgroup_task_res_counter (cgrp); +struct res_counter *old_res =cgroup_task_res_counter (old_cgrp); + + common_ancestor =res_counter_common_ancestor (res, old_res); +res_counter_uncharge_until (res, common_ancestor,1 ); }/*
@@ -155,8 +155,12 @@ static void task_counter_attach_task(struct cgroup *cgrp,struct cgroup *old_cgrp, struct task_struct *tsk) { -res_counter_uncharge_until (cgroup_task_res_counter (old_cgrp ), - common_ancestor, 1); + struct res_counter *common_ancestor; +struct res_counter *res =cgroup_task_res_counter (cgrp); +struct res_counter *old_res =cgroup_task_res_counter (old_cgrp); + + common_ancestor =res_counter_common_ancestor (res, old_res); +res_counter_uncharge_until (old_res, common_ancestor,1 ); }static u64 task_counter_read_u64 (struct cgroup *cgrp,struct cftype *cft)
Signature · 1 line
1.7.5.4
Quoted 4 lines · On Tue, 8 Nov 2011 16:21:10 +0100 Frederic Weisbecker…
To solve this, keep the original cgroup of each thread in the thread group cached in the flex array and pass it to can_attach_task()/attach_task() and
cancel_attach_task()so that the correct common ancestor between the old and new cgroup can be safely retrieved for each task.
OK, thanks.
We need to work out what to do with this patchset. ie: should we merge it. I'm not sure that the case has been made?
Let's please drag this thing onto the table and poke at it for a while. Probably everyone has forgotten everything so we'll need to start again, sorry. Perhaps you can (re)start proceedings by telling us why it's useful to our users and why we should merge it?
Some mental notes:
Tim says it would be useful for the things he's doing but doesn't appear to have confirmed/tested that.
Kay has said that it would not be useful for his plumber's wishlist item, which is a shame.
I seem to recall complaining that it doesn't address the forkbomb issue for non-cgroups setups, so the forkbomb issue remains unaddressed.
Quoted 8 lines · On Tue, 8 Nov 2011 13:51:11 -0800 Andrew Morton…
Quoted 4 lines · On Tue, 8 Nov 2011 16:21:10 +0100 Frederic Weisbecker…
To solve this, keep the original cgroup of each thread in the thread group cached in the flex array and pass it to can_attach_task()/attach_task() and
cancel_attach_task()so that the correct common ancestor between the old and new cgroup can be safely retrieved for each task.
Quoted 5 lines
OK, thanks.
We need to work out what to do with this patchset. ie: should we merge it. I'm not sure that the case has been made?
My impression is positive....but as other guy proposed, I feel fork-limit should be useful, too. It allows to limit or rate-limit the number of fork(). So, I wonder some fork-limit can be implemented in this task_counter cgroup.
Quoted 5 lines
Let's please drag this thing onto the table and poke at it for a while. Probably everyone has forgotten everything so we'll need to start again, sorry. Perhaps you can (re)start proceedings by telling us why it's useful to our users and why we should merge it?
please ;)
Quoted 11 lines
Some mental notes:
Tim says it would be useful for the things he's doing but doesn't appear to have confirmed/tested that.
Kay has said that it would not be useful for his plumber's wishlist item, which is a shame.
I seem to recall complaining that it doesn't address the forkbomb issue for non-cgroups setups, so the forkbomb issue remains unaddressed.
For non-cgroup fork-bomb, I and Minchan proposed forkbomb-killer (in independent way). I stop it now but if someone has interests, I recall it from grave.
Thanks,
-Kame
Quoted 10 lines · Andrew Morton
Quoted 4 lines · On Tue, 8 Nov 2011 16:21:10 +0100 Frederic Weisbecker…
To solve this, keep the original cgroup of each thread in the thread group cached in the flex array and pass it to can_attach_task()/attach_task() and
cancel_attach_task()so that the correct common ancestor between the old and new cgroup can be safely retrieved for each task.OK, thanks.
Quoted 7 lines
We need to work out what to do with this patchset. ie: should we merge it. I'm not sure that the case has been made?
Let's please drag this thing onto the table and poke at it for a while. Probably everyone has forgotten everything so we'll need to start again, sorry. Perhaps you can (re)start proceedings by telling us why it's useful to our users and why we should merge it?
Right, so the main purpose is to have a suitable forkbomb protection in the lxc containers. It seems that these days, using NR_PROC rlimit is the prime choice to protect against forkbombs. But we can't use this for containers because if they run under the same user, they can starve each others by generating high number of processes. So we need the limit on number of processes to be per container.
The basic requirement is to be able to run untrustee process inside a container while protecting against attacks from there without impacting the rest of the system.
I'm adding in Cc some Lxc people who could perhaps provide more details and testify we really need this.
Quoted 4 lines
Some mental notes:
Tim says it would be useful for the things he's doing but doesn't appear to have confirmed/tested that.
Yeah, I'm waiting for more details from him. Tim?
Quoted 2 lines
Kay has said that it would not be useful for his plumber's wishlist item, which is a shame.
Indeed. I mean it would work but this cgroup subsystem is too much overhead to be used by an init process (and then all other processes).
Quoted 2 lines
I seem to recall complaining that it doesn't address the forkbomb issue for non-cgroups setups, so the forkbomb issue remains unaddressed.
Right. Now if we can find a generic solution to protect against all forkbombs, something deterministic that can react soon enough so that it doesn't impact the rest of system, in order to avoid running into some DDOS, then we will consider it.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe cgroups" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Andrew Morton
Quoted 4 lines · On Tue, 8 Nov 2011 16:21:10 +0100 Frederic Weisbecker…
To solve this, keep the original cgroup of each thread in the thread group cached in the flex array and pass it to can_attach_task()/attach_task() and
cancel_attach_task()so that the correct common ancestor between the old and new cgroup can be safely retrieved for each task.OK, thanks.
Quoted 7 lines
We need to work out what to do with this patchset. ie: should we merge it. I'm not sure that the case has been made?
Let's please drag this thing onto the table and poke at it for a while. Probably everyone has forgotten everything so we'll need to start again, sorry. Perhaps you can (re)start proceedings by telling us why it's useful to our users and why we should merge it?
Right, so the main purpose is to have a suitable forkbomb protection in the lxc containers. It seems that these days, using NR_PROC rlimit is the prime choice to protect against forkbombs. But we can't use this for containers because if they run under the same user, they can starve each others by generating high number of processes. So we need the limit on number of processes to be per container.
The basic requirement is to be able to run untrustee process inside a container while protecting against attacks from there without impacting the rest of the system.
I'm adding in Cc some Lxc people who could perhaps provide more details and testify we really need this.
Quoted 4 lines
Some mental notes:
Tim says it would be useful for the things he's doing but doesn't appear to have confirmed/tested that.
Yeah, I'm waiting for more details from him. Tim?
Quoted 2 lines
Kay has said that it would not be useful for his plumber's wishlist item, which is a shame.
Indeed. I mean it would work but this cgroup subsystem is too much overhead to be used by an init process (and then all other processes).
Quoted 2 lines
I seem to recall complaining that it doesn't address the forkbomb issue for non-cgroups setups, so the forkbomb issue remains unaddressed.
Right. Now if we can find a generic solution to protect against all forkbombs, something deterministic that can react soon enough so that it doesn't impact the rest of system, in order to avoid running into some DDOS, then we will consider it.
Thanks.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 54 lines · Frederic Weisbecker
Quoted 11 lines · Andrew Morton
Quoted 5 lines · On Tue, 8 Nov 2011 16:21:10 +0100 Frederic Weisbecker…
To solve this, keep the original cgroup of each thread in the thread group cached in the flex array and pass it to can_attach_task()/attach_task() and
cancel_attach_task()so that the correct common ancestor between the old and new cgroup can be safely retrieved for each task.OK, thanks.
Quoted 8 lines
We need to work out what to do with this patchset. ie: should we merge it. I'm not sure that the case has been made?
Let's please drag this thing onto the table and poke at it for a while. Probably everyone has forgotten everything so we'll need to start again, sorry. Perhaps you can (re)start proceedings by telling us why it's useful to our users and why we should merge it?
Right, so the main purpose is to have a suitable forkbomb protection in the lxc containers. It seems that these days, using
NR_PROCrlimit is the prime choice to protect against forkbombs. But we can't use this for containers because if they run under the same user, they can starve each others by generating high number of processes. So we need the limit on number of processes to be per container.The basic requirement is to be able to run untrustee process inside a container while protecting against attacks from there without impacting the rest of the system.
I'm adding in Cc some Lxc people who could perhaps provide more details and testify we really need this.
Quoted 4 lines
Some mental notes:
Tim says it would be useful for the things he's doing but doesn't appear to have confirmed/tested that.
Yeah, I'm waiting for more details from him. Tim?
Quoted 2 lines
Kay has said that it would not be useful for his plumber's wishlist item, which is a shame.
Indeed. I mean it would work but this cgroup subsystem is too much overhead to be used by an init process (and then all other processes).
Quoted 3 lines
I seem to recall complaining that it doesn't address the forkbomb issue for non-cgroups setups, so the forkbomb issue remains unaddressed.
Quoted 6 lines
Right. Now if we can find a generic solution to protect against all forkbombs, something deterministic that can react soon enough so that it doesn't impact the rest of system, in order to avoid running into some DDOS, then we will consider it.
Thanks.
I have heard that this is being held up because of a lack of justification. Here is my attempt. I would like to use the ability to prevent a fork bomb and guaranteed killall for three different tools that I work on.
1. Kiosk/xguest user. Currently we tell people to log out of a system on the kiosk and the pam stack attempts to kill all processes running in the kiosk user session. The kiosk user is not allowed to login to the system if a process is still running as the user. The reason for this is we want to guarantee no previous user left a trojan process waiting to track your activity. If the login program can not kill all user processes at logout, then the next user will not be able to login.
2. Sandbox Desktop tools are used to write one or more processes within a lockeddown environment. The idea here is to run untrusted code and potentially this code could trigger a fork bomb, you want to be able to kill the session.
3. Secure containers, similarly to sandboxes allow users to run multiple Linux Containers in a locked down manner. We would like to be guaranteed that we can kill all processes within a secure containers at exit.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk7nuSYACgkQrlYvE4MpobMY1ACgmZ/P8LbVTHBrOQUsh6xL5Qy2 scsAoK641lrpZkX8DB1JETpKT6jfWe5i
=E93Z
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe cgroups" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 54 lines · Frederic Weisbecker
Quoted 11 lines · Andrew Morton
Quoted 5 lines · On Tue, 8 Nov 2011 16:21:10 +0100 Frederic Weisbecker…
To solve this, keep the original cgroup of each thread in the thread group cached in the flex array and pass it to can_attach_task()/attach_task() and
cancel_attach_task()so that the correct common ancestor between the old and new cgroup can be safely retrieved for each task.OK, thanks.
Quoted 8 lines
We need to work out what to do with this patchset. ie: should we merge it. I'm not sure that the case has been made?
Let's please drag this thing onto the table and poke at it for a while. Probably everyone has forgotten everything so we'll need to start again, sorry. Perhaps you can (re)start proceedings by telling us why it's useful to our users and why we should merge it?
Right, so the main purpose is to have a suitable forkbomb protection in the lxc containers. It seems that these days, using
NR_PROCrlimit is the prime choice to protect against forkbombs. But we can't use this for containers because if they run under the same user, they can starve each others by generating high number of processes. So we need the limit on number of processes to be per container.The basic requirement is to be able to run untrustee process inside a container while protecting against attacks from there without impacting the rest of the system.
I'm adding in Cc some Lxc people who could perhaps provide more details and testify we really need this.
Quoted 4 lines
Some mental notes:
Tim says it would be useful for the things he's doing but doesn't appear to have confirmed/tested that.
Yeah, I'm waiting for more details from him. Tim?
Quoted 2 lines
Kay has said that it would not be useful for his plumber's wishlist item, which is a shame.
Indeed. I mean it would work but this cgroup subsystem is too much overhead to be used by an init process (and then all other processes).
Quoted 3 lines
I seem to recall complaining that it doesn't address the forkbomb issue for non-cgroups setups, so the forkbomb issue remains unaddressed.
Quoted 6 lines
Right. Now if we can find a generic solution to protect against all forkbombs, something deterministic that can react soon enough so that it doesn't impact the rest of system, in order to avoid running into some DDOS, then we will consider it.
Thanks.
I have heard that this is being held up because of a lack of justification. Here is my attempt. I would like to use the ability to prevent a fork bomb and guaranteed killall for three different tools that I work on.
1. Kiosk/xguest user. Currently we tell people to log out of a system on the kiosk and the pam stack attempts to kill all processes running in the kiosk user session. The kiosk user is not allowed to login to the system if a process is still running as the user. The reason for this is we want to guarantee no previous user left a trojan process waiting to track your activity. If the login program can not kill all user processes at logout, then the next user will not be able to login.
2. Sandbox Desktop tools are used to write one or more processes within a lockeddown environment. The idea here is to run untrusted code and potentially this code could trigger a fork bomb, you want to be able to kill the session.
3. Secure containers, similarly to sandboxes allow users to run multiple Linux Containers in a locked down manner. We would like to be guaranteed that we can kill all processes within a secure containers at exit.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk7nuSYACgkQrlYvE4MpobMY1ACgmZ/P8LbVTHBrOQUsh6xL5Qy2 scsAoK641lrpZkX8DB1JETpKT6jfWe5i
=E93Z
-----END PGP SIGNATURE-----
Quoted 85 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 54 lines · Frederic Weisbecker
Quoted 11 lines · Andrew Morton
Quoted 5 lines · On Tue, 8 Nov 2011 16:21:10 +0100 Frederic Weisbecker…
To solve this, keep the original cgroup of each thread in the thread group cached in the flex array and pass it to can_attach_task()/attach_task() and
cancel_attach_task()so that the correct common ancestor between the old and new cgroup can be safely retrieved for each task.OK, thanks.
Quoted 8 lines
We need to work out what to do with this patchset. ie: should we merge it. I'm not sure that the case has been made?
Let's please drag this thing onto the table and poke at it for a while. Probably everyone has forgotten everything so we'll need to start again, sorry. Perhaps you can (re)start proceedings by telling us why it's useful to our users and why we should merge it?
Right, so the main purpose is to have a suitable forkbomb protection in the lxc containers. It seems that these days, using
NR_PROCrlimit is the prime choice to protect against forkbombs. But we can't use this for containers because if they run under the same user, they can starve each others by generating high number of processes. So we need the limit on number of processes to be per container.The basic requirement is to be able to run untrustee process inside a container while protecting against attacks from there without impacting the rest of the system.
I'm adding in Cc some Lxc people who could perhaps provide more details and testify we really need this.
Quoted 4 lines
Some mental notes:
Tim says it would be useful for the things he's doing but doesn't appear to have confirmed/tested that.
Yeah, I'm waiting for more details from him. Tim?
Quoted 2 lines
Kay has said that it would not be useful for his plumber's wishlist item, which is a shame.
Indeed. I mean it would work but this cgroup subsystem is too much overhead to be used by an init process (and then all other processes).
Quoted 3 lines
I seem to recall complaining that it doesn't address the forkbomb issue for non-cgroups setups, so the forkbomb issue remains unaddressed.
Quoted 6 lines
Right. Now if we can find a generic solution to protect against all forkbombs, something deterministic that can react soon enough so that it doesn't impact the rest of system, in order to avoid running into some DDOS, then we will consider it.
Thanks.
I have heard that this is being held up because of a lack of justification. Here is my attempt. I would like to use the ability to prevent a fork bomb and guaranteed killall for three different tools that I work on.
1. Kiosk/xguest user. Currently we tell people to log out of a system on the kiosk and the pam stack attempts to kill all processes running in the kiosk user session. The kiosk user is not allowed to login to the system if a process is still running as the user. The reason for this is we want to guarantee no previous user left a trojan process waiting to track your activity. If the login program can not kill all user processes at logout, then the next user will not be able to login.
2. Sandbox Desktop tools are used to write one or more processes within a lockeddown environment. The idea here is to run untrusted code and potentially this code could trigger a fork bomb, you want to be able to kill the session.
Quoted 4 lines
3. Secure containers, similarly to sandboxes allow users to run multiple Linux Containers in a locked down manner. We would like to be guaranteed that we can kill all processes within a secure containers at exit.
More generally when libvirt uses the kernel's namespace+cgroups support to spawn the LXC container, we want to be able to put an upper bound on the number of process an individual container can run. The existing RLIMIT_NPROC doesn't work, because you can get multiple containers running processes with the same real UID, and each container can also run processes under different real UIDs. libvirt places each container created inside a dedicated cgroups, for the purpose of resource control, so task limits attached to cgroups easily lets us limit per-container process creation.
Regards,
Daniel
Signature · 8 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- To unsubscribe from this list: send the line "unsubscribe cgroups" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 85 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 54 lines · Frederic Weisbecker
Quoted 11 lines · Andrew Morton
Quoted 5 lines · On Tue, 8 Nov 2011 16:21:10 +0100 Frederic Weisbecker…
To solve this, keep the original cgroup of each thread in the thread group cached in the flex array and pass it to can_attach_task()/attach_task() and
cancel_attach_task()so that the correct common ancestor between the old and new cgroup can be safely retrieved for each task.OK, thanks.
Quoted 8 lines
We need to work out what to do with this patchset. ie: should we merge it. I'm not sure that the case has been made?
Let's please drag this thing onto the table and poke at it for a while. Probably everyone has forgotten everything so we'll need to start again, sorry. Perhaps you can (re)start proceedings by telling us why it's useful to our users and why we should merge it?
Right, so the main purpose is to have a suitable forkbomb protection in the lxc containers. It seems that these days, using
NR_PROCrlimit is the prime choice to protect against forkbombs. But we can't use this for containers because if they run under the same user, they can starve each others by generating high number of processes. So we need the limit on number of processes to be per container.The basic requirement is to be able to run untrustee process inside a container while protecting against attacks from there without impacting the rest of the system.
I'm adding in Cc some Lxc people who could perhaps provide more details and testify we really need this.
Quoted 4 lines
Some mental notes:
Tim says it would be useful for the things he's doing but doesn't appear to have confirmed/tested that.
Yeah, I'm waiting for more details from him. Tim?
Quoted 2 lines
Kay has said that it would not be useful for his plumber's wishlist item, which is a shame.
Indeed. I mean it would work but this cgroup subsystem is too much overhead to be used by an init process (and then all other processes).
Quoted 3 lines
I seem to recall complaining that it doesn't address the forkbomb issue for non-cgroups setups, so the forkbomb issue remains unaddressed.
Quoted 6 lines
Right. Now if we can find a generic solution to protect against all forkbombs, something deterministic that can react soon enough so that it doesn't impact the rest of system, in order to avoid running into some DDOS, then we will consider it.
Thanks.
I have heard that this is being held up because of a lack of justification. Here is my attempt. I would like to use the ability to prevent a fork bomb and guaranteed killall for three different tools that I work on.
1. Kiosk/xguest user. Currently we tell people to log out of a system on the kiosk and the pam stack attempts to kill all processes running in the kiosk user session. The kiosk user is not allowed to login to the system if a process is still running as the user. The reason for this is we want to guarantee no previous user left a trojan process waiting to track your activity. If the login program can not kill all user processes at logout, then the next user will not be able to login.
2. Sandbox Desktop tools are used to write one or more processes within a lockeddown environment. The idea here is to run untrusted code and potentially this code could trigger a fork bomb, you want to be able to kill the session.
Quoted 4 lines
3. Secure containers, similarly to sandboxes allow users to run multiple Linux Containers in a locked down manner. We would like to be guaranteed that we can kill all processes within a secure containers at exit.
More generally when libvirt uses the kernel's namespace+cgroups support to spawn the LXC container, we want to be able to put an upper bound on the number of process an individual container can run. The existing RLIMIT_NPROC doesn't work, because you can get multiple containers running processes with the same real UID, and each container can also run processes under different real UIDs. libvirt places each container created inside a dedicated cgroups, for the purpose of resource control, so task limits attached to cgroups easily lets us limit per-container process creation.
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|