summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrIng <labs@cyring.fr>2020-05-28 09:18:52 +0200
committerCyrIng <labs@cyring.fr>2020-05-28 09:18:52 +0200
commita13268d919e421508243143412382089a0e597d2 (patch)
tree8793f13f2675bb65314df56b0ccdfa7bae538fa3
parent3d57a7db02b34f32ce412f9d25f8e174758ed378 (diff)
Preliminary Hardening impacts.1.77
-rw-r--r--corefreqd.c6
-rw-r--r--corefreqk.c137
2 files changed, 66 insertions, 77 deletions
diff --git a/corefreqd.c b/corefreqd.c
index bab1c9a..ce56cd5 100644
--- a/corefreqd.c
+++ b/corefreqd.c
@@ -1196,7 +1196,9 @@ void Architecture(SHM_STRUCT *Shm, PROC *Proc)
aTSC = Proc->Features.AdvPower.EDX.Inv_TSC;
/* Copy all initial CPUID features. */
-/*TODO: Proc->Features.ExtInfo.EDX._3DNow=1; TODO( Hardening ) */
+/*TODO(Hardening Example)
+ memcpy(Proc->Architecture, "Chappie Processor", 17);
+*/
memcpy(&Shm->Proc.Features, &Proc->Features, sizeof(FEATURES));
/* Copy the fomula identifiers */
Shm->Proc.thermalFormula = Proc->thermalFormula;
@@ -4896,7 +4898,6 @@ REASON_CODE Core_Manager(REF *Ref)
Arg[cpu].TID = 0;
PerCore_Update(Shm, Proc, Core, cpu);
-/* TODO(CleanUp) Technology_Update(Shm, Proc); */
if (ServerFollowService( &localService,
&Shm->Proc.Service,
@@ -4916,7 +4917,6 @@ REASON_CODE Core_Manager(REF *Ref)
if (!Arg[cpu].TID)
{ /* Add this cpu. */
PerCore_Update(Shm, Proc, Core, cpu);
-/* TODO(CleanUp) Technology_Update(Shm, Proc); */
Arg[cpu].Ref = Ref;
Arg[cpu].Bind = cpu;
diff --git a/corefreqk.c b/corefreqk.c
index 862b337..a0f638a 100644
--- a/corefreqk.c
+++ b/corefreqk.c
@@ -11473,90 +11473,79 @@ static long CoreFreqK_ioctl( struct file *filp,
static int CoreFreqK_mmap(struct file *pfile, struct vm_area_struct *vma)
{
unsigned long reqSize = vma->vm_end - vma->vm_start, secSize = 0;
+ int rc = -EIO;
- if (vma->vm_pgoff == 0) {
- if (Proc != NULL)
- {
- int rc = -EIO;
- secSize = ROUND_TO_PAGES(sizeof(PROC));
+ if (vma->vm_pgoff == 0) {
+ if (Proc != NULL)
+ {
+ secSize = ROUND_TO_PAGES(sizeof(PROC));
+ if (reqSize != secSize) {
+ rc = -EAGAIN;
+ goto EXIT_PAGE;
+ }
+/*TODO(Hardening impacts!)
+ vma->vm_flags = VM_READ;
+ vma->vm_page_prot = PAGE_READONLY;
+*/
+ rc = remap_pfn_range(vma,
+ vma->vm_start,
+ virt_to_phys((void *) Proc) >> PAGE_SHIFT,
+ reqSize,
+ vma->vm_page_prot);
+ }
+ } else if (vma->vm_pgoff == 1) {
+ if (Proc != NULL)
+ {
+ switch (SysGate_OnDemand()) {
+ default:
+ case -1:
+ break;
+ case 1:
+ /* Fallthrough */
+ case 0:
+ secSize = PAGE_SIZE << Proc->OS.ReqMem.Order;
if (reqSize != secSize) {
return (-EAGAIN);
}
+/*TODO(Hardening impacts!)
+ vma->vm_flags = VM_READ;
vma->vm_page_prot = PAGE_READONLY;
- if ((rc = remap_pfn_range(vma,
+*/
+ rc = remap_pfn_range(vma,
vma->vm_start,
- virt_to_phys((void *) Proc) >> PAGE_SHIFT,
- reqSize,
- vma->vm_page_prot)) != 0)
- {
- return (rc);
- }
- } else {
- return (-EIO);
- }
- } else if (vma->vm_pgoff == 1) {
- if (Proc != NULL)
- {
- int rc = -EIO;
- switch (SysGate_OnDemand()) {
- default:
- case -1:
- return (-EIO);
- case 1:
- /* Fallthrough */
- case 0:
- secSize = PAGE_SIZE << Proc->OS.ReqMem.Order;
- if (reqSize != secSize) {
- return (-EAGAIN);
- }
- vma->vm_page_prot = PAGE_READONLY;
- if ((rc = remap_pfn_range(vma,
- vma->vm_start,
virt_to_phys((void *)Proc->OS.Gate)>>PAGE_SHIFT,
- reqSize,
- vma->vm_page_prot)) != 0)
- {
- return (rc);
- }
- break;
- }
- } else {
- return (-EIO);
- }
- } else if (vma->vm_pgoff >= 10) {
- signed int cpu = vma->vm_pgoff - 10;
-
- if (Proc != NULL) {
- if ((cpu >= 0) && (cpu < Proc->CPU.Count)) {
- if (KPublic->Core[cpu] != NULL)
- {
- int rc = -EIO;
+ reqSize,
+ vma->vm_page_prot);
+ break;
+ }
+ }
+ } else if (vma->vm_pgoff >= 10) {
+ signed int cpu = vma->vm_pgoff - 10;
+
+ if (Proc != NULL) {
+ if ((cpu >= 0) && (cpu < Proc->CPU.Count)) {
+ if (KPublic->Core[cpu] != NULL)
+ {
secSize = ROUND_TO_PAGES(sizeof(CORE));
if (reqSize != secSize) {
- return (-EAGAIN);
+ rc = -EAGAIN;
+ goto EXIT_PAGE;
}
+/*TODO(Hardening impacts!)
+ vma->vm_flags = VM_READ;
vma->vm_page_prot = PAGE_READONLY;
- if ((rc = remap_pfn_range(vma,
- vma->vm_start,
- virt_to_phys((void *) KPublic->Core[cpu]) >> PAGE_SHIFT,
- reqSize,
- vma->vm_page_prot)) != 0)
- {
- return (rc);
- }
- } else {
- return (-EIO);
- }
- } else {
- return (-EIO);
- }
- } else {
- return (-EIO);
- }
- } else {
- return (-EIO);
+*/
+ rc = remap_pfn_range(vma,
+ vma->vm_start,
+ virt_to_phys((void *)KPublic->Core[cpu]) >> PAGE_SHIFT,
+ reqSize,
+ vma->vm_page_prot);
}
- return (0);
+ }
+ }
+ }
+EXIT_PAGE:
+ return (rc);
}
static DEFINE_MUTEX(CoreFreqK_mutex); /* Only one driver instance. */
@@ -11833,7 +11822,7 @@ static int __init CoreFreqK_init(void)
if ((iArg.Features = kmalloc(sizeof(FEATURES), GFP_KERNEL)) == NULL) {
rc = -ENOMEM;
- goto EXIT;
+ goto EXIT_INIT;
}
memset(iArg.Features, 0, sizeof(FEATURES));
@@ -12202,7 +12191,7 @@ static int __init CoreFreqK_init(void)
}
}
kfree(iArg.Features);
-EXIT:
+EXIT_INIT:
return (rc);
}