Re: mmap giving Permission Denied error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

I have successfully acessed(read and write) to 0x00000000(NULL) address. I had to make certain changes in .config file and recompile it.

Thank you all.

Regards
Ravi Teja


On Sat, Sep 21, 2013 at 8:00 PM, anish singh <anish198519851985@xxxxxxxxx> wrote:


On Sep 21, 2013 7:35 PM, "Ravi Teja" <ravi2j@xxxxxxxxx> wrote:
>
> Hello Ratheesh,
>
> I have intentionally used MAP_FIXED flag as I am interested in mapping to 0x00000000.
AFAICS in linux generally mapping to null address is not allowed as this decision helps in debugging null dereference errors.

>
> Even after setting the mmap_min_addr in /proc/sys/vm to 0 (which was previously 4096), I am getting this error.
>
> Is there anything wrong that I am doing?
>
>
> On Sat, Sep 21, 2013 at 7:17 PM, ratheesh kannoth <ratheesh.ksz@xxxxxxxxx> wrote:
>>
>> MAP_FIXED could be trying to get a map from  0.
>>
>>
>> Pls remove this flag and try.
>>
>>
>> On Sat, Sep 21, 2013 at 6:55 PM, Ravi Teja <ravi2j@xxxxxxxxx> wrote:
>>>
>>> Hello all,
>>>
>>> I tried mmap'ing to address zero after setting /proc/sys/vm/mmap_min_addr to 0, but mmap is giving Permission Denied error.
>>>
>>> My C code is as below - 
>>>
>>> #include <stdio.h>
>>> #include <stdlib.h>
>>> #include <sys/mman.h>
>>>
>>> int main(void)
>>> {
>>> int *ptr = NULL;
>>> ptr = mmap(0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,-1,0);
>>> if(ptr == MAP_FAILED)
>>> {
>>> perror("Error in mapping\n");
>>> exit(1);
>>> }
>>> printf("After mmap\n");
>>> *ptr = 16;
>>> printf("Contents of address 0x%x is :: %d\n",ptr,*ptr);
>>> return 0;
>>> }
>>>
>>> Am I doing anything wrong here?
>>>
>>> Thank you in advance.
>>>
>>> Regards,
>>> Ravi Teja
>>>
>>> _______________________________________________
>>> Kernelnewbies mailing list
>>> Kernelnewbies@xxxxxxxxxxxxxxxxx
>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>>
>>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@xxxxxxxxxxxxxxxxx
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux