Received: by 10.223.176.5 with SMTP id f5csp808487wra; Sat, 3 Feb 2018 10:45:44 -0800 (PST) X-Google-Smtp-Source: AH8x226IkTGyCNAlhQNNC7ondGgp7AnZHDyiMB4cgp31Ta7MIdpWuAm6hBziCPU8MWv2bY4Z5XvU X-Received: by 10.99.164.74 with SMTP id c10mr21261564pgp.18.1517683544114; Sat, 03 Feb 2018 10:45:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517683544; cv=none; d=google.com; s=arc-20160816; b=yBKhpl7v5Y4mE85aKjQvDdi/Ezb8pxtXuij5BPstYdhfk/9kUu2CaJehoVkwwraSVD Ap6pqT5UQ4UrQLC5yhNXMJn6oVv5mB3obfdEod7APgHCa0viVgwLVc1I49qxLKFIkTmL TEgUEa5vRRGDkC3V8s31D4IdHJuomtoy/Rssw127m+T1j3PeYsvbV+Ykw3j6SsyTZOgP Q3AchtZ3yL//ujAv4sFXJ5b0lLGSra+Fmxlpcf2FOacnC72kZnRtmeAvn9OwhKHVCXaE KZpf6B/FHBO3tp37guTC4EEveJkv3yMy1Nsr0hetot7aSQIDFL59BJzwex40nvNQ/txO vcmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=qdSqW3JJf0YtYuk5ebMwg2fmI1pZtaIZjfXtjUAFG0w=; b=B11LAwY/1zB6sKg41vBKDZeebNT9CsTh82DUZo4M8KTbmYY5aqfVbGHFPVZZlCBU3P /HfqADjLbaOW7vNBEt/Fhb1W9K224x6juNoN1SjTgHNWmGhyY2Fc+edf32XxBH4i6GFn YXLmpyEkFPZ06P+98NTglf4j7t0R9ZbQgCE9+xqLAw8w5d+r2CCh2eDeVgaqHDOA6Nkm 6ML7Xa7/CSeDaEnysPpQJN5iN8tEw7mGSz4lkG2KttSb7lg62FuPn/J2etT4Rwli9uES GCLCG4s0KLUfsBFx7/ZdXDSFeMVKRPIeapv0IkqoSgHqm7chep5QBBULnPO67ffPn21U HYzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Bu2xK4XU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e29si1507008pga.146.2018.02.03.10.45.29; Sat, 03 Feb 2018 10:45:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Bu2xK4XU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755199AbeBCSna (ORCPT + 99 others); Sat, 3 Feb 2018 13:43:30 -0500 Received: from mail-bl2nam02on0139.outbound.protection.outlook.com ([104.47.38.139]:53867 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752651AbeBCSDI (ORCPT ); Sat, 3 Feb 2018 13:03:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=qdSqW3JJf0YtYuk5ebMwg2fmI1pZtaIZjfXtjUAFG0w=; b=Bu2xK4XUAb1JCrZ5ef6AKAqgMG/oVVzZkz6rdUp2eZ1k22LAUnu+6fywuFAXgRqswpKm+mo9WxBjLx6W6dDt29paXNWIEp+vN7tUW6J14iVy/03CdmaFk65fU1tuNI12A1XBspjADT9YR/+vKn6tCk2eKj6iSBL0Ipz/7pLtSgg= Received: from BL0PR2101MB1027.namprd21.prod.outlook.com (52.132.20.161) by BL0PR2101MB1041.namprd21.prod.outlook.com (52.132.23.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.506.3; Sat, 3 Feb 2018 18:02:12 +0000 Received: from BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9]) by BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9%3]) with mapi id 15.20.0485.006; Sat, 3 Feb 2018 18:02:12 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Felix Janda , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 083/110] uapi libc compat: add fallback for unsupported libcs Thread-Topic: [PATCH AUTOSEL for 4.14 083/110] uapi libc compat: add fallback for unsupported libcs Thread-Index: AQHTnRj/P87g024KWEORlq+LA1aT8A== Date: Sat, 3 Feb 2018 18:01:22 +0000 Message-ID: <20180203180015.29073-83-alexander.levin@microsoft.com> References: <20180203180015.29073-1-alexander.levin@microsoft.com> In-Reply-To: <20180203180015.29073-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BL0PR2101MB1041;6:MwhdAEBZxQ3B2M6lg+IPqraOuci1IUCYtdKtnL8K6bri0N+AU1MQe+RMHMFZS7enN+lydOfaMH56QtgqosqD6JjRltO14SH5q6SFUXtszUucQWowpAxIuZEieiBW/MCcPjoY//IqxBFalXisPG7r+KjsWvNfisK5NvbEjhSz58OgXYbahVDv71lsThG0R3iE9Mi5VwgBRLzVu3wE9frahYReSkauxB9QvgNacr0N28gJo9GjlGku2OY/1NgxyfWPFt+jxwToytIrNP5MJZ7AZghW3Lbqzt5PDdH3eAmZ2cJVxB4jvnAcXSqBhWmPGlfnzloPEvRCMwmLufAvD0EC5sMhHxqhaHotTmuSNHt20aaWGNbamtSpo+WORXj88/b1;5:OeFi/wzmPDN+hZWE256gtNVijUOIiGaxot7Xwjm8rj6z/piRIED9tMjD5WkpeJILWlHnz0wcO0jfquuus8hn8APfLRykaDMdARsbqPmoppCkxe+/tzDuwBZgC8XdgQlnDAPnHudIf5GnPzi7VHpzLDsibimD8FFvUXwcJN5oRkA=;24:wQmcMbDVsKjUNX9drM5gA/isln9oot3DZgKLAVfy20EjAhQhtUY2Klb+tHM4RxwvRD38TsGbLa2Aikpq0uCRIjzxElFmtfU/tz+K+8j3Zpk=;7:8Ma0D+qn+vNscZw8P2yn2d0qBizUuc4vLHmu46g6glas9sdoQ/W1Hlg3puyaKToXjZWkw5mts3oIVE2WkM+mLWbFKN+qwWBitcaZo6Z96LlaHg6B39KYyX4/vDPayNBoZcLoHDMAnuOn6oVjuqgniyv5H2UXBe+uhZo9imxBQ2FTU7nAMAeN2E5rGI9hoh2yIiIZsTXjroTAu7+rLp5tGCZhaJlYYgB1CcjjlFB/mPBcVun5Pvzx8H24IziyzyLZ x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: e2186e88-1ac1-4c2e-1501-08d56b30409f x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:BL0PR2101MB1041; x-ms-traffictypediagnostic: BL0PR2101MB1041: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3231101)(2400082)(944501161)(93006095)(93001095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(6072148)(201708071742011);SRVR:BL0PR2101MB1041;BCL:0;PCL:0;RULEID:;SRVR:BL0PR2101MB1041; x-forefront-prvs: 05724A8921 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(396003)(366004)(39860400002)(376002)(346002)(189003)(199004)(2501003)(305945005)(3660700001)(5250100002)(81156014)(99286004)(81166006)(36756003)(7736002)(10290500003)(106356001)(53936002)(5660300001)(316002)(22452003)(8936002)(54906003)(110136005)(3280700002)(478600001)(72206003)(966005)(4326008)(25786009)(107886003)(102836004)(97736004)(76176011)(59450400001)(6666003)(66066001)(6506007)(2950100002)(2900100001)(68736007)(8676002)(6116002)(3846002)(186003)(1076002)(6346003)(105586002)(26005)(10090500001)(2906002)(6512007)(86612001)(14454004)(6306002)(575784001)(86362001)(6436002)(6486002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL0PR2101MB1041;H:BL0PR2101MB1027.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: j1Rw0pCI9aVvd6UJ1jZYg+L+h8drKyW1carX37jr/fwrqLFEJJZUPnsAJ5zNsF1xzl/BZDVHhOjozvPSWaGerw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: e2186e88-1ac1-4c2e-1501-08d56b30409f X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2018 18:01:22.4878 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR2101MB1041 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Felix Janda [ Upstream commit c0bace798436bca0fdc221ff61143f1376a9c3de ] libc-compat.h aims to prevent symbol collisions between uapi and libc headers for each supported libc. This requires continuous coordination between them. The goal of this commit is to improve the situation for libcs (such as musl) which are not yet supported and/or do not wish to be explicitly supported, while not affecting supported libcs. More precisely, with this commit, unsupported libcs can request the suppression of any specific uapi definition by defining the correspondings _UAPI_DEF_* macro as 0. This can fix symbol collisions for them, as long as the libc headers are included before the uapi headers. Inclusion in the other order is outside the scope of this commit. All infrastructure in order to enable this fallback for unsupported libcs is already in place, except that libc-compat.h unconditionally defines all _UAPI_DEF_* macros to 1 for all unsupported libcs so that any previous definitions are ignored. In order to fix this, this commit merely makes these definitions conditional. This commit together with the musl libc commit http://git.musl-libc.org/cgit/musl/commit/?id=3D04983f2272382af92eb8f883896= 4ff944fbb8258 fixes for example the following compiler errors when is included after musl's : ./linux/in6.h:32:8: error: redefinition of 'struct in6_addr' ./linux/in6.h:49:8: error: redefinition of 'struct sockaddr_in6' ./linux/in6.h:59:8: error: redefinition of 'struct ipv6_mreq' The comments referencing glibc are still correct, but this file is not only used for glibc any more. Signed-off-by: Felix Janda Reviewed-by: Hauke Mehrtens Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- include/uapi/linux/libc-compat.h | 55 ++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-com= pat.h index 282875cf8056..8254c937c9f4 100644 --- a/include/uapi/linux/libc-compat.h +++ b/include/uapi/linux/libc-compat.h @@ -168,46 +168,99 @@ =20 /* If we did not see any headers from any supported C libraries, * or we are being included in the kernel, then define everything - * that we need. */ + * that we need. Check for previous __UAPI_* definitions to give + * unsupported C libraries a way to opt out of any kernel definition. */ #else /* !defined(__GLIBC__) */ =20 /* Definitions for if.h */ +#ifndef __UAPI_DEF_IF_IFCONF #define __UAPI_DEF_IF_IFCONF 1 +#endif +#ifndef __UAPI_DEF_IF_IFMAP #define __UAPI_DEF_IF_IFMAP 1 +#endif +#ifndef __UAPI_DEF_IF_IFNAMSIZ #define __UAPI_DEF_IF_IFNAMSIZ 1 +#endif +#ifndef __UAPI_DEF_IF_IFREQ #define __UAPI_DEF_IF_IFREQ 1 +#endif /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */ +#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1 +#endif /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ +#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1 +#endif =20 /* Definitions for in.h */ +#ifndef __UAPI_DEF_IN_ADDR #define __UAPI_DEF_IN_ADDR 1 +#endif +#ifndef __UAPI_DEF_IN_IPPROTO #define __UAPI_DEF_IN_IPPROTO 1 +#endif +#ifndef __UAPI_DEF_IN_PKTINFO #define __UAPI_DEF_IN_PKTINFO 1 +#endif +#ifndef __UAPI_DEF_IP_MREQ #define __UAPI_DEF_IP_MREQ 1 +#endif +#ifndef __UAPI_DEF_SOCKADDR_IN #define __UAPI_DEF_SOCKADDR_IN 1 +#endif +#ifndef __UAPI_DEF_IN_CLASS #define __UAPI_DEF_IN_CLASS 1 +#endif =20 /* Definitions for in6.h */ +#ifndef __UAPI_DEF_IN6_ADDR #define __UAPI_DEF_IN6_ADDR 1 +#endif +#ifndef __UAPI_DEF_IN6_ADDR_ALT #define __UAPI_DEF_IN6_ADDR_ALT 1 +#endif +#ifndef __UAPI_DEF_SOCKADDR_IN6 #define __UAPI_DEF_SOCKADDR_IN6 1 +#endif +#ifndef __UAPI_DEF_IPV6_MREQ #define __UAPI_DEF_IPV6_MREQ 1 +#endif +#ifndef __UAPI_DEF_IPPROTO_V6 #define __UAPI_DEF_IPPROTO_V6 1 +#endif +#ifndef __UAPI_DEF_IPV6_OPTIONS #define __UAPI_DEF_IPV6_OPTIONS 1 +#endif +#ifndef __UAPI_DEF_IN6_PKTINFO #define __UAPI_DEF_IN6_PKTINFO 1 +#endif +#ifndef __UAPI_DEF_IP6_MTUINFO #define __UAPI_DEF_IP6_MTUINFO 1 +#endif =20 /* Definitions for ipx.h */ +#ifndef __UAPI_DEF_SOCKADDR_IPX #define __UAPI_DEF_SOCKADDR_IPX 1 +#endif +#ifndef __UAPI_DEF_IPX_ROUTE_DEFINITION #define __UAPI_DEF_IPX_ROUTE_DEFINITION 1 +#endif +#ifndef __UAPI_DEF_IPX_INTERFACE_DEFINITION #define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1 +#endif +#ifndef __UAPI_DEF_IPX_CONFIG_DATA #define __UAPI_DEF_IPX_CONFIG_DATA 1 +#endif +#ifndef __UAPI_DEF_IPX_ROUTE_DEF #define __UAPI_DEF_IPX_ROUTE_DEF 1 +#endif =20 /* Definitions for xattr.h */ +#ifndef __UAPI_DEF_XATTR #define __UAPI_DEF_XATTR 1 +#endif =20 #endif /* __GLIBC__ */ =20 --=20 2.11.0