linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* glibc and linux-man disagrees about pkey_alloc
@ 2018-05-16 11:10 Szabolcs Nagy
  2018-05-16 11:19 ` Dmitry V. Levin
  2018-05-16 14:36 ` Florian Weimer
  0 siblings, 2 replies; 6+ messages in thread
From: Szabolcs Nagy @ 2018-05-16 11:10 UTC (permalink / raw)
  To: mtk.manpages; +Cc: nd, linux-man, GNU C Library, Rich Felker

glibc sysdeps/unix/sysv/linux/bits/mman-shared.h:

int pkey_alloc (unsigned int __flags, unsigned int __access_rights) __THROW;

linux-man http://man7.org/linux/man-pages/man2/pkey_alloc.2.html :

int pkey_alloc(unsigned long flags, unsigned long access_rights);

i assume the documentation should be fixed (as the glibc
code is already in use)

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

* Re: glibc and linux-man disagrees about pkey_alloc
  2018-05-16 11:10 glibc and linux-man disagrees about pkey_alloc Szabolcs Nagy
@ 2018-05-16 11:19 ` Dmitry V. Levin
  2018-05-16 11:33   ` Szabolcs Nagy
  2018-05-16 14:36 ` Florian Weimer
  1 sibling, 1 reply; 6+ messages in thread
From: Dmitry V. Levin @ 2018-05-16 11:19 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: mtk.manpages, nd, linux-man, GNU C Library, Rich Felker

[-- Attachment #1: Type: text/plain, Size: 574 bytes --]

On Wed, May 16, 2018 at 12:10:40PM +0100, Szabolcs Nagy wrote:
> glibc sysdeps/unix/sysv/linux/bits/mman-shared.h:
> 
> int pkey_alloc (unsigned int __flags, unsigned int __access_rights) __THROW;
> 
> linux-man http://man7.org/linux/man-pages/man2/pkey_alloc.2.html :
> 
> int pkey_alloc(unsigned long flags, unsigned long access_rights);
> 
> i assume the documentation should be fixed (as the glibc
> code is already in use)

Note that pkey_alloc syscall takes arguments of type "unsigned long"
and explicitly tests them for unsupported bits.


-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: glibc and linux-man disagrees about pkey_alloc
  2018-05-16 11:19 ` Dmitry V. Levin
@ 2018-05-16 11:33   ` Szabolcs Nagy
  2018-05-18 15:26     ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 6+ messages in thread
From: Szabolcs Nagy @ 2018-05-16 11:33 UTC (permalink / raw)
  To: mtk.manpages, linux-man, GNU C Library, Rich Felker; +Cc: nd

On 16/05/18 12:19, Dmitry V. Levin wrote:
> On Wed, May 16, 2018 at 12:10:40PM +0100, Szabolcs Nagy wrote:
>> glibc sysdeps/unix/sysv/linux/bits/mman-shared.h:
>>
>> int pkey_alloc (unsigned int __flags, unsigned int __access_rights) __THROW;
>>
>> linux-man http://man7.org/linux/man-pages/man2/pkey_alloc.2.html :
>>
>> int pkey_alloc(unsigned long flags, unsigned long access_rights);
>>
>> i assume the documentation should be fixed (as the glibc
>> code is already in use)
> 
> Note that pkey_alloc syscall takes arguments of type "unsigned long"
> and explicitly tests them for unsupported bits.
> 
> 

i see, but this is a general bug in the way the syscalls are
documented: a syscall is not a c function, so a c declaration
is not the right way to document it (the pcs does not even
work for syscalls and the linux uapi headers do not provide
magic inline wrappers usable from freestanding c code).

the libc api is in c so that is reasonable to document using
the c language (using c/posix types).

so i recommend making the distinction between kernel uapi,
syscall abi and libc api clear when they disagree about types.

in this case the man says '#include <sys/mman.h>' which is
a libc header, so the declaration has to match whatever is
in there otherwise it's misleading.

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

* Re: glibc and linux-man disagrees about pkey_alloc
  2018-05-16 11:10 glibc and linux-man disagrees about pkey_alloc Szabolcs Nagy
  2018-05-16 11:19 ` Dmitry V. Levin
@ 2018-05-16 14:36 ` Florian Weimer
  2018-05-16 15:18   ` Rich Felker
  1 sibling, 1 reply; 6+ messages in thread
From: Florian Weimer @ 2018-05-16 14:36 UTC (permalink / raw)
  To: Szabolcs Nagy, mtk.manpages; +Cc: nd, linux-man, GNU C Library, Rich Felker

On 05/16/2018 01:10 PM, Szabolcs Nagy wrote:
> glibc sysdeps/unix/sysv/linux/bits/mman-shared.h:
> 
> int pkey_alloc (unsigned int __flags, unsigned int __access_rights) 
> __THROW;
> 
> linux-man http://man7.org/linux/man-pages/man2/pkey_alloc.2.html :
> 
> int pkey_alloc(unsigned long flags, unsigned long access_rights);
> 
> i assume the documentation should be fixed (as the glibc
> code is already in use)

unsigned long on the kernel side is unsigned long long in userspace for 
the x32 variant of x86-64, so the kernel types aren't that helpful for 
describing the user-space interface in an architecture-independent 
fashion.  I expect the flags to be consistent across architectures, so 
there can only be 32 of them anyway, and access rights currently use two 
bits on x86 (and three on POWER, I think).

Thanks,
Florian

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

* Re: glibc and linux-man disagrees about pkey_alloc
  2018-05-16 14:36 ` Florian Weimer
@ 2018-05-16 15:18   ` Rich Felker
  0 siblings, 0 replies; 6+ messages in thread
From: Rich Felker @ 2018-05-16 15:18 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Szabolcs Nagy, mtk.manpages, nd, linux-man, GNU C Library

On Wed, May 16, 2018 at 04:36:03PM +0200, Florian Weimer wrote:
> On 05/16/2018 01:10 PM, Szabolcs Nagy wrote:
> >glibc sysdeps/unix/sysv/linux/bits/mman-shared.h:
> >
> >int pkey_alloc (unsigned int __flags, unsigned int
> >__access_rights) __THROW;
> >
> >linux-man http://man7.org/linux/man-pages/man2/pkey_alloc.2.html :
> >
> >int pkey_alloc(unsigned long flags, unsigned long access_rights);
> >
> >i assume the documentation should be fixed (as the glibc
> >code is already in use)
> 
> unsigned long on the kernel side is unsigned long long in userspace
> for the x32 variant of x86-64, so the kernel types aren't that
> helpful for describing the user-space interface in an
> architecture-independent fashion.  I expect the flags to be
> consistent across architectures, so there can only be 32 of them
> anyway, and access rights currently use two bits on x86 (and three
> on POWER, I think).

There's possibly some argument to be made that by the time 32 bits are
filled, 32-bit archs will be legacy-only and won't be getting new pkey
hardware features, in which case having the full 64 bits available
would be nice... But I don't really care what decision is made as long
as it's consistent.

Rich

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

* Re: glibc and linux-man disagrees about pkey_alloc
  2018-05-16 11:33   ` Szabolcs Nagy
@ 2018-05-18 15:26     ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Kerrisk (man-pages) @ 2018-05-18 15:26 UTC (permalink / raw)
  To: Szabolcs Nagy, linux-man, GNU C Library, Rich Felker; +Cc: mtk.manpages, nd

On 05/16/2018 01:33 PM, Szabolcs Nagy wrote:
> On 16/05/18 12:19, Dmitry V. Levin wrote:
>> On Wed, May 16, 2018 at 12:10:40PM +0100, Szabolcs Nagy wrote:
>>> glibc sysdeps/unix/sysv/linux/bits/mman-shared.h:
>>>
>>> int pkey_alloc (unsigned int __flags, unsigned int __access_rights) __THROW;
>>>
>>> linux-man http://man7.org/linux/man-pages/man2/pkey_alloc.2.html :
>>>
>>> int pkey_alloc(unsigned long flags, unsigned long access_rights);
>>>
>>> i assume the documentation should be fixed (as the glibc
>>> code is already in use)
>>
>> Note that pkey_alloc syscall takes arguments of type "unsigned long"
>> and explicitly tests them for unsupported bits.
>>
>>
> 
> i see, but this is a general bug in the way the syscalls are
> documented: a syscall is not a c function, so a c declaration
> is not the right way to document it (the pcs does not even
> work for syscalls and the linux uapi headers do not provide
> magic inline wrappers usable from freestanding c code).
> 
> the libc api is in c so that is reasonable to document using
> the c language (using c/posix types).
> 
> so i recommend making the distinction between kernel uapi,
> syscall abi and libc api clear when they disagree about types.
> 
> in this case the man says '#include <sys/mman.h>' which is
> a libc header, so the declaration has to match whatever is
> in there otherwise it's misleading.

In cases like these, the section 2 man pages tend to document
the libc interface. The reason that "unsigned long" was shown
was that until now there was no libc interface. I've amended
the manual page to use "unsigned int" for both arguments.
Thanks for CCing linux-man@

Cheers,

Michael



-- 
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] 6+ messages in thread

end of thread, other threads:[~2018-05-18 15:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-16 11:10 glibc and linux-man disagrees about pkey_alloc Szabolcs Nagy
2018-05-16 11:19 ` Dmitry V. Levin
2018-05-16 11:33   ` Szabolcs Nagy
2018-05-18 15:26     ` Michael Kerrisk (man-pages)
2018-05-16 14:36 ` Florian Weimer
2018-05-16 15:18   ` Rich Felker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).