<p dir="ltr"><br>
On Sep 21, 2013 7:35 PM, "Ravi Teja" <<a href="mailto:ravi2j@gmail.com">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>
AFAICS in linux generally mapping to null address is not allowed as this decision helps in debugging null dereference errors.<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">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">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">Kernelnewbies@kernelnewbies.org</a><br>
>>> <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
>>><br>
>><br>
><br>
><br>
> _______________________________________________<br>
> Kernelnewbies mailing list<br>
> <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
> <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
><br>
</p>