Created
December 6, 2015 08:24
-
-
Save RKX1209/79a822c9c6f5e0cb6fe9 to your computer and use it in GitHub Desktop.
When apply this patch to linux kernel 3.13, you can choose config option 'NO_SIGSEGV', that disable SIGSEGV. In other words, when SEGV happen, new elf section corresponding segv address will allocated.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- arch/x86/Kconfig | |
+++ arch/x86/Kconfig | |
@@ -263,6 +263,24 @@ config ARCH_SUPPORTS_UPROBES | |
source "init/Kconfig" | |
source "kernel/Kconfig.freezer" | |
+menu "Joke setup" | |
+ | |
+config NO_SIGSEGV | |
+ bool "SIGSEGV must not happen" | |
+ help | |
+ When General Protection happen | |
+ | |
+config PROC_HIME | |
+ bool "Processor no HIME" | |
+ help | |
+ HIME! HIME! | |
+ | |
+config TUN_FS | |
+ bool "PENGUIN SENPAI" | |
+ help | |
+ tundere | |
+ | |
+endmenu | |
menu "Processor type and features" | |
config ZONE_DMA | |
diff --git arch/x86/kernel/traps.c arch/x86/kernel/traps.c | |
index 9041463..cfbda7c 100644 | |
--- arch/x86/kernel/traps.c | |
+++ arch/x86/kernel/traps.c | |
@@ -316,7 +316,12 @@ do_general_protection(struct pt_regs *regs, long error_code) | |
print_vma_addr(" in ", regs->ip); | |
pr_cont("\n"); | |
} | |
- | |
+ #ifdef CONFIG_NO_SIGSEGV | |
+ /* #memo | |
+ Allocate struct page by using zone or slab allocater. | |
+ And then, make new PTE by mk_pte(page,prot) */ | |
+ printk(KERN_INFO"<NO_SEGV> pid:%d #GPF\n",tsk->pid); | |
+ #endif | |
force_sig(SIGSEGV, tsk); | |
exit: | |
exception_exit(prev_state); | |
diff --git arch/x86/mm/fault.c arch/x86/mm/fault.c | |
index 7e14055..7a90aea 100644 | |
--- arch/x86/mm/fault.c | |
+++ arch/x86/mm/fault.c | |
@@ -177,7 +177,7 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address, | |
info.si_code = si_code; | |
info.si_addr = (void __user *)address; | |
if (fault & VM_FAULT_HWPOISON_LARGE) | |
- lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault)); | |
+ lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault)); | |
if (fault & VM_FAULT_HWPOISON) | |
lsb = PAGE_SHIFT; | |
info.si_addr_lsb = lsb; | |
@@ -428,7 +428,7 @@ static noinline __kprobes int vmalloc_fault(unsigned long address) | |
#ifdef CONFIG_CPU_SUP_AMD | |
static const char errata93_warning[] = | |
-KERN_ERR | |
+KERN_ERR | |
"******* Your BIOS seems to not contain a fix for K8 errata #93\n" | |
"******* Working around it, but it may cause SEGVs or burn power.\n" | |
"******* Please consider a BIOS update.\n" | |
@@ -1025,6 +1025,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code) | |
struct mm_struct *mm; | |
int fault; | |
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; | |
+ unsigned long populate; | |
tsk = current; | |
mm = tsk->mm; | |
@@ -1158,14 +1159,25 @@ retry: | |
vma = find_vma(mm, address); | |
if (unlikely(!vma)) { | |
+ #ifdef CONFIG_NO_SIGSEGV | |
+ //printk(KERN_INFO"<NO_SIGSEGV> mmap at address0x%08x\n",vma->vm_start); | |
+ goto new_vma; | |
+ #else | |
bad_area(regs, error_code, address); | |
return; | |
+ #endif | |
} | |
+ | |
if (likely(vma->vm_start <= address)) | |
goto good_area; | |
if (unlikely(!(vma->vm_flags & VM_GROWSDOWN))) { | |
+ printk(KERN_INFO"<NO_SIG> not stack 0x%16lx 0x%16lx\n",vma->vm_start, address); | |
+ #ifdef CONFIG_NO_SIGSEGV | |
+ goto new_vma; | |
+ #else | |
bad_area(regs, error_code, address); | |
return; | |
+ #endif | |
} | |
if (error_code & PF_USER) { | |
/* | |
@@ -1175,24 +1187,39 @@ retry: | |
* 32 pointers and then decrements %sp by 65535.) | |
*/ | |
if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) { | |
+ printk(KERN_INFO"<NO_SIG> out of stack 0x%16lx 0x%16lx\n",regs->sp, address); | |
+ #ifdef CONFIG_NO_SIGSEGV | |
+ goto new_vma; | |
+ #else | |
bad_area(regs, error_code, address); | |
return; | |
+ #endif | |
} | |
} | |
if (unlikely(expand_stack(vma, address))) { | |
+ printk(KERN_INFO"<NO_SIG> cannot expand stack 0x%16lx 0x%16lx\n",vma->vm_start, address); | |
+ #ifdef CONFIG_NO_SIGSEGV | |
+ goto new_vma; | |
+ #else | |
bad_area(regs, error_code, address); | |
return; | |
+ #endif | |
} | |
+ new_vma:; | |
+ unsigned long mm_flags = 0; | |
+ mm_flags = 0x22; | |
+ do_mmap_pgoff(0,address & PAGE_MASK,PAGE_SIZE,0x7,mm_flags,0,&populate); | |
+ vma = find_vma(mm, address); | |
/* | |
* Ok, we have a good vm_area for this memory access, so | |
* we can handle it.. | |
*/ | |
good_area: | |
- if (unlikely(access_error(error_code, vma))) { | |
+ /* if (unlikely(access_error(error_code, vma))) { | |
bad_area_access_error(regs, error_code, address); | |
return; | |
- } | |
+ } */ | |
/* | |
* If for any reason at all we couldn't handle the fault, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment