Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp525868imm; Fri, 14 Sep 2018 02:12:28 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbZfMgJJ6zH58lfc2lhsyl2z/632CPGkJjiPdWKTNVPemrLbR2snVDEqzg2HjiAkw3+PceE X-Received: by 2002:a62:8208:: with SMTP id w8-v6mr11330908pfd.215.1536916348546; Fri, 14 Sep 2018 02:12:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536916348; cv=none; d=google.com; s=arc-20160816; b=iiuQ7QBRG/cmRpCxKB7hppgPbDDhEFO2vNTqW39ZZNc3283natISlGxmF/a2r6yGoD oy6RYuNpvNaigMtjRGsYrFKABNXqgoIWkqcdqeBuALV6Sw+RUSSeKsd4CM1CXrg6AViE /zU5cBAd6WF/JT66q6dk7j3uQIMNFFgs9PhFGL3qrkwwGyqWS7vlo0H+a2OWQ/HN9J7p emprvphQthbliizxBtRZA3nffXOauMCJSl79XVv5KD+139i93updu8zKYqDcIWQ5/uUb 6KDiORw8kUJAwMNzVgiI7T6dzp3wOs0AO3asAwlldBeVP5zTQ7MNZN3tfm2td2zgZhgB jwXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=BhVvzQ0WMIiiveH8tbznscp05Oy6tXnMO0INnwNj2M8=; b=EryxOTnbmZgOGTZlW4OetAJjY06S97sCTDn+Ad0l87WeS2bNu920c0is432xfwDtRl RxUARhXZmj/wAyo204osY+4CmuAOLKn1CFqZmn6iisW/S37MvZrbbHYXMMa6RPssjVxS 3jUwQe/Qw5grL9xeVf+cI3WAwkhSVZA+df4kjUsNI3kTmYUvYZlCP75rK5ZGKkCnHULX 0dWqBKrWa+MuD8UDYDFJXLNPyOzr3iGf72Jf9jMrS2lhIut20wbw0ehlGhF2dcL/Rp2k DdX7tLQ6ogMsXYh1Ugt4LfsFgqrzJ36aMS1CFe19Ztpu2wlnTgR8lm+j4dgsTK924i1r 1ZiA== 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 r7-v6si6972939pga.77.2018.09.14.02.12.13; Fri, 14 Sep 2018 02:12:28 -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 S1728181AbeINOY0 (ORCPT + 99 others); Fri, 14 Sep 2018 10:24:26 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:38958 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728137AbeINOY0 (ORCPT ); Fri, 14 Sep 2018 10:24:26 -0400 Received: by mail-qk1-f196.google.com with SMTP id b19-v6so4773172qkc.6; Fri, 14 Sep 2018 02:10:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BhVvzQ0WMIiiveH8tbznscp05Oy6tXnMO0INnwNj2M8=; b=WLKy+dRqeLgWoKKlDhzsW05JKq2QKcpFbvTHhnvElza80NEHSTBBbCkZlnqh6s4Az5 zs4hge36rIZ3qxajT7D9tl29pl8DHbe7HGS5aPFTw7NU8URwYHiyd+CyQ9ERC1O2sEfJ ltcedCX0YMzlZ3ZF9XNTXcya4AiN/wnEaeeMcBkhKh/U4aNtonWGs3jvMEvso0E2VlTq AFAMsVnMeE+NWu2eS9t7jwFht/KHHLCJ+mipov3DqWdb5M3Dse2S3kwesK42LFrQ7FX/ KOZvK9B1pj9Xf4wTFxYl6OOfcdGVg7K2CLS31v3BO79p1D5rrHCKNjxxnu8QYZpd2XhE d4mg== X-Gm-Message-State: APzg51Cwwakzth4AGAzsdKn393MJMIdb6J+Zi8XA6c6+oNjAnhdsWyip gtWlwRcAHbnAcvQJaulnGUveQg1ejDaRduvL4QI= X-Received: by 2002:a37:6b03:: with SMTP id g3-v6mr7942423qkc.107.1536916251580; Fri, 14 Sep 2018 02:10:51 -0700 (PDT) MIME-Version: 1.0 References: <153622549721.14298.8116794954073122489.stgit@warthog.procyon.org.uk> <153622557736.14298.10350496216090814292.stgit@warthog.procyon.org.uk> In-Reply-To: <153622557736.14298.10350496216090814292.stgit@warthog.procyon.org.uk> From: Arnd Bergmann Date: Fri, 14 Sep 2018 11:10:35 +0200 Message-ID: Subject: Re: [PATCH 11/11] UAPI: Check headers build for C++ [ver #2] To: David Howells Cc: Linux API , Linux Kbuild mailing list , Masahiro Yamada , Michal Marek , Linux Kernel Mailing List , Joseph Myers Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 6, 2018 at 11:21 AM David Howells wrote: > + > +typedef __s8 int8_t; > +typedef __s16 int16_t; > +typedef __s32 int32_t; > +typedef __s64 int64_t; > +typedef __u8 uint8_t; > +typedef __u16 uint16_t; > +typedef __u32 uint32_t; > +typedef __u64 uint64_t; > +typedef long int intptr_t; > +typedef unsigned long int uintptr_t; > +typedef unsigned short u_short; > +typedef unsigned int u_int; > +typedef unsigned long u_long; > +typedef char *caddr_t; > + > +typedef __kernel_clockid_t clockid_t; > +typedef __kernel_ino_t ino_t; > +typedef __kernel_pid_t pid_t; > +typedef __kernel_sa_family_t sa_family_t; > +typedef __kernel_size_t size_t; > +typedef __kernel_uid_t uid_t; > + > +typedef unsigned long elf_greg_t; > +typedef elf_greg_t elf_gregset_t[1]; > +typedef unsigned long long elf_fpregset_t[1]; > +typedef unsigned long long elf_fpxregset_t[1]; > + > +#define INT_MIN ((int)0x80000000) > +#define INT_MAX ((int)0x7fffffff) > + > +extern size_t strlen(const char *); > +extern void *memset(void *, int, size_t); > +extern void *memcpy(void *, const void *, size_t); > +extern __u16 ntohs(__u16); > +extern __u16 htons(__u16); > +extern __u32 ntohl(__u32); > +extern __u32 htonl(__u32); > + > +typedef uint32_t grant_ref_t; > +typedef uint16_t domid_t; > +typedef unsigned long xen_pfn_t; > + > +#define MSG_FIN 0x200 > + > +typedef int SVGA3dMSPattern; > +typedef int SVGA3dMSQualityLevel; > + > +struct sockaddr > +{ > + sa_family_t sa_family; > + char sa_data[14]; > +}; > +#define sockaddr_storage __kernel_sockaddr_storage I think we need to reduce that list as much as we can. In https://patchwork.ozlabs.org/patch/968814/, Joseph Myers pointed out header file (linux/elfcore.h) that simply cannot be included from user space at all, because its dependencies cannot be met without running into conflicting type definitions, and he would like to include that file in order to automatically check that it's compatible with the glibc version (I pointed out a couple of architectures on which it is in fact incompatible right now). In the list above, I see multiple classes of bugs that could be addressed: - references to identifiers that are only present in kernel internal headers: SVGA3dMSPattern, MSG_FIN, xen_pfn_t, ... I think these are all simple bugs, and we should either remove the references, or make sure the respective dependencies are included in the uapi headers as well, possibly renamed with a __kernel_ prefix to avoid clashing with user space headers. - references to user space types that should use the uapi internal types: sockaddr_storage, clockid_t, uid_t, ... I think these just need to get the __kernel_prefix consistently as we did a few years ago. Note that using the headers otherwise is broken anyway when the types in libc are different from the ones in the kernel. - standard types (uint32_t): either include the correct user space headers ifndef __KERNEL__ or use the kernel types - standard functions (memcpy(), ntohs(), ...): These should already be handled in the headers by including the user space. If we missed any, we should probably do the same thing there. Arnd