From patchwork Thu Mar 2 16:38:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9601099 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6224B60453 for ; Thu, 2 Mar 2017 17:15:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F0B826BE9 for ; Thu, 2 Mar 2017 17:15:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43C81283EE; Thu, 2 Mar 2017 17:15:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E409326BE9 for ; Thu, 2 Mar 2017 17:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754861AbdCBRNO (ORCPT ); Thu, 2 Mar 2017 12:13:14 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:59055 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752757AbdCBRLM (ORCPT ); Thu, 2 Mar 2017 12:11:12 -0500 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0M323z-1cTsPX2kL9-00swPK; Thu, 02 Mar 2017 17:38:48 +0100 From: Arnd Bergmann To: kasan-dev@googlegroups.com Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-wireless@vger.kernel.org, kernel-build-reports@lists.linaro.org, "David S . Miller" , Arnd Bergmann Subject: [PATCH 03/26] typecheck.h: avoid local variables in typecheck() macro Date: Thu, 2 Mar 2017 17:38:11 +0100 Message-Id: <20170302163834.2273519-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170302163834.2273519-1-arnd@arndb.de> References: <20170302163834.2273519-1-arnd@arndb.de> X-Provags-ID: V03:K0:AIrqmKyqRQ67wAYQk8t9c/pjPS/RSkAJdJekvrBRBqbmiCvnLFe o8BaUssH+eAZQ62Pn8mT1ugAZybrTOYw7VVHAt1RUBetwcrBCMUV4JvG+t1RJj9I8oK06NB YR/kpcvlu4roJdGNqoR+RTsvqqUfHvLyED0K1Tj44SWy2ZeAbWhUNkYxtNoNzeh+G7U+kDU 2FMxzl1dF7IqnYh4VXohA== X-UI-Out-Filterresults: notjunk:1; V01:K0:ZsqvM4Tbs/k=:+NLhOn4olTHAjQ7oKO9htu M8lUTZfnYph6SPih+CCOt061lVEftJNQ74DDDb4V9abPjhY0KT1Rb2KcxMVujEdGyaMUnqZ4D TZZemorKOQxMsgIyKE412GawezSsO0uf1VAwoYmF73ORbj0jyEwfrv5gHyQ/C9mjfONb653yj oPNUbaRt2SXpeG0a/fUo+6YXEUp978qra3fzPqSSvccW834Uu/+RXuypz5mgW9XYLu+b0ibdY 7BNxeN6Qxfdg1ieBCKHopDlGs0Lfhbnh+FvlTUGyGASci8V7QwjO8iw+c7WllK+9Ws+/JGWbe sW+JoLZH0Hjqheu9zueiuwGUKOqD7owfCuoNNeRfc6PD3HZBF7OalR9NkKJfn3SN01p6exhZw vc/yTZtolppRsruu4TCg3EeZ8h776jrvTN5MToJoBi9IjRbvkSonmx9p4ORxCbLHgHMrn5sIP PSkWLkWnUXzl/gyiPp1pQYEZvrnfA8lH6qoXDGcrX0ih7U2XqPg/VdYzbVC53zkZb+G6SjJgk eVUgEiI+IzZBSzTE2QEANeFc0fMC3elKpMCcUKFYWGsOAZkwtocE5Wm4y6gtf5Tc2ybOMk6ZZ 5ebq3iCSrZvl+gRWnXOpQuBPfQ2yISXT2A/bwIRtt826cMxZOu9kXd1DNhKTRoilxue8GS04r HRD6nzzrL+n/R0AS/wvCjwxIl79QvmQNjpF69ByRkCnqmdDUSy8XHlMLyO2iBzdVxEpA= Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With KASAN enabled, the typecheck macro leads to some serious stack memory, as seen in the rt2xxx drivers: drivers/net/wireless/ralink/rt2x00/rt2800lib.c: In function 'rt2800_init_registers': drivers/net/wireless/ralink/rt2x00/rt2800lib.c:5068:1: error: the frame size of 23768 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] drivers/net/wireless/ralink/rt2x00/rt2800lib.c: In function 'rt2800_config_txpower_rt3593.isra.1': drivers/net/wireless/ralink/rt2x00/rt2800lib.c:4126:1: error: the frame size of 14184 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] drivers/net/wireless/ralink/rt2x00/rt2800lib.c: In function 'rt2800_config_channel_rf3053.isra.5': drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2585:1: error: the frame size of 7632 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] If we express the macro in a way that avoids the local variables, this goes away and the stacks are comparable to building without KASAN. Signed-off-by: Arnd Bergmann --- include/linux/typecheck.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/include/linux/typecheck.h b/include/linux/typecheck.h index eb5b74a575be..adb1579fa5f0 100644 --- a/include/linux/typecheck.h +++ b/include/linux/typecheck.h @@ -5,12 +5,7 @@ * Check at compile time that something is of a particular type. * Always evaluates to 1 so you may use it easily in comparisons. */ -#define typecheck(type,x) \ -({ type __dummy; \ - typeof(x) __dummy2; \ - (void)(&__dummy == &__dummy2); \ - 1; \ -}) +#define typecheck(type,x) ({(void)((typeof(type) *)NULL == (typeof(x) *)NULL); 1;}) /* * Check at compile time that 'function' is a certain type, or is a pointer