<div dir="ltr">Hello all,<div><br></div><div>I have successfully acessed(read and write) to 0x00000000(NULL) address. I had to make certain changes in .config file and recompile it.</div><div><br></div><div>Thank you all.</div>
<div><br></div><div>Regards</div><div>Ravi Teja</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Sep 21, 2013 at 8:00 PM, anish singh <span dir="ltr"><<a href="mailto:anish198519851985@gmail.com" target="_blank">anish198519851985@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr"></p><div class="im"><br>
On Sep 21, 2013 7:35 PM, "Ravi Teja" <<a href="mailto:ravi2j@gmail.com" target="_blank">ravi2j@gmail.com</a>> wrote:<br>
><br>
> Hello Ratheesh,<br>
><br>
> I have intentionally used MAP_FIXED flag as I am interested in mapping to 0x00000000.<br></div>
AFAICS in linux generally mapping to null address is not allowed as this decision helps in debugging null dereference errors.<div><div class="h5"><br>
><br>
> Even after setting the mmap_min_addr in /proc/sys/vm to 0 (which was previously 4096), I am getting this error.<br>
><br>
> Is there anything wrong that I am doing?<br>
><br>
><br>
> On Sat, Sep 21, 2013 at 7:17 PM, ratheesh kannoth <<a href="mailto:ratheesh.ksz@gmail.com" target="_blank">ratheesh.ksz@gmail.com</a>> wrote:<br>
>><br>
>> MAP_FIXED could be trying to get a map from 0.<br>
>><br>
>><br>
>> Pls remove this flag and try.<br>
>><br>
>><br>
>> On Sat, Sep 21, 2013 at 6:55 PM, Ravi Teja <<a href="mailto:ravi2j@gmail.com" target="_blank">ravi2j@gmail.com</a>> wrote:<br>
>>><br>
>>> Hello all,<br>
>>><br>
>>> I tried mmap'ing to address zero after setting /proc/sys/vm/mmap_min_addr to 0, but mmap is giving Permission Denied error.<br>
>>><br>
>>> My C code is as below - <br>
>>><br>
>>> #include <stdio.h><br>
>>> #include <stdlib.h><br>
>>> #include <sys/mman.h><br>
>>><br>
>>> int main(void)<br>
>>> {<br>
>>> int *ptr = NULL;<br>
>>> ptr = mmap(0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,-1,0);<br>
>>> if(ptr == MAP_FAILED)<br>
>>> {<br>
>>> perror("Error in mapping\n");<br>
>>> exit(1);<br>
>>> }<br>
>>> printf("After mmap\n");<br>
>>> *ptr = 16;<br>
>>> printf("Contents of address 0x%x is :: %d\n",ptr,*ptr);<br>
>>> return 0;<br>
>>> }<br>
>>><br>
>>> Am I doing anything wrong here?<br>
>>><br>
>>> Thank you in advance.<br>
>>><br>
>>> Regards,<br>
>>> Ravi Teja<br>
>>><br>
>>> _______________________________________________<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>
>><br>
><br>
><br>
> _______________________________________________<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>
</div></div><p></p>
</blockquote></div><br></div>