mirror of
https://github.com/Qortal/Brooklyn.git
synced 2025-01-30 23:02:18 +00:00
2a709f28fa
* 0day explit mitigation * Memory corruption prevention * Privilege escalation prevention * Buffer over flow prevention * File System corruption defense * Thread escape prevention This may very well be the most intensive inclusion to BrooklynR. This will not be part of an x86 suite nor it will be released as tool kit. The security core toolkit will remain part of kernel base.
41 lines
975 B
C
41 lines
975 B
C
#include <linux/kernel.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/file.h>
|
|
#include <linux/ipc.h>
|
|
#include <linux/gracl.h>
|
|
#include <linux/grsecurity.h>
|
|
#include <linux/grinternal.h>
|
|
|
|
int
|
|
gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
|
|
const u64 shm_createtime, const kuid_t cuid, const int shmid)
|
|
{
|
|
struct task_struct *task;
|
|
|
|
if (!gr_acl_is_enabled())
|
|
return 1;
|
|
|
|
rcu_read_lock();
|
|
read_lock(&tasklist_lock);
|
|
|
|
task = find_task_by_vpid(shm_cprid);
|
|
|
|
if (unlikely(!task))
|
|
task = find_task_by_vpid(shm_lapid);
|
|
|
|
if (unlikely(task && (time_before_eq64(task->start_time, shm_createtime) ||
|
|
(task_pid_nr(task) == shm_lapid)) &&
|
|
(task->acl->mode & GR_PROTSHM) &&
|
|
(task->acl != current->acl))) {
|
|
read_unlock(&tasklist_lock);
|
|
rcu_read_unlock();
|
|
gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
|
|
return 0;
|
|
}
|
|
read_unlock(&tasklist_lock);
|
|
rcu_read_unlock();
|
|
|
|
return 1;
|
|
}
|