Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJgzZoou1wBNK8qHAheR7_haHf1njaTgRZwXnPGX+19qUAbwLg@mail.gmail.com>
Date: Thu, 12 Jun 2025 10:31:03 -0400
From: enh <enh@...gle.com>
To: musl@...ts.openwall.com
Cc: Namhyung Kim <namhyung@...nel.org>, Arnaldo Carvalho de Melo <acme@...nel.org>
Subject: Re: sys/prctl.h differences vs man page

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@...utronix.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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.