The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/security/min_addr.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #include <linux/init.h>
    2 #include <linux/mm.h>
    3 #include <linux/security.h>
    4 #include <linux/sysctl.h>
    5 
    6 /* amount of vm to protect from userspace access by both DAC and the LSM*/
    7 unsigned long mmap_min_addr;
    8 /* amount of vm to protect from userspace using CAP_SYS_RAWIO (DAC) */
    9 unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
   10 /* amount of vm to protect from userspace using the LSM = CONFIG_LSM_MMAP_MIN_ADDR */
   11 
   12 /*
   13  * Update mmap_min_addr = max(dac_mmap_min_addr, CONFIG_LSM_MMAP_MIN_ADDR)
   14  */
   15 static void update_mmap_min_addr(void)
   16 {
   17 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
   18         if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
   19                 mmap_min_addr = dac_mmap_min_addr;
   20         else
   21                 mmap_min_addr = CONFIG_LSM_MMAP_MIN_ADDR;
   22 #else
   23         mmap_min_addr = dac_mmap_min_addr;
   24 #endif
   25 }
   26 
   27 /*
   28  * sysctl handler which just sets dac_mmap_min_addr = the new value and then
   29  * calls update_mmap_min_addr() so non MAP_FIXED hints get rounded properly
   30  */
   31 int mmap_min_addr_handler(struct ctl_table *table, int write,
   32                           void __user *buffer, size_t *lenp, loff_t *ppos)
   33 {
   34         int ret;
   35 
   36         if (write && !capable(CAP_SYS_RAWIO))
   37                 return -EPERM;
   38 
   39         ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
   40 
   41         update_mmap_min_addr();
   42 
   43         return ret;
   44 }
   45 
   46 static int __init init_mmap_min_addr(void)
   47 {
   48         update_mmap_min_addr();
   49 
   50         return 0;
   51 }
   52 pure_initcall(init_mmap_min_addr);

Cache object: ef0795961ed99e9e0c09d61d1c30b66b


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.