Re: typo in ioperm man page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Michael,

Thank you for your reply. Sorry if I am wrong about the typo. My
reasoning is as follows:
in the GLIBC source code (for versions 2.27 and 2.30) I see the
following comment before the declaration of the function ioperm(): "If
TURN_ON is TRUE, request for permission to do direct i/o on the port
numbers in the range [FROM,FROM+NUM-1]...". As far as I understand,
port numbers here are individual bytes (not bits) in the I/O address
space.

I ran the following sample program under GLIBC 2.27 (under Ubuntu
18.04, Linux kernel 4.15):
#include <stdio.h>
#include <sys/io.h>
int main(int argc, char* argv[]) {
  int i;
  i = ioperm(0x378, 1, 1);
  printf("ioperm() returned: %d\n", i);
  outb(0xFF, 0x378);
  printf("1-st outb() completed\n");
  outb(0xFF, 0x379);
  printf("2-nd outb() completed\n");
  return 0;
}

When I run this program (under privileged user), I see the following output:
   ioperm() returned: 0
   1-st outb() completed
   Segmentation fault
So, on the second call to outb() the program receives a segmentation
fault: according to outb man page it means an attempt to access an I/O
port without prior getting permission to access this port by means of
ioperm().

If in the call to ioperm() I change the parameter num (the second
parameter) from 1 to 2:
   i = ioperm(0x378, 2, 1);
then the program runs without segmentation fault and gives the following output:
   ioperm() returned: 0
   1-st outb() completed
   2-nd outb() completed
i.e. the second call to outb() also succeeded (because ioperm() now
permits the access to both I/O ports accessed by the program).

It makes me think that the num parameter of ioperm() function
specifies the number of whole bytes (but not bits) in the I/O address
space.

Best regards,
Sergey


On Wed, Dec 25, 2019 at 9:25 PM Michael Kerrisk (man-pages)
<mtk.manpages@xxxxxxxxx> wrote:
>
> On 12/25/19 8:51 AM, Sergey Oskotskiy wrote:
> > Hello Michael,
> >
> > I think the ioperm man page
> > (http://man7.org/linux/man-pages/man2/ioperm.2.html) has a typo:
> > it says "ioperm() sets the port access permission bits for the calling
> > thread for num ___bits___ ...".
> > I think it should be "...for num ___bytes___..."
> >
> > With best Christmas wishes,
>
> Sergey,
>
> Can you say more abut *why* you think it's wrong.[1] That would
> help me investigate.
>
> Thanks,
>
> Michael
>
> [1] At first glance, I suspect that the existing text *is*
>     correct.
>
> --
> Michael Kerrisk
> Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
> Linux/UNIX System Programming Training: http://man7.org/training/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux