From patchwork Sat Feb 6 00:44:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 8240841 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0FFD39F4DD for ; Sat, 6 Feb 2016 00:45:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 33622201DD for ; Sat, 6 Feb 2016 00:45:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A823203B4 for ; Sat, 6 Feb 2016 00:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750808AbcBFApM (ORCPT ); Fri, 5 Feb 2016 19:45:12 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:36541 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750760AbcBFApK (ORCPT ); Fri, 5 Feb 2016 19:45:10 -0500 Received: by mail-pf0-f173.google.com with SMTP id n128so76683313pfn.3 for ; Fri, 05 Feb 2016 16:45:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition; bh=anQuhl2W9jFkCIz275dS9boQYY2bdlwimHEQzrtkdpY=; b=Z6EoeH8VAriQbRNb2amUeKdVy2uTbAPibyU/P1lTJwOTz/I7r+Ht5pJcPOBAHpxTzg OHV6NN7aFUnrWzDYNpzYsybMDGblHxIUDdbHo53WBdxUZgUosRFk4ZlfjPg6sUrVI/VC 8tQBMl/KI+O/rT8+EtsBkmfYbT59Jo186SV4U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition; bh=anQuhl2W9jFkCIz275dS9boQYY2bdlwimHEQzrtkdpY=; b=QHFPwf4rrvCP0Bhj4gNIdVx07zHjQEFP6QOja9+Kvx56leNooOynJt9RrOYrKejBz9 XZvZz8rnGYvK38LefX1nNmC/s+pDn4ddxUEPp6Eut+lzpv6EXWfT0pzNPpYjqvjB8V3s zEF+ASmxMyXf6eDhwXP3Pwvv2CYpStuX4z0cOl61Rv6pXslRfaNftcWB/Jc6j41UXOXV YEhHH/ndC9Qg2AAQB2+TbO5pxoGBl0ikia3amfFUSZ522/3RkKBSkLH8rKbgzguEQgU0 uFWAcgGuLVZ3btcjCeXVynwz5JV5Vi0iEmTfp7xSkmwlM2x3nYxWjRpr/QAO1Ci2aJze dWnw== X-Gm-Message-State: AG10YOSk+zCN590etWEgInkK7mC+hlbDCk4VybUGjmFi80WABn0sVRhbzXfQz4zdkD7Uzg== X-Received: by 10.98.0.135 with SMTP id 129mr24089060pfa.156.1454719510340; Fri, 05 Feb 2016 16:45:10 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x1sm27017889pfi.42.2016.02.05.16.45.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Feb 2016 16:45:09 -0800 (PST) Date: Fri, 5 Feb 2016 16:44:38 -0800 From: Kees Cook To: Michal Marek Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: [PATCH] kbuild: disable Android-specific compiler features Message-ID: <20160206004438.GA21780@www.outflux.net> MIME-Version: 1.0 Content-Disposition: inline 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 The Android compilers enable some non-standard features by default. While most Android build systems inject the needed "-mno-android" option via KCFLAGS, it happens too late (at least on x86_64), since KBUILD_CFLAGS gains KCFLAGS after running (and failing) many cc-option tests. (For example, the stack-protector tests happen after arch-specific KBUILD_CFLAGS are added but before the external KCFLAGS are added.) As such, we should notice this option and immediately turn it on as the first cc-option test we run. Signed-off-by: Kees Cook --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 6c1a3c247988..126c98b582bb 100644 --- a/Makefile +++ b/Makefile @@ -393,6 +393,10 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -Wno-format-security \ -std=gnu89 +# We must turn off the Android-specific compiler options as early as possible +# otherwise cc-option calls below may erroneously fail. +KBUILD_CFLAGS += $(call cc-option,-mno-android,) + KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := KBUILD_AFLAGS := -D__ASSEMBLY__