Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Jan 1997 06:11:38 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, swallace@ece.uci.edu
Cc:        cvs-all@freefall.freebsd.org, CVS-committers@freefall.freebsd.org, cvs-sys@freefall.freebsd.org, dyson@freebsd.org, jkh@freefall.freebsd.org
Subject:   Re: cvs commit: src/sys/i386/linux imgact_linux.c
Message-ID:  <199701291911.GAA10699@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>>>  Modified:    sys/i386/linux  imgact_linux.c
>>>  Log:
>>>  *Ahem* - opt_rlimit.h does not exist in the LKM case.  This was another
>>>  2.2 build-breaker.. :(
>> ...
>> The correct fix seems to be particularly easy in this case.  Old code:
>> ...
>> Just remove the bogus check against MAXDSIZ.  The correct limit (rlim_cur)
>> is already checked.  rlim_cur <= MAXDSIZ, so checking against MAXDSIZ is
>> currently a no-op.

>Bruce, no one has done anything about this "wrong" fix of Jordan's.
>Do you want to implement your idea?  It's still in 2.2R.

I just fixed it locally.  Since it's cosmetic, I won't commit it for a
while.

imgact_aout.c and imgact_gzip.c also do the unnecssary check and have to
include the options file for it.  Fixed.

I noticed several related non-cosmetic problems:
- imgact_elf.c and imgact_coff.c don't seem to limit the text or data
  sections at all.  An executable with a too-large data section will
  probably crash early when it tries to extend the break.
- the text limit of MAXTSIZ is not configurable either statically or
  with setrlimit().  It's default of 16M is rather small.  It seems to
  be only used in imgact_aout.c and imgact_aout.c.  More executable
  pages can be allocated using mmap().
- mmap() doesn't honor the data limit either.  The only effective memory
  limits are the RSS limit and the size of swap.  This is demonstrated
  by the enclosed program.  It uses all of swap.  read-only and
  MAP_SHARED variations of it demonstrate panics and nfs paging bugs.

BTW, how do you generate files from the linux syscalls.master?  There
should be a makefile as in /sys/kern.

Bruce

#include <sys/types.h>
#include <sys/mman.h>

#include <fcntl.h>
#include <stdio.h>

int main(void)
{
	int fd, i;
	caddr_t p;

	fd = open("zz", O_RDWR);
	if (fd == -1)
		perror("open");
	while (1) {
		p = mmap(NULL, 128 * 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE,
			 fd, (off_t)0);
		if (p == MAP_FAILED)
			perror("mmap");
		printf("%p %p\n", sbrk(0), p);
		for (i = 0; i < 128 * 4096; i += 4096)
			*(volatile int *)((char *)p + i) = 1;
	}
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701291911.GAA10699>