* [PATCH] uapi/if_ether.h: move __UAPI_DEF_ETHHDR libc define
@ 2018-02-12 22:59 Hauke Mehrtens
2018-02-12 23:01 ` Hauke Mehrtens
0 siblings, 1 reply; 4+ messages in thread
From: Hauke Mehrtens @ 2018-02-12 22:59 UTC (permalink / raw)
To: davem; +Cc: linux-api, netdev, g.nault, Hauke Mehrtens, # 4 . 15
This fixes a compile problem of some user space applications by not
including linux/libc-compat.h in uapi/if_ether.h.
linux/libc-compat.h checks which "features" the header files, included
from the libc, provide to make the Linux kernel uapi header files only
provide no conflicting structures and enums. If a user application mixes
kernel headers and libc headers it could happen that linux/libc-compat.h
gets included too early where not all other libc headers are included
yet. Then the linux/libc-compat.h would not prevent all the
redefinitions and we run into compile problems.
This patch removes the include of linux/libc-compat.h from
uapi/if_ether.h to fix the recently introduced case, but not all as this
is more or less impossible.
It is no problem to do the check directly in the if_ether.h file and not
in libc-compat.h as this does not need any fancy glibc header detection
as glibc never provided struct ethhdr and should define
__UAPI_DEF_ETHHDR by them self when they will provide this.
The following test program did not compile correctly any more:
int main(void)
{
return 0;
}
Fixes: 6926e041a892 ("uapi/if_ether.h: prevent redefinition of struct ethhdr")
Reported-by: Guillaume Nault <g.nault@alphalink.fr>
Cc: <stable@vger.kernel.org> # 4.15
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
include/uapi/linux/if_ether.h | 6 +++++-
include/uapi/linux/libc-compat.h | 6 ------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h
index f8cb5760ea4f..8bbbcb5cd94b 100644
--- a/include/uapi/linux/if_ether.h
+++ b/include/uapi/linux/if_ether.h
@@ -23,7 +23,6 @@
#define _UAPI_LINUX_IF_ETHER_H
#include <linux/types.h>
-#include <linux/libc-compat.h>
/*
* IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
@@ -151,6 +150,11 @@
* This is an Ethernet frame header.
*/
+/* allow libcs like musl to deactivate this, glibc does not implement this. */
+#ifndef __UAPI_DEF_ETHHDR
+#define __UAPI_DEF_ETHHDR 1
+#endif
+
#if __UAPI_DEF_ETHHDR
struct ethhdr {
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index fc29efaa918c..8254c937c9f4 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -264,10 +264,4 @@
#endif /* __GLIBC__ */
-/* Definitions for if_ether.h */
-/* allow libcs like musl to deactivate this, glibc does not implement this. */
-#ifndef __UAPI_DEF_ETHHDR
-#define __UAPI_DEF_ETHHDR 1
-#endif
-
#endif /* _UAPI_LIBC_COMPAT_H */
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] uapi/if_ether.h: move __UAPI_DEF_ETHHDR libc define
2018-02-12 22:59 [PATCH] uapi/if_ether.h: move __UAPI_DEF_ETHHDR libc define Hauke Mehrtens
@ 2018-02-12 23:01 ` Hauke Mehrtens
2018-02-13 16:24 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Hauke Mehrtens @ 2018-02-12 23:01 UTC (permalink / raw)
To: davem; +Cc: linux-api, netdev, g.nault, # 4 . 15
On 02/12/2018 11:59 PM, Hauke Mehrtens wrote:
> This fixes a compile problem of some user space applications by not
> including linux/libc-compat.h in uapi/if_ether.h.
>
> linux/libc-compat.h checks which "features" the header files, included
> from the libc, provide to make the Linux kernel uapi header files only
> provide no conflicting structures and enums. If a user application mixes
> kernel headers and libc headers it could happen that linux/libc-compat.h
> gets included too early where not all other libc headers are included
> yet. Then the linux/libc-compat.h would not prevent all the
> redefinitions and we run into compile problems.
> This patch removes the include of linux/libc-compat.h from
> uapi/if_ether.h to fix the recently introduced case, but not all as this
> is more or less impossible.
>
> It is no problem to do the check directly in the if_ether.h file and not
> in libc-compat.h as this does not need any fancy glibc header detection
> as glibc never provided struct ethhdr and should define
> __UAPI_DEF_ETHHDR by them self when they will provide this.
>
> The following test program did not compile correctly any more:
>
> int main(void)
> {
> return 0;
> }
git removed the included here:
#include <linux/if_ether.h>
#include <netinet/in.h>
#include <linux/in.h>
int main(void)
{
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] uapi/if_ether.h: move __UAPI_DEF_ETHHDR libc define
2018-02-12 23:01 ` Hauke Mehrtens
@ 2018-02-13 16:24 ` David Miller
2018-02-13 16:52 ` Guillaume Nault
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2018-02-13 16:24 UTC (permalink / raw)
To: hauke; +Cc: linux-api, netdev, g.nault, stable
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Tue, 13 Feb 2018 00:01:26 +0100
> On 02/12/2018 11:59 PM, Hauke Mehrtens wrote:
>> This fixes a compile problem of some user space applications by not
>> including linux/libc-compat.h in uapi/if_ether.h.
>>
>> linux/libc-compat.h checks which "features" the header files, included
>> from the libc, provide to make the Linux kernel uapi header files only
>> provide no conflicting structures and enums. If a user application mixes
>> kernel headers and libc headers it could happen that linux/libc-compat.h
>> gets included too early where not all other libc headers are included
>> yet. Then the linux/libc-compat.h would not prevent all the
>> redefinitions and we run into compile problems.
>> This patch removes the include of linux/libc-compat.h from
>> uapi/if_ether.h to fix the recently introduced case, but not all as this
>> is more or less impossible.
>>
>> It is no problem to do the check directly in the if_ether.h file and not
>> in libc-compat.h as this does not need any fancy glibc header detection
>> as glibc never provided struct ethhdr and should define
>> __UAPI_DEF_ETHHDR by them self when they will provide this.
>>
>> The following test program did not compile correctly any more:
>>
>> int main(void)
>> {
>> return 0;
>> }
>
> git removed the included here:
>
> #include <linux/if_ether.h>
> #include <netinet/in.h>
> #include <linux/in.h>
>
> int main(void)
> {
> return 0;
> }
Applied with this fixed up, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] uapi/if_ether.h: move __UAPI_DEF_ETHHDR libc define
2018-02-13 16:24 ` David Miller
@ 2018-02-13 16:52 ` Guillaume Nault
0 siblings, 0 replies; 4+ messages in thread
From: Guillaume Nault @ 2018-02-13 16:52 UTC (permalink / raw)
To: David Miller; +Cc: hauke, linux-api, netdev, stable
On Tue, Feb 13, 2018 at 11:24:07AM -0500, David Miller wrote:
> From: Hauke Mehrtens <hauke@hauke-m.de>
> Date: Tue, 13 Feb 2018 00:01:26 +0100
>
> > On 02/12/2018 11:59 PM, Hauke Mehrtens wrote:
> >> This fixes a compile problem of some user space applications by not
> >> including linux/libc-compat.h in uapi/if_ether.h.
> >>
> >> linux/libc-compat.h checks which "features" the header files, included
> >> from the libc, provide to make the Linux kernel uapi header files only
> >> provide no conflicting structures and enums. If a user application mixes
> >> kernel headers and libc headers it could happen that linux/libc-compat.h
> >> gets included too early where not all other libc headers are included
> >> yet. Then the linux/libc-compat.h would not prevent all the
> >> redefinitions and we run into compile problems.
> >> This patch removes the include of linux/libc-compat.h from
> >> uapi/if_ether.h to fix the recently introduced case, but not all as this
> >> is more or less impossible.
> >>
> >> It is no problem to do the check directly in the if_ether.h file and not
> >> in libc-compat.h as this does not need any fancy glibc header detection
> >> as glibc never provided struct ethhdr and should define
> >> __UAPI_DEF_ETHHDR by them self when they will provide this.
> >>
> >> The following test program did not compile correctly any more:
> >>
> >> int main(void)
> >> {
> >> return 0;
> >> }
> >
> > git removed the included here:
> >
> > #include <linux/if_ether.h>
> > #include <netinet/in.h>
> > #include <linux/in.h>
> >
> > int main(void)
> > {
> > return 0;
> > }
>
> Applied with this fixed up, thanks!
Works fine. Thanks Hauke!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-02-13 16:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-12 22:59 [PATCH] uapi/if_ether.h: move __UAPI_DEF_ETHHDR libc define Hauke Mehrtens
2018-02-12 23:01 ` Hauke Mehrtens
2018-02-13 16:24 ` David Miller
2018-02-13 16:52 ` Guillaume Nault
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).