[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNAQ4Z0BxqFrNdQDWJqbJBW9bSvnzVkvJTZZ-1mMKD7Y6SQ@mail.gmail.com>
Date: Sun, 30 Jun 2019 10:35:24 +0900
From: Masahiro Yamada <yamada.masahiro@...ionext.com>
To: Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>
Cc: Song Liu <songliubraving@...com>,
Michal Marek <michal.lkml@...kovi.net>, bpf@...r.kernel.org,
Daniel Borkmann <daniel@...earbox.net>,
Jani Nikula <jani.nikula@...el.com>,
Networking <netdev@...r.kernel.org>,
Palmer Dabbelt <palmer@...ive.com>,
Alexei Starovoitov <ast@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Albert Ou <aou@...s.berkeley.edu>, Yonghong Song <yhs@...com>,
linux-riscv@...ts.infradead.org, Sam Ravnborg <sam@...nborg.org>,
Martin KaFai Lau <kafai@...com>
Subject: Re: [PATCH v3 1/4] kbuild: compile-test UAPI headers to ensure they
are self-contained
On Fri, Jun 28, 2019 at 1:40 AM Masahiro Yamada
<yamada.masahiro@...ionext.com> wrote:
>
> Multiple people have suggested compile-testing UAPI headers to ensure
> they can be really included from user-space. "make headers_check" is
> obviously not enough to catch bugs, and we often leak references to
> kernel-space definition to user-space.
>
> Use the new header-test-y syntax to implement it. Please note exported
> headers are compile-tested with a completely different set of compiler
> flags. The header search path is set to $(objtree)/usr/include since
> exported headers should not include unexported ones.
>
> We use -std=gnu89 for the kernel space since the kernel code highly
> depends on GNU extensions. On the other hand, UAPI headers should be
> written in more standardized C, so they are compiled with -std=c90.
> This will emit errors if C++ style comments, the keyword 'inline', etc.
> are used. Please use C style comments (/* ... */), '__inline__', etc.
> in UAPI headers.
>
> There is additional compiler requirement to enable this test because
> many of UAPI headers include <stdlib.h>, <sys/ioctl.h>, <sys/time.h>,
> etc. directly or indirectly. You cannot use kernel.org pre-built
> toolchains [1] since they lack <stdlib.h>.
>
> I added scripts/cc-system-headers.sh to check the system header
> availability, which CONFIG_UAPI_HEADER_TEST depends on.
Perhaps, we could use scripts/cc-can-link.sh for this purpose.
The intention is slightly different, but a compiler to link
user-space programs must provide necessary standard headers.
--
Best Regards
Masahiro Yamada
Powered by blists - more mailing lists