Added do_readbios. Added debugging output for unexpected use of unsafe copy

functions.
This commit is contained in:
Philip Homburg 2006-07-10 12:27:26 +00:00
parent 73e5de6354
commit 6f4091eb8c
7 changed files with 80 additions and 0 deletions

View file

@ -180,6 +180,7 @@ PRIVATE void initialize(void)
map(SYS_SAFECOPYFROM, do_safecopy); /* copy with pre-granted permission */
map(SYS_SAFECOPYTO, do_safecopy); /* copy with pre-granted permission */
map(SYS_VSAFECOPY, do_vsafecopy); /* vectored safecopy */
map(SYS_READBIOS, do_readbios); /* read from BIOS locations */
/* Clock functionality. */
map(SYS_TIMES, do_times); /* get uptime and process times */

View file

@ -177,6 +177,7 @@ _PROTOTYPE( int do_safecopy, (message *m_ptr) );
_PROTOTYPE( int do_vsafecopy, (message *m_ptr) );
_PROTOTYPE( int do_iopenable, (message *m_ptr) );
_PROTOTYPE( int do_setgrant, (message *m_ptr) );
_PROTOTYPE( int do_readbios, (message *m_ptr) );
#endif /* SYSTEM_H */

View file

@ -42,6 +42,7 @@ OBJECTS = \
$(SYSTEM)(do_getksig.o) \
$(SYSTEM)(do_endksig.o) \
$(SYSTEM)(do_kill.o) \
$(SYSTEM)(do_readbios.o) \
$(SYSTEM)(do_sigsend.o) \
$(SYSTEM)(do_sigreturn.o) \
$(SYSTEM)(do_abort.o) \
@ -138,6 +139,9 @@ $(SYSTEM)(do_getinfo.o): do_getinfo.c
$(SYSTEM)(do_abort.o): do_abort.c
$(CC) do_abort.c
$(SYSTEM)(do_readbios.o): do_readbios.c
$(CC) do_readbios.c
$(SYSTEM)(do_setgrant.o): do_setgrant.c
$(CC) do_setgrant.c

View file

@ -30,6 +30,23 @@ register message *m_ptr; /* pointer to request message */
phys_bytes bytes; /* number of bytes to copy */
int i;
if (m_ptr->m_source != 0 && m_ptr->m_source != 1 &&
m_ptr->m_source != 2 && m_ptr->m_source != 3)
{
static int first=1;
if (first)
{
first= 0;
kprintf(
"do_copy: got request from %d (source %d, seg %d, destination %d, seg %d)\n",
m_ptr->m_source,
m_ptr->CP_SRC_ENDPT,
m_ptr->CP_SRC_SPACE,
m_ptr->CP_DST_ENDPT,
m_ptr->CP_DST_SPACE);
}
}
/* Dismember the command message. */
vir_addr[_SRC_].proc_nr_e = m_ptr->CP_SRC_ENDPT;
vir_addr[_SRC_].segment = m_ptr->CP_SRC_SPACE;

View file

@ -0,0 +1,39 @@
/* The kernel call implemented in this file:
* m_type: SYS_READBIOS
*
* The parameters for this kernel call are:
* m2_i1: RDB_SIZE number of bytes to copy
* m2_l1: RDB_ADDR absolute address in BIOS area
* m2_p1: RDB_BUF buffer address in requesting process
*/
#include "../system.h"
#include <minix/type.h>
/*===========================================================================*
* do_readbios *
*===========================================================================*/
PUBLIC int do_readbios(m_ptr)
register message *m_ptr; /* pointer to request message */
{
int proc_nr;
struct proc *p;
phys_bytes address, phys_buf, phys_bios;
vir_bytes buf;
size_t size;
address = m_ptr->RDB_ADDR;
buf = (vir_bytes)m_ptr->RDB_BUF;
size = m_ptr->RDB_SIZE;
okendpt(m_ptr->m_source, &proc_nr);
p = proc_addr(proc_nr);
phys_buf = umap_local(p, D, buf, size);
if (phys_buf == 0)
return EFAULT;
phys_bios = umap_bios(p, address, size);
if (phys_bios == 0)
return EPERM;
phys_copy(phys_bios, phys_buf, size);
return 0;
}

View file

@ -28,6 +28,16 @@ register message *m_ptr; /* pointer to request message */
phys_bytes phys_buf;
int req_type, req_dir;
if ((m_ptr->DIO_REQUEST & _DIO_SAFEMASK) != _DIO_SAFE)
{
static int first= 1;
if (first)
{
first= 0;
kprintf("do_sdevio: for %d\n", m_ptr->m_source);
}
}
/* Check if process endpoint is OK.
* A driver may directly provide a pointer to a buffer at the user-process
* that initiated the device I/O. Kernel processes, of course, are denied.

View file

@ -33,6 +33,14 @@ register message *m_ptr; /* pointer to request message */
int i,s;
struct vir_cp_req *req;
{ static int first=1;
if (first)
{
first= 0;
kprintf("do_vcopy: got request from %d\n", m_ptr->m_source);
}
}
/* Check if request vector size is ok. */
nr_req = (unsigned) m_ptr->VCP_VEC_SIZE;
if (nr_req > VCOPY_VEC_SIZE) return(EINVAL);