Linux-man Archive on lore.kernel.org
 help / color / Atom feed
* typo in ioperm man page
@ 2019-12-25  7:51 Sergey Oskotskiy
  2019-12-25 18:25 ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 3+ messages in thread
From: Sergey Oskotskiy @ 2019-12-25  7:51 UTC (permalink / raw)
  To: mtk.manpages; +Cc: linux-man

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: typo in ioperm man page
  2019-12-25  7:51 typo in ioperm man page Sergey Oskotskiy
@ 2019-12-25 18:25 ` Michael Kerrisk (man-pages)
  2019-12-26  7:45   ` Sergey Oskotskiy
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Kerrisk (man-pages) @ 2019-12-25 18:25 UTC (permalink / raw)
  To: Sergey Oskotskiy; +Cc: mtk.manpages, linux-man

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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: typo in ioperm man page
  2019-12-25 18:25 ` Michael Kerrisk (man-pages)
@ 2019-12-26  7:45   ` Sergey Oskotskiy
  0 siblings, 0 replies; 3+ messages in thread
From: Sergey Oskotskiy @ 2019-12-26  7:45 UTC (permalink / raw)
  To: Michael Kerrisk (man-pages); +Cc: linux-man

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@gmail.com> 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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-25  7:51 typo in ioperm man page Sergey Oskotskiy
2019-12-25 18:25 ` Michael Kerrisk (man-pages)
2019-12-26  7:45   ` Sergey Oskotskiy

Linux-man Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-man/0 linux-man/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-man linux-man/ https://lore.kernel.org/linux-man \
		linux-man@vger.kernel.org
	public-inbox-index linux-man

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-man


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git