[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <20171214220012.10103-4-k.opasiak@samsung.com>
Date: Thu, 14 Dec 2017 23:00:11 +0100
From: Krzysztof Opasiak <k.opasiak@...sung.com>
To: gregkh@...uxfoundation.org, viro@...iv.linux.org.uk, arnd@...db.de
Cc: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-arch@...r.kernel.org, k.lewandowsk@...sung.com,
l.stelmach@...sung.com, p.szewczyk@...sung.com,
Krzysztof Opasiak <k.opasiak@...sung.com>
Subject: [RFC PATCH v2 3/4] Connect rlimit-events with process life cycle
Add rlimit-events call to process lifecycle to ensure that
we get notified whenever process dies (to cleanup our watch
levels) or forks (to implement watch levels inheritance).
Signed-off-by: Krzysztof Opasiak <k.opasiak@...sung.com>
---
kernel/exit.c | 3 +++
kernel/fork.c | 11 ++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/kernel/exit.c b/kernel/exit.c
index f6cad39f35df..d3b9e1b854a3 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -62,6 +62,7 @@
#include <linux/random.h>
#include <linux/rcuwait.h>
#include <linux/compat.h>
+#include <linux/rlimit_noti.h>
#include <linux/uaccess.h>
#include <asm/unistd.h>
@@ -846,6 +847,8 @@ void __noreturn do_exit(long code)
tty_audit_exit();
audit_free(tsk);
+ rlimit_noti_task_exit(tsk);
+
tsk->exit_code = code;
taskstats_exit(tsk, group_dead);
diff --git a/kernel/fork.c b/kernel/fork.c
index e54684b63c08..77bbac0bdfe9 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -100,6 +100,8 @@
#include <trace/events/sched.h>
+#include <linux/rlimit_noti.h>
+
#define CREATE_TRACE_POINTS
#include <trace/events/task.h>
@@ -1389,6 +1391,7 @@ static inline void posix_cpu_timers_init_group(struct signal_struct *sig) { }
static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
{
struct signal_struct *sig;
+ int ret;
if (clone_flags & CLONE_THREAD)
return 0;
@@ -1419,9 +1422,15 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
#endif
task_lock(current->group_leader);
- memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim);
+ memcpy(sig->rlim, current->signal->rlim, sizeof(sig->rlim));
task_unlock(current->group_leader);
+ ret = rlimit_noti_task_fork(current->group_leader, tsk);
+ if (ret) {
+ kmem_cache_free(signal_cachep, sig);
+ return ret;
+ }
+
posix_cpu_timers_init_group(sig);
tty_audit_fork(sig);
--
2.9.3
Powered by blists - more mailing lists