From: Philip Homburg Date: Mon, 23 Apr 2007 13:31:16 +0000 (+0000) Subject: Disallow unaligned access to I/O ports. X-Git-Tag: v3.1.4~424 X-Git-Url: http://zhaoyanbai.com/repos/icons/debian/static/man.7.ps?a=commitdiff_plain;h=d2cec7db496971fc913d896b55e113795d8115a1;p=minix.git Disallow unaligned access to I/O ports. --- diff --git a/kernel/system/do_devio.c b/kernel/system/do_devio.c index 810b5a9d0..a53bf0abe 100644 --- a/kernel/system/do_devio.c +++ b/kernel/system/do_devio.c @@ -30,6 +30,14 @@ register message *m_ptr; /* pointer to request message */ io_type = m_ptr->DIO_REQUEST & _DIO_TYPEMASK; io_dir = m_ptr->DIO_REQUEST & _DIO_DIRMASK; + switch (io_type) + { + case _DIO_BYTE: size= 1; break; + case _DIO_WORD: size= 2; break; + case _DIO_LONG: size= 4; break; + default: size= 4; break; /* Be conservative */ + } + rp= proc_addr(who_p); privp= priv(rp); if (!privp) @@ -55,14 +63,17 @@ register message *m_ptr; /* pointer to request message */ } if (i >= nr_io_range) { - kprintf( - "do_devio: I/O port check failed for proc %d, port 0x%x\n", - m_ptr->m_source, port); return EPERM; } } doit: + if (m_ptr->DIO_PORT & (size-1)) + { + kprintf("do_devio: unaligned port 0x%x (size %d)\n", + m_ptr->DIO_PORT, size); + return EPERM; + } /* Process a single I/O request for byte, word, and long values. */ if (io_dir == _DIO_INPUT) {