Security: round mmap hint address above mmap_min_addr
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / mm.h
index 7e87e1b1662e55b5fbcfc81e022e56bb9807881a..1b7b95c67acaf5df2fd9cb860599931119ddc029 100644 (file)
 #include <linux/mmzone.h>
 #include <linux/rbtree.h>
 #include <linux/prio_tree.h>
-#include <linux/mutex.h>
 #include <linux/debug_locks.h>
-#include <linux/backing-dev.h>
 #include <linux/mm_types.h>
+#include <linux/security.h>
 
 struct mempolicy;
 struct anon_vma;
@@ -514,6 +513,21 @@ static inline void set_page_links(struct page *page, enum zone_type zone,
        set_page_section(page, pfn_to_section_nr(pfn));
 }
 
+/*
+ * If a hint addr is less than mmap_min_addr change hint to be as
+ * low as possible but still greater than mmap_min_addr
+ */
+static inline unsigned long round_hint_to_min(unsigned long hint)
+{
+#ifdef CONFIG_SECURITY
+       hint &= PAGE_MASK;
+       if (((void *)hint != NULL) &&
+           (hint < mmap_min_addr))
+               return PAGE_ALIGN(mmap_min_addr);
+#endif
+       return hint;
+}
+
 /*
  * Some inline functions in vmstat.h depend on page_zone()
  */