Re: Maximum size of mfs in i386

2022-05-03 Thread Yoshihiro Kawamata
So the implementation of W^X in i386 has an impact.

Thank you for showing me the cause, it became clear.



Re: Maximum size of mfs in i386

2022-05-03 Thread Theo de Raadt
> What could be the cause? Is there any way to increase the MAXDSIZ to
> nearly 3GB?

No.

Our i386 architecture is a bit special.  Since older machines don't have
a NX bit, we invented a "line-in-the-sand" scheme using segment limits.
In a userland process, this places code below 512MB, and data above that,
and shared libraries stradle the distance if needed.  We are doing PIE ASLR,
so it is unclear exactly how large a linear-range of memory remains.
This is what is causing the effects you are seeing.

If you want more, move to amd64.



Maximum size of mfs in i386

2022-05-02 Thread Yoshihiro Kawamata
I would like some hints regarding the maximum size of mfs.

mount_mfs(8) says:

Note however that for mount_mfs the practical limit is based
on datasize in login.conf(5), and ultimately depends on the per-
arch MAXDSIZ limit.

So, I searched for the MAXDSIZ value in the source code.

# cd /usr/src/sys/arch
# grep -rs 'define[ ]*MAXDSIZ' amd64 arm64 i386
amd64/include/vmparam.h:#define MAXDSIZ ((paddr_t)32*1024*1024*1024)  /* 
max data size */
arm64/include/vmparam.h:#define MAXDSIZ ((paddr_t)16*1024*1024*1024)  /* 
max data size */
i386/include/vmparam.h:#define MAXDSIZ (3UL*1024*1024*1024)  /* max data 
size */

I found that it is defined as 32GB for amd64, 16GB for arm64, and 3GB
for i386.

When I try mfs mount on each architecture, I generally get the
capacity specified by the kernel on amd64 and arm64, but on i386, the
limit is reached with a value much smaller than MAXDSIZ.

As you can see, I set each resource value to the maximum with
ulimit. The data size is set to 3 GB.

# ulimit -a
time(cpu-seconds)unlimited
file(blocks) unlimited
coredump(blocks) unlimited
data(kbytes) 3145728
stack(kbytes)8192
lockedmem(kbytes)unlimited
memory(kbytes)   3838984
nofiles(descriptors) 128
processes1310

However, when I run the mfs mount, the maximum value is a little
larger than 1GB.

# mount -t mfs -o -s=1351M swap /mnt 
# umount /mnt
# mount -t mfs -o -s=1352M swap /mnt 
mount_mfs: mmap: Cannot allocate memory

What could be the cause? Is there any way to increase the MAXDSIZ to
nearly 3GB?


Yoshihiro Kawamata
http://fuguita.org/