Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 May 1998 08:53:53 +0100
From:      Mark Blackman <tmb@rcru.rl.ac.uk>
To:        hackers@FreeBSD.ORG
Cc:        tmb@rcru.rl.ac.uk
Subject:   /dev/io access.
Message-ID:  <199805180753.IAA22480@bird.te.rl.ac.uk>

next in thread | raw e-mail | index | archive | help
Hello all,

I've noticed that there is a small discrepancy between what
the io(4) man page says and what the source for 2.2.6 does.

In the course of doing some preliminary userland communication with a
custom bit of hardware (10MHz A/D PCI card), I find that my code cannot
write to an I/O port address unless it's run with uid=0.

The man page io(4) says ... 
"
     The entire access control is handled by the file access permissions of
     /dev/io, so care should be taken in granting rights for this device.
     Note that even read/only access will grant the full I/O privileges.
"
The source code (/usr/src/sys/i386/i386/mem.c) says..

in "mmopen", case 14 being the "io" device I believe.

       case 14:
                error = suser(p->p_ucred, &p->p_acflag);
                if (error != 0)
                        return (error);
                if (securelevel > 0)
                        return (EPERM);
                fp = (struct trapframe *)curproc->p_md.md_regs;
                fp->tf_eflags |= PSL_IOPL;
                break;      

The "suser" call appears to enforce a root-only access policy to the
I/O port addresses. I assume there was a change of philosophy between
the man page being written and 2.2.6? 

There are two trivial work-arounds, i.e. run uid=0 or change my
version of the system. However, I would like to be briefly acquainted
with the reasoning for this change though if anyone is feeling
generous with their time.  Note that pciconf.c is similarly
restricted.

Regards,
*************************************************************************
* Mark Blackman                                                         *
* Radar Group                                                           *
* Radio Communications Research Unit                                    *
* Rutherford Appleton Laboratory        E-mail: tmb@rcru.rl.ac.uk       *
* Chilton, Didcot                       Tel:    +44-1235-446126         *
* Oxon OX11 0QX, United Kingdom         Fax:    +44-1235-446140         *
************************************************************************* 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



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