From patchwork Mon Mar 28 17:21:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 12793953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91EEFC433EF for ; Mon, 28 Mar 2022 17:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237936AbiC1RYA (ORCPT ); Mon, 28 Mar 2022 13:24:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237418AbiC1RYA (ORCPT ); Mon, 28 Mar 2022 13:24:00 -0400 Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 764F564BCE; Mon, 28 Mar 2022 10:22:19 -0700 (PDT) Received: from grover.. (133-32-185-133.west.xps.vectant.ne.jp [133.32.185.133]) (authenticated) by conuserg-12.nifty.com with ESMTP id 22SHLdGY017332; Tue, 29 Mar 2022 02:21:39 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com 22SHLdGY017332 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1648488100; bh=a1RDShE0uWC0OhbAt+4QzV+tQ/pdHe8WAiRE756c3W0=; h=From:To:Cc:Subject:Date:From; b=RCDk9PCuaJFsqcnuTc1cCV86kdxgz9+vRh03BPeaMVSz9jxwij1W1oCar3Mi7++Q3 3LdkaOwdZsqz7bWaGJVQ9U54S0IWu39zjEDVnx/9YcIyg/ox5+gdnDV4EdNgTd6XG0 m91SPvkhunrgydwR6iwo6IuoVQLXg6ZNRB8cAA+y3fpUmqLnQ+Vm6n+y9keyuaL5mZ 6gIsIKqzPHRO/rTRTqM9z8FgGzOCAqePQIj3lIvtx1YlJf5XBvXj4mDaqj7jOR16cN 3ETTch9XoG6fk/EvJpZc0VNUXSPnV+WDgg1mWEF65vxJ+cH664GWI2JWKFlcQRs7Yw DdibEitGXs14Q== X-Nifty-SrcIP: [133.32.185.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, Masahiro Yamada , David Airlie Subject: [PATCH 1/2] agpgart.h: do not include from exported header Date: Tue, 29 Mar 2022 02:21:29 +0900 Message-Id: <20220328172130.197319-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Commit 35d0f1d54ecd ("include/uapi/linux/agpgart.h: include stdlib.h in userspace") included to fix the unknown size_t error, but I do not think it is the right fix. This header already uses __kernel_size_t a few lines below. Replace the remaining size_t, and stop including . Signed-off-by: Masahiro Yamada --- include/uapi/linux/agpgart.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/agpgart.h b/include/uapi/linux/agpgart.h index f5251045181a..9cc3448c0b5b 100644 --- a/include/uapi/linux/agpgart.h +++ b/include/uapi/linux/agpgart.h @@ -52,7 +52,6 @@ #ifndef __KERNEL__ #include -#include struct agp_version { __u16 major; @@ -64,10 +63,10 @@ typedef struct _agp_info { __u32 bridge_id; /* bridge vendor/device */ __u32 agp_mode; /* mode info of bridge */ unsigned long aper_base;/* base of aperture */ - size_t aper_size; /* size of aperture */ - size_t pg_total; /* max pages (swap + system) */ - size_t pg_system; /* max pages (system) */ - size_t pg_used; /* current pages used */ + __kernel_size_t aper_size; /* size of aperture */ + __kernel_size_t pg_total; /* max pages (swap + system) */ + __kernel_size_t pg_system; /* max pages (system) */ + __kernel_size_t pg_used; /* current pages used */ } agp_info; typedef struct _agp_setup { From patchwork Mon Mar 28 17:21:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 12793954 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C719FC433FE for ; Mon, 28 Mar 2022 17:22:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237418AbiC1RYT (ORCPT ); Mon, 28 Mar 2022 13:24:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232718AbiC1RYT (ORCPT ); Mon, 28 Mar 2022 13:24:19 -0400 Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BF3864BD1; Mon, 28 Mar 2022 10:22:37 -0700 (PDT) Received: from grover.. (133-32-185-133.west.xps.vectant.ne.jp [133.32.185.133]) (authenticated) by conuserg-12.nifty.com with ESMTP id 22SHLdGZ017332; Tue, 29 Mar 2022 02:21:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com 22SHLdGZ017332 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1648488100; bh=UH1VDPx6gdMj3puEVBexYhQw2eBB8T7IsyNihS4F0YM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ov2CdN5oQp5TdxkGzLQIabmizxCidhSCe2jkecUC2Jq9B3bLXl3Amuypl11knvFxH zVvOPyiEb2bcuTrKFa0xKgHp5J4TL2xG4JF2p9dpnvwnO/r2Mvx+bISGokVSkRx3tL 3IOSC8xdtSKS1GdN3z+hoV88w0tZZDT511BP51yCVZCcYuPlm6VoWr0tHdynR+qsc3 zGAsqzfk8OQvxw/FSRqLy84uc/Bq/Xk26kOn/GCKJzP94mvRRMmpiVsOgINjJ9UEMp 8qkmwB9JJF/qasA9MuXNQErhk5LtIEBvTSRQgOUEvejeZi92XLgC4HWpg0J8+6W+M6 62MnpZKhFg3/Q== X-Nifty-SrcIP: [133.32.185.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, Masahiro Yamada , "Dmitry V. Levin" , Elliot Berman , Geert Uytterhoeven , Greg Kroah-Hartman , Nick Desaulniers Subject: [PATCH 2/2] kbuild: forbid exported headers from including , Date: Tue, 29 Mar 2022 02:21:30 +0900 Message-Id: <20220328172130.197319-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220328172130.197319-1-masahiroy@kernel.org> References: <20220328172130.197319-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Some UAPI headers included , like this: #ifndef __KERNEL__ #include #endif As it turned out, they just included it for no good reason. After some fixes, now I can compile-test UAPI headers (CONFIG_UAPI_HEADER_TEST=y) without included. To avoid somebody getting it back again, this commit adds the dummy header, usr/dummy-include/stdlib.h I added $(srctree)/usr/dummy-include to the header search paths. Because it is searched before the system directories, if someone tries to include , they will see the error message. While I am here, I also replaced $(objtree)/usr/include with $(obj), but it is just a small refactoring. If we achieve the situation where none of system headers is included from exported kernel headers (i.e. kernel headers become self-contained), we might be able to add -nostdinc, but that is much far from where we stand now. (see many no-header-test lines in usr/include/Makefile) As a realistic solution, you can forbid header inclusion individually by putting a dummy header into usr/dummy-include/. Currently, no header include . I put it as well before somebody attempts to use it. Signed-off-by: Masahiro Yamada Reviewed-by: Greg Kroah-Hartman --- usr/dummy-include/stdbool.h | 7 +++++++ usr/dummy-include/stdlib.h | 7 +++++++ usr/include/Makefile | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 usr/dummy-include/stdbool.h create mode 100644 usr/dummy-include/stdlib.h diff --git a/usr/dummy-include/stdbool.h b/usr/dummy-include/stdbool.h new file mode 100644 index 000000000000..54ff9e9c90ac --- /dev/null +++ b/usr/dummy-include/stdbool.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _STDBOOL_H +#define _STDBOOL_H + +#error "Please do not include from exported headers" + +#endif /* _STDBOOL_H */ diff --git a/usr/dummy-include/stdlib.h b/usr/dummy-include/stdlib.h new file mode 100644 index 000000000000..e8c21888e371 --- /dev/null +++ b/usr/dummy-include/stdlib.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _STDLIB_H +#define _STDLIB_H + +#error "Please do not include from exported headers" + +#endif /* _STDLIB_H */ diff --git a/usr/include/Makefile b/usr/include/Makefile index fa9819e022b7..7740777b49f8 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -15,7 +15,7 @@ UAPI_CFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) # USERCFLAGS might contain sysroot location for CC. UAPI_CFLAGS += $(USERCFLAGS) -override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include +override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I $(obj) -I $(srctree)/usr/dummy-include # The following are excluded for now because they fail to build. #