Fwd: mmap 0-th page

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

 



I am apologizing for sending again.
I have forgotten to add all recipients to previous e-mail.
...


-------- Forwarded Message --------
Subject: 	Re: mmap 0-th page
Date: 	Fri, 9 Aug 2024 12:45:01 +0200
From: 	michal.hrachovec@xxxxxxxx <michal.hrachovec@xxxxxxxx>
To: 	Jiri Slaby <jirislaby@xxxxxxxxxx>



Good afternoon,

I finally have in Fedora Linux kernel version 6.10.3:
Linux fedora 6.10.3-100.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Aug  5 14:46:47 UTC 2024 x86_64 GNU/Linux

I have set this setting to zero:
cat /proc/sys/vm/mmap_min_addr
0

Then I compiled your program, where I only added the main and the return statements:

int main(void)
{
char *zero = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
*(char *)(NULL) = 'A';
printf("%c\n", *zero);
return 0;
}

I got error at running the compiled program:
Program received signal SIGSEGV, Segmentation fault (at line 2 of your program)

Can you help again, please.

Thank you.

Michal Hrachovec


On 7/31/24 09:43, Jiri Slaby wrote:
On 31. 07. 24, 9:39, Jiri Slaby wrote:
On 26. 07. 24, 12:36, michal.hrachovec@xxxxxxxx wrote:
I am trying to allocate the 0-th page with mmap function in my code.
I am always getting this error with this error-code: mmap error ffffffff
Then I was searching the internet for this topic and I have found the same topic at stackoverflow web pages.


         char *zero = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
         *(char *)(NULL) = 'A';
         printf("%c\n", *zero);

still yields 'A' here with 6.10.2 w/ vm.mmap_min_addr=0.
Yeah and mind LSMs...






[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux