From patchwork Tue Mar 19 16:51:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 160582 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4099490jad; Tue, 19 Mar 2019 09:52:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvpRYBJ9tNILk4Q/mKuvsju3c6H+yltfql1t38u9djhD0cztkAxz2WPSPW/+K5WId8JY23 X-Received: by 2002:a17:902:5a2:: with SMTP id f31mr3431463plf.119.1553014327430; Tue, 19 Mar 2019 09:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553014327; cv=none; d=google.com; s=arc-20160816; b=I4hbH1qoL0B3w95Tmaj7Gw/4d1R2V6IOkExIGdc2xSDPHqNi3WSLOWhGvj17E9PSNs s0tujzr/8WnJ9eIF97uB5Ub0cSVSa39vjBcKYJpb4gjgN9V17pVDX/fWCkFBwGDvs+fl lDEBtObWKlYXr56yvbgLS6rrKxQ7KCO34fZjaCccYC1xwrv325y3hy5Fvm9afvVkxnjp 5lgJewHORICcuYPEjll7FD+142phm1Btq/xLD79TQ8c++SU917Z2XOaR/pmh2YXQX8lc DifsEk48odn3CCBMWuj84YVFqTXtPLXiRs9agrJgO4s0P/vQ39maLbPPKNdUjXgQxbCN DHqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=b/mFBjguBn/1bwx4Hj53b9ZP4s/rA5eNbpxi7V/A4NI=; b=MdLZbSuke4BV7xWV77DbT0dZVp86znKzJ7gfTNbPtVWsjztAowTrYqI+oE2P5q+SIf PCxlUIcOl4ZOK7L9Lp+MpPSQFGkhl/FkceoXMCinHq95eeiALm8xka0/099xV6sN2JJL F4KD1gPs+N8AzVAgCUEqPOkMYU1HkZadzp71sLM6blaBEFH/Fj5W5dVVPH4yd2rud8Rx KSShAeuV4m+gPyoy4zOw7DsaN1kEcrE/m81p7A8QObfXFwkhWdXwwV6v+vf5Xf0H9yWw 6gcUjBSQ/pN0sq2DzjSVuIYTy2Pt93aFY56WVKpMMzMSipirycUrnTuTmeLQNf85Ze0B CdwA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h21si11935809pgl.346.2019.03.19.09.52.07; Tue, 19 Mar 2019 09:52:07 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727805AbfCSQwF (ORCPT + 31 others); Tue, 19 Mar 2019 12:52:05 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:51607 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726579AbfCSQwE (ORCPT ); Tue, 19 Mar 2019 12:52:04 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1N6bo8-1gx9Gh3uwg-0185ri; Tue, 19 Mar 2019 17:51:54 +0100 From: Arnd Bergmann To: linux-api@vger.kernel.org Cc: linux-arch@vger.kernel.org, netdev@vger.kernel.org, Laura Abbott , Arnd Bergmann , Florian Weimer , Paul Burton , Deepa Dinamani , linux-kernel@vger.kernel.org Subject: [PATCH] uapi: avoid namespace conflict in linux/posix_types.h Date: Tue, 19 Mar 2019 17:51:09 +0100 Message-Id: <20190319165123.3967889-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:9c6ua1+avFyWCBxiOJ8wr7i2NCjA9m8sxVPnpzEziAPVOqkO9TB jH94v4CaVDwDy2nhKbcoqr2MpO7GnCR1WEiwf3PVc2jX9g55Tw8pndUzp7817pW8cwIcH7f 1l1u+p2vIXD1V+qlThaq6H7uVBIoZBGIasl3cYp2+jst0OeDAQxXMoORN0CxC91tZAQr9XX 0g3vkGop8l6gVFn/V9BZQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:yN9VZMfyfjw=:tojk5vDX75dpWby3Z9wnf1 oBTmAuEbS7qqnmpeEEoeY+wWGsdwOCoNb8jW+sg9BrENNb71xGLUyZO8eoFEu5hJfv9UVGlC8 OCy48YS4FY+RLTzbzR1WcBBe3gsLHkq4KSosaV6vPZRQvDepSEFRiWkakK04z6Mu9DjV0fNp7 6HMaOfUmY/vDjnw25FAcOr/iShPOvrJc7+s4veAlV6Xhvig2phEMCWh22XTspo+CtO5bcEFS4 rAlJGWYX2+UFcfMwsIKn56PsnkOM+6ZxAZueaGr2gR8knIw2Hg5WsjpZ05Z0qDb4gfdAAP3yS iD1o7op7rFlEu0k/Em3tvEHZR0iRy+thn0L9NoQz54cLV25VTx+kYpTomkz0oJpvK8+fSzJin 9xoDZHl9v8Dm5PIFFcPPIxzL56nPyhH2pXRNV+PxbVN7bBmZPc4VXSXvM5WxSVoLiiWSYO7+N iEqQ/vQs9QxlPB6XIIG3XMCfGECcDuqG5jN4BiKl3/hkNJlw+ucadM/4OvM+Z5tijtHDPLMqJ vmTJMUrfODtiLMlxabMTUBNGFW9UXr6l1pzOOINZWfisncjooX1mJsfkgeAXiJ+wa6kBC47Yp 8FusZPRFE3sGhK/A3b4JBp1gvjie5L9VLprb1xeunv7Zve97k9a0P06bx+lclFBZ/mSP6uFX+ JTzuaCiobgZeqHhcrxiLXPMVaaTzLHYZS996H4abmAjM99ruC/0dupN8XeRu3plTUb39+ZZma Rd5wsDQeEQdpgKVV9M1OLV4PjijNOtu3YMkwFA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Florian Weimer points out an issue with including linux/posix_types.h from arbitrary other headers: if an application has defined a macro named 'fds_bits', it may stop compiling after a change in the kernel headers. Since fds_bits is a non-reserved identifier in C, that is considered a bug in the kernel headers. The structure definition does not really seem to be helpful here, as the kernel no longer provides macros to manipulate it. The only user of the structure that we could find was in libsanitize. This usage is actually broken, as discussed in the email thread, but this means we cannot just remove the definition from the exported headers, but we can use the __kernel_* namespace for it, to avoid the namespace conflict. The kernel itself just uses bit operations on the typedef without accessing the field by name. This change should also help with the many other kernel headers that include linux/posix_types.h directly or through linux/types.h. Similarly, the definition of __kernel_fsid_t uses a structure with field identifier 'val' that may have the same problem. Again, user space should not rely on the specific field name but instead treat an fsid_t as an opaque identifier. I'm using an #ifdef __KERNEL__ guard here to save us from having to change all kernel code accessing the field. Glibc has changed this from 'val' to '__val' back in 1996/97 when they moved away from using the kernel types directly, it it is likely that nothing uses __kernel_fsid_t any more. MIPS still has another copy of __kernel_fsid_t, but that is in the process of being removed as well. Link: https://lore.kernel.org/lkml/87a7hvded7.fsf@mid.deneb.enyo.de/ Link: https://lore.kernel.org/lkml/20190314173900.25454-1-paul.burton@mips.com/ Cc: Florian Weimer Cc: Paul Burton Fixes: a623a7a1a567 ("y2038: fix socket.h header inclusion") Signed-off-by: Arnd Bergmann --- There was another bug report for the same change just now, so I wouldn't apply this patch yet before we have fully understood the other issue. Sending this for review now since the two problems are most likely independent. --- include/uapi/asm-generic/posix_types.h | 4 ++++ include/uapi/linux/posix_types.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) -- 2.20.0 Acked-by: David S. Miller diff --git a/include/uapi/asm-generic/posix_types.h b/include/uapi/asm-generic/posix_types.h index f0733a26ebfc..2a8c68ac88ca 100644 --- a/include/uapi/asm-generic/posix_types.h +++ b/include/uapi/asm-generic/posix_types.h @@ -77,7 +77,11 @@ typedef __kernel_long_t __kernel_ptrdiff_t; #ifndef __kernel_fsid_t typedef struct { +#ifdef __KERNEL__ int val[2]; +#else + int __kernel_val[2]; +#endif } __kernel_fsid_t; #endif diff --git a/include/uapi/linux/posix_types.h b/include/uapi/linux/posix_types.h index 9a7a740b35a2..a5a5cfc38bbf 100644 --- a/include/uapi/linux/posix_types.h +++ b/include/uapi/linux/posix_types.h @@ -23,7 +23,7 @@ #define __FD_SETSIZE 1024 typedef struct { - unsigned long fds_bits[__FD_SETSIZE / (8 * sizeof(long))]; + unsigned long __kernel_fds_bits[__FD_SETSIZE / (8 * sizeof(long))]; } __kernel_fd_set; /* Type of a signal handler. */