* Re: [musl] sys/prctl.h differences vs man page
[not found] <20250612064940.ukl7RfT2@linutronix.de>
@ 2025-06-12 14:31 ` enh
[not found] ` <20250612162636.GS1827@brightrain.aerifal.cx>
0 siblings, 1 reply; 3+ messages in thread
From: enh @ 2025-06-12 14:31 UTC (permalink / raw)
To: musl; +Cc: Namhyung Kim, Arnaldo Carvalho de Melo
yeah, apologies that i don't think i reported this to the list before,
but android also hit various prctl portability issues trying to use
musl as the host libc and added this ahead of the musl <sys/prctl.h>
as our workaround:
#ifndef _SYS_PRCTL_H
#define _SYS_PRCTL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/*
* Get the constants and structs from uapi so that code that
* includes <linux/prctl.h> doesn't conflict with <sys/prctl.h>.
*/
#include <linux/prctl.h>
int prctl (int, ...);
#ifdef __cplusplus
}
#endif
#endif
"we don't duplicate anything that's in a uapi header" is just what
bionic does for everything, all the time, but interestingly
<sys/prctl.h> is a rare header where glibc also doesn't do their usual
copy & paste and just includes <linux/prctl.h> instead. (which is why
this is an issue unique to musl, not one shared with glibc.)
On Thu, Jun 12, 2025 at 2:49 AM Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
>
> Hi,
>
> the man page for prctl(2) states:
> | SYNOPSIS
> | #include <linux/prctl.h> /* Definition of PR_* constants */
> | #include <sys/prctl.h>
>
> if one is going to include both headers then this happens:
> | In file included from file.c:6:
> | /usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'
> | 88 | struct prctl_mm_map {
> | | ^~~~~~~~~~~~
> | In file included from file.c:5:
> | /linux/tools/include/uapi/linux/prctl.h:134:8: note: originally defined here
> | 134 | struct prctl_mm_map {
> | | ^~~~~~~~~~~~
>
> The problem is that musl's provided sys/prctl.h defines the struct
> prctl_mm_map which is a copy of linux kernel's linux/prctl.h. This breaks
> compiles based on the man page because that struct is defined twice.
> It makes it harder to write software which replaces linux/prctl.h with
> current header file while testing for recent features. It also increases
> the maintenance on musl's side to keep that file up to date.
>
> Could you please ship sys/prctl.h which provides the prctl() definition
> and include the PR_* definition from linux/prctl.h?
>
> This problem has been observed on Alpine Linux by Namhyung Kim [0].
>
> [0] https://lore.kernel.org/all/aEh6xO14wDSCFUDr@google.com/T/#u
>
> Sebastian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [musl] sys/prctl.h differences vs man page
[not found] ` <20250612165000.DmnF5NIa@linutronix.de>
@ 2025-06-12 17:21 ` Rich Felker
0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2025-06-12 17:21 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: enh, musl, Namhyung Kim, Arnaldo Carvalho de Melo
On Thu, Jun 12, 2025 at 06:50:00PM +0200, Sebastian Andrzej Siewior wrote:
> On 2025-06-12 12:34:08 [-0400], Rich Felker wrote:
> > On Thu, Jun 12, 2025 at 12:28:24PM -0400, enh wrote:
> > > https://man7.org/linux/man-pages/man2/prctl.2.html
> >
> > OK, apparently this is either a regression since the man-pages 6.8-r0
> > package I have here on Alpine, or an old version. Guess we should look
> > at the git history and how that happened...
>
> That would be commit
> ae31bd15b65ce ("prctl.2, PR_*.2const: SYNOPSIS: #include <linux/prctl.h> for the PR_* constants")
> https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=ae31bd15b65ce
>
> Commit is present since man-pages-6.9.
Yes, that looks completely unmotivated and should be reverted.
In general, you should never include both the linux uapi and
userspace/libc header for the same thing.
If your libc delegates to the linux uapi header, it will already have
included it implicitly to get the definitions.
If not, the two conflict.
And abstractly: one is describing the application-to-libc-function
interface, the other is describing the raw syscall interface. You
include the header for which one you're using.
Rich
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [musl] sys/prctl.h differences vs man page
[not found] ` <20250612163847.GT1827@brightrain.aerifal.cx>
@ 2025-06-12 20:36 ` Alejandro Colomar
0 siblings, 0 replies; 3+ messages in thread
From: Alejandro Colomar @ 2025-06-12 20:36 UTC (permalink / raw)
To: Rich Felker; +Cc: A. Wilcox, musl
[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]
Hi Rich,
On Thu, Jun 12, 2025 at 12:38:48PM -0400, Rich Felker wrote:
> On Thu, Jun 12, 2025 at 11:32:47AM -0500, A. Wilcox wrote:
> > On Jun 12, 2025, at 11:26, Rich Felker <dalias@libc.org> wrote:
> > > I don't see where it's documented that one should include
> > > <linux/prctl.h> to use the prctl API. It's not in my copy of the man
> > > page.
> > >
> > > Rich
> >
> > https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/man/man2/prctl.2?id=ae31bd15b65ce03a143860e8f4daa99fcd5125a4
>
> CC'ing commit author on this breakage.
I'd say I only changed the formatting of the information, but the manual
page already claimed you should include both <sys/prctl.h> and
<linux/prctl.h>; it just dit it in a weird way.
So, should we consider <sys/prctl.h> to be the provider of PR_*
constants? I'd be happy to update the manual page, but libc maintainers
should state what is the official header for the PR_* constants.
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-12 20:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20250612064940.ukl7RfT2@linutronix.de>
2025-06-12 14:31 ` [musl] sys/prctl.h differences vs man page enh
[not found] ` <20250612162636.GS1827@brightrain.aerifal.cx>
[not found] ` <CAJgzZoqh=Mm1Hnuabnig_7fWXTSb7DYj_LBeS0xZWO8vVwfong@mail.gmail.com>
[not found] ` <20250612163408.GF6263@brightrain.aerifal.cx>
[not found] ` <20250612165000.DmnF5NIa@linutronix.de>
2025-06-12 17:21 ` Rich Felker
[not found] ` <F863CD31-25C5-4406-B02C-CE8B3FBFB28A@Wilcox-Tech.com>
[not found] ` <20250612163847.GT1827@brightrain.aerifal.cx>
2025-06-12 20:36 ` Alejandro Colomar
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).