From patchwork Fri Apr 25 14:56:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Marek X-Patchwork-Id: 4063761 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CFE7ABFF02 for ; Fri, 25 Apr 2014 14:57:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 16D922037A for ; Fri, 25 Apr 2014 14:57:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E5252200BE for ; Fri, 25 Apr 2014 14:57:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751716AbaDYO5G (ORCPT ); Fri, 25 Apr 2014 10:57:06 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45575 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751589AbaDYO5F (ORCPT ); Fri, 25 Apr 2014 10:57:05 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BD890AC36; Fri, 25 Apr 2014 14:57:04 +0000 (UTC) Received: by sepie.suse.cz (Postfix, from userid 10020) id 6CF4940260; Fri, 25 Apr 2014 16:57:04 +0200 (CEST) From: Michal Marek To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: David Howells Subject: [RFC] UAPI: Prevent kernel modules from using the exported headers Date: Fri, 25 Apr 2014 16:56:48 +0200 Message-Id: <1398437808-9263-1-git-send-email-mmarek@suse.cz> X-Mailer: git-send-email 1.8.4.5 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Mandriva/Mageia and SUSE have been adding an #error statement to the /usr/include/linux/version.h header and it does trigger with broken out of tree modules occasionally. Adding it to all exported headers should not hurt and is easier to implement. Signed-off-by: Michal Marek --- scripts/headers_install.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh index 5de5660..1c787da 100644 --- a/scripts/headers_install.sh +++ b/scripts/headers_install.sh @@ -30,16 +30,19 @@ trap 'rm -f "$OUTDIR/$FILE" "$OUTDIR/$FILE.sed"' EXIT for i in "$@" do FILE="$(basename "$i")" + scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$SRCDIR/$i" \ + > "$OUTDIR/$FILE.sed" sed -r \ + -e '1i #ifdef __KERNEL__' \ + -e '1i #error Kernel modules must not include files from /usr/include/' \ + -e '1i #endif' \ -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \ -e 's/__attribute_const__([ \t]|$)/\1/g' \ -e 's@^#include @@' \ -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \ -e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \ -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \ - "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1 - scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \ - > "$OUTDIR/$FILE" + "$OUTDIR/$FILE.sed" >"$OUTDIR/$FILE" || exit 1 [ $? -gt 1 ] && exit 1 rm -f "$OUTDIR/$FILE.sed" done