<div dir="ltr">Hello Ratheesh,<div><br></div><div>I have intentionally used MAP_FIXED flag as<i> </i>I am interested in mapping to 0x00000000.</div><div><br></div><div>Even after setting the mmap_min_addr in /proc/sys/vm to 0 (which was previously 4096), I am getting this error.</div>
<div><br></div><div>Is there anything wrong that I am doing?</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Sep 21, 2013 at 7:17 PM, ratheesh kannoth <span dir="ltr"><<a href="mailto:ratheesh.ksz@gmail.com" target="_blank">ratheesh.ksz@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>MAP_FIXED could be trying to get a map from 0.<br><br><br></div><div>Pls remove this flag and try.<br>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Sat, Sep 21, 2013 at 6:55 PM, Ravi Teja <span dir="ltr"><<a href="mailto:ravi2j@gmail.com" target="_blank">ravi2j@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hello all,<div><br></div><div>I tried mmap'ing to address zero after setting <b>/proc/sys/vm/mmap_min_addr</b> to<b> 0</b>, but mmap is giving Permission Denied error.</div>
<div><br></div><div>My C code is as below - </div>
<div><br></div><div><div>#include <stdio.h></div><div>#include <stdlib.h></div><div>#include <sys/mman.h></div><div><br></div><div>int main(void)</div><div>{</div><div><span style="white-space:pre-wrap">        </span>int *ptr = NULL;</div>
<div><span style="white-space:pre-wrap">        </span>ptr = mmap(0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,-1,0);</div><div><span style="white-space:pre-wrap">        </span>if(ptr == MAP_FAILED)</div><div>
<span style="white-space:pre-wrap">        </span>{</div><div><span style="white-space:pre-wrap">                </span>perror("Error in mapping\n");</div><div><span style="white-space:pre-wrap">                </span>exit(1);</div><div>
<span style="white-space:pre-wrap">        </span>}</div><div><span style="white-space:pre-wrap">        </span>printf("After mmap\n");</div><div><span style="white-space:pre-wrap">        </span>*ptr = 16;</div><div><span style="white-space:pre-wrap">        </span>printf("Contents of address 0x%x is :: %d\n",ptr,*ptr);</div>
<div><span style="white-space:pre-wrap">        </span>return 0;</div><div>}</div></div><div><br></div><div>Am I doing anything wrong here?</div><div><br></div><div>Thank you in advance.</div><div><br></div><div>Regards,</div>
<div>Ravi Teja</div></div>
<br></div></div>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>