/* * netsniff-ng - the packet sniffing beast * Copyright 2009 - 2013 Daniel Borkmann. * Subject to the GPL, version 2. */ #include #include #include "hash.h" #include "xmalloc.h" #include "oui.h" #include "str.h" static struct hash_table oui; static bool initialized = false; struct vendor_id { unsigned int id; char *vendor; struct vendor_id *next; }; const char *lookup_vendor(unsigned int id) { struct vendor_id *v; v = lookup_hash(id, &oui); while (v && id != v->id) v = v->next; return (v && id == v->id ? v->vendor : NULL); } void dissector_init_oui(void) { FILE *fp; char buff[128], *ptr, *end; struct vendor_id *v; void **pos; if (initialized) return; fp = fopen(ETCDIRE_STRING "/oui.conf", "r"); if (!fp) panic("No oui.conf found!\n"); memset(buff, 0, sizeof(buff)); while (fgets(buff, sizeof(buff), fp) != NULL) { buff[sizeof(buff) - 1] = 0; ptr = buff; v = xmalloc(sizeof(*v)); v->id = strtol(ptr, &end, 0); /* not a valid line, skip */ if (v->id == 0 && end == ptr) { xfree(v); continue; } ptr = strstr(buff, ", "); /* likewise */ if (!ptr) { xfree(v); continue; } ptr += strlen(", "); ptr = strtrim_right(ptr, '\n'); ptr = strtrim_right(ptr, ' '); v->vendor = xstrdup(ptr); v->next = NULL; pos = insert_hash(v->id, v, &oui); if (pos) { v->next = *pos; *pos = v; } memset(buff, 0, sizeof(buff)); } fclose(fp); initialized = true; } static int dissector_cleanup_oui_hash(void *ptr) { struct vendor_id *tmp, *v = ptr; if (!ptr) return 0; while ((tmp = v->next)) { xfree(v->vendor); xfree(v); v = tmp; } xfree(v->vendor); xfree(v); return 0; } void dissector_cleanup_oui(void) { if (!initialized) return; for_each_hash(&oui, dissector_cleanup_oui_hash); free_hash(&oui); initialized = false; } t/tree/?h=nds-private-remove&id=fb754f958f8e46202c1efd7f66d5b3db1208117d'>treecommitdiff
diff options
context:
space:
mode:
authorThomas Garnier <thgarnie@google.com>2016-08-09 10:11:05 -0700
committerIngo Molnar <mingo@kernel.org>2016-08-10 14:45:19 +0200
commitfb754f958f8e46202c1efd7f66d5b3db1208117d (patch)
treed3464916feec6cc38eeecaf50008f302658db00b
parentc7d2361f7524f365c1ae42f47880e3fa9efb2c2a (diff)
x86/mm/KASLR: Increase BRK pages for KASLR memory randomization
Default implementation expects 6 pages maximum are needed for low page allocations. If KASLR memory randomization is enabled, the worse case of e820 layout would require 12 pages (no large pages). It is due to the PUD level randomization and the variable e820 memory layout. This bug was found while doing extensive testing of KASLR memory randomization on different type of hardware. Signed-off-by: Thomas Garnier <thgarnie@google.com> Cc: Aleksey Makarov <aleksey.makarov@linaro.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Baoquan He <bhe@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Borislav Petkov <bp@suse.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Dave Young <dyoung@redhat.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Fabian Frederick <fabf@skynet.be> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Joerg Roedel <jroedel@suse.de> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Lv Zheng <lv.zheng@intel.com> Cc: Mark Salter <msalter@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rafael J . Wysocki <rafael.j.wysocki@intel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Toshi Kani <toshi.kani@hp.com> Cc: kernel-hardening@lists.openwall.com Fixes: 021182e52fe0 ("Enable KASLR for physical mapping memory regions") Link: http://lkml.kernel.org/r/1470762665-88032-2-git-send-email-thgarnie@google.com Signed-off-by: Ingo Molnar <mingo@kernel.org>