Subject: Check for PROT_EXEC in a driver mmap routine?
To: None <tech-kern@netbsd.org>
From: Bernd Ernesti <netbsd@arresum.inka.de>
List: tech-kern
Date: 09/14/1999 19:41:22
Hi,

I started again to fix the freebsd brooktree driver so i works again
under -current and found that the mmap succeeds when I commented out
the PROT_EXEC check.

For what do we need such a check or is it save to comment it out?

Bernd


int
bktr_mmap( dev_t dev, vm_offset_t offset, int nprot )
{
	int		unit;
	bktr_ptr_t	bktr;

	unit = UNIT(minor(dev));

	if (unit >= NBKTR || FUNCTION(minor(dev)) > 0)
		return( -1 );

	bktr = bktr_cd.cd_devs[unit];

#ifndef __NetBSD__
	if (nprot & PROT_EXEC)
		return( -1 );
#endif

	if (offset < 0)
		return( -1 );

	if (offset >= bktr->alloc_pages * PAGE_SIZE)
		return( -1 );

#ifdef __NetBSD__
	return (bus_dmamem_mmap(bktr->dmat, bktr->dm_mem->dm_segs, 1,
				offset, nprot, BUS_DMA_WAITOK));
#else
	return( i386_btop(vtophys(bktr->bigbuf) + offset) );
#endif
}