aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/security.h9
-rw-r--r--kernel/fork.c1
-rw-r--r--security/capability.c5
-rw-r--r--security/security.c5
4 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/security.h b/include/linux/security.h
index 83c18e8c846d..8325eddd9ee4 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -651,6 +651,10 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
651 * manual page for definitions of the @clone_flags. 651 * manual page for definitions of the @clone_flags.
652 * @clone_flags contains the flags indicating what should be shared. 652 * @clone_flags contains the flags indicating what should be shared.
653 * Return 0 if permission is granted. 653 * Return 0 if permission is granted.
654 * @task_free:
655 * @task task being freed
656 * Handle release of task-related resources. (Note that this can be called
657 * from interrupt context.)
654 * @cred_alloc_blank: 658 * @cred_alloc_blank:
655 * @cred points to the credentials. 659 * @cred points to the credentials.
656 * @gfp indicates the atomicity of any memory allocations. 660 * @gfp indicates the atomicity of any memory allocations.
@@ -1493,6 +1497,7 @@ struct security_operations {
1493 int (*dentry_open) (struct file *file, const struct cred *cred); 1497 int (*dentry_open) (struct file *file, const struct cred *cred);
1494 1498
1495 int (*task_create) (unsigned long clone_flags); 1499 int (*task_create) (unsigned long clone_flags);
1500 void (*task_free) (struct task_struct *task);
1496 int (*cred_alloc_blank) (struct cred *cred, gfp_t gfp); 1501 int (*cred_alloc_blank) (struct cred *cred, gfp_t gfp);
1497 void (*cred_free) (struct cred *cred); 1502 void (*cred_free) (struct cred *cred);
1498 int (*cred_prepare)(struct cred *new, const struct cred *old, 1503 int (*cred_prepare)(struct cred *new, const struct cred *old,
@@ -1752,6 +1757,7 @@ int security_file_send_sigiotask(struct task_struct *tsk,
1752int security_file_receive(struct file *file); 1757int security_file_receive(struct file *file);
1753int security_dentry_open(struct file *file, const struct cred *cred); 1758int security_dentry_open(struct file *file, const struct cred *cred);
1754int security_task_create(unsigned long clone_flags); 1759int security_task_create(unsigned long clone_flags);
1760void security_task_free(struct task_struct *task);
1755int security_cred_alloc_blank(struct cred *cred, gfp_t gfp); 1761int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
1756void security_cred_free(struct cred *cred); 1762void security_cred_free(struct cred *cred);
1757int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp); 1763int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
@@ -2245,6 +2251,9 @@ static inline int security_task_create(unsigned long clone_flags)
2245 return 0; 2251 return 0;
2246} 2252}
2247 2253
2254static inline void security_task_free(struct task_struct *task)
2255{ }
2256
2248static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp) 2257static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
2249{ 2258{
2250 return 0; 2259 return 0;
diff --git a/kernel/fork.c b/kernel/fork.c
index 1b2ef3c23ae4..f0e7781ba9b4 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -192,6 +192,7 @@ void __put_task_struct(struct task_struct *tsk)
192 WARN_ON(atomic_read(&tsk->usage)); 192 WARN_ON(atomic_read(&tsk->usage));
193 WARN_ON(tsk == current); 193 WARN_ON(tsk == current);
194 194
195 security_task_free(tsk);
195 exit_creds(tsk); 196 exit_creds(tsk);
196 delayacct_tsk_free(tsk); 197 delayacct_tsk_free(tsk);
197 put_signal_struct(tsk->signal); 198 put_signal_struct(tsk->signal);
diff --git a/security/capability.c b/security/capability.c
index 2f680eb02b59..5bb21b1c448c 100644
--- a/security/capability.c
+++ b/security/capability.c
@@ -358,6 +358,10 @@ static int cap_task_create(unsigned long clone_flags)
358 return 0; 358 return 0;
359} 359}
360 360
361static void cap_task_free(struct task_struct *task)
362{
363}
364
361static int cap_cred_alloc_blank(struct cred *cred, gfp_t gfp) 365static int cap_cred_alloc_blank(struct cred *cred, gfp_t gfp)
362{ 366{
363 return 0; 367 return 0;
@@ -954,6 +958,7 @@ void __init security_fixup_ops(struct security_operations *ops)
954 set_to_cap_if_null(ops, file_receive); 958 set_to_cap_if_null(ops, file_receive);
955 set_to_cap_if_null(ops, dentry_open); 959 set_to_cap_if_null(ops, dentry_open);
956 set_to_cap_if_null(ops, task_create); 960 set_to_cap_if_null(ops, task_create);
961 set_to_cap_if_null(ops, task_free);
957 set_to_cap_if_null(ops, cred_alloc_blank); 962 set_to_cap_if_null(ops, cred_alloc_blank);
958 set_to_cap_if_null(ops, cred_free); 963 set_to_cap_if_null(ops, cred_free);
959 set_to_cap_if_null(ops, cred_prepare); 964 set_to_cap_if_null(ops, cred_prepare);
diff --git a/security/security.c b/security/security.c
index d7542493454d..7d9426bb7442 100644
--- a/security/security.c
+++ b/security/security.c
@@ -729,6 +729,11 @@ int security_task_create(unsigned long clone_flags)
729 return security_ops->task_create(clone_flags); 729 return security_ops->task_create(clone_flags);
730} 730}
731 731
732void security_task_free(struct task_struct *task)
733{
734 security_ops->task_free(task);
735}
736
732int security_cred_alloc_blank(struct cred *cred, gfp_t gfp) 737int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
733{ 738{
734 return security_ops->cred_alloc_blank(cred, gfp); 739 return security_ops->cred_alloc_blank(cred, gfp);