From patchwork Fri Sep 22 21:29:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9967115 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 706F260381 for ; Fri, 22 Sep 2017 21:33:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62C252884B for ; Fri, 22 Sep 2017 21:33:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5677229A28; Fri, 22 Sep 2017 21:33:05 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 D272A2884B for ; Fri, 22 Sep 2017 21:33:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752793AbdIVVcr (ORCPT ); Fri, 22 Sep 2017 17:32:47 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:54979 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbdIVVco (ORCPT ); Fri, 22 Sep 2017 17:32:44 -0400 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0M1eYM-1d7P5u1rre-00tmVw; Fri, 22 Sep 2017 23:31:12 +0200 From: Arnd Bergmann To: Jiri Pirko Cc: Arnd Bergmann , Mauro Carvalho Chehab , Arend van Spriel , Kalle Valo , "David S. Miller" , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Masahiro Yamada , Michal Marek , Andrew Morton , Kees Cook , Geert Uytterhoeven , Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com, kasan-dev@googlegroups.com, linux-kbuild@vger.kernel.org, Jakub Jelinek , =?UTF-8?q?Martin=20Li=C5=A1ka?= , stable@vger.kernel.org Subject: [PATCH v4 7/9] rocker: fix rocker_tlv_put_* functions for KASAN Date: Fri, 22 Sep 2017 23:29:18 +0200 Message-Id: <20170922212930.620249-8-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170922212930.620249-1-arnd@arndb.de> References: <20170922212930.620249-1-arnd@arndb.de> X-Provags-ID: V03:K0:ocpyRAgyJ4TPg1pGKyh1loLMcVmRjDmXhzPdpsOW+QsUHEzbq8a ygbIwmnz74dwWw3W7IXJr53pPmj74VDTVlUH77KmuPec6bE8u/Wp3H6itdpQbuNG+Xo1XFs gKa668/udITvo896lSBqLk7HeggqYM8zOG9naAGMUhgzfSmf6iqbi3dzKytgnhxWWUGipBa 8GAA2GCKQI1yAeqqjjfRw== X-UI-Out-Filterresults: notjunk:1; V01:K0:B6NOhgN9314=:14eLMuBTywzhXmykIvWIJC 3DYHueB4rVOedFXnWLeyOd8JhFL1CemgSjhm+K501ZtYu7f+tAHK6WEbkdAgmjaxQiQA4EYEL BMcxPI/lj/lVkJlmr+29g/0wkH1SxtRO1/+T9q3YyGp3P2PvOk883uqmX+bOQAV0AM9vVghan +4LEdi0ejSIxJS+EgpVC6V8GGnwm6rMalXJUJjF1skvdPpDjOqmX1JAEn9YQ9Ij3D6nSmsIAb l1vrEQKzNoGHDxCRpT0DkJnSMxq7ZVVEKlu4z5F6qiMXo8HbEVJdaX5h9tNDBbwRIoQNDnV+O k1dHFefZpL7DBufQJHdk3dbzE9gUYtipvPUVfs1MAixQ6t0+i0DkdvqcHAidfr8b5EZ4NHuXn DgnYlCv3mTWo5iEHbnVWk+0irlx48tVqMZdGH9xbAGH7E7anzIo7+Frr/nx/SoRC6qd+YVnuW u5gWbPrhuwioGcPB1u8KGr9wPwHjKsLe8PMBsrfH/pEPwWp99W8Gwisu+bQXaM4LtB7J8Ee1b L7bEbPbRQ+Qzw4D4ZxU9ALTtQKFktA0SDRuXkd19LP3KyO3I3Wew7XUd9WknyzngULpUYF7br HZZYTlSaOJMeYzK7UKyvy36XxD6NB0yteHRRlDrlRB+U+Q7Q02iJv6ub1XStVDAeOdqWpjc/8 sr5UNYZ8BuX8G3776Hv0UVZ69XceLefujyy7qLrIctefn7tZNgyAy5c1lB6wdfxDemCOmlcx/ 7XJ34tG8rs2gcGC57KE6bmWKXwEIH9jbdprp9Q== 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 Inlining these functions creates lots of stack variables that each take 64 bytes when KASAN is enabled, leading to this warning about potential stack overflow: drivers/net/ethernet/rocker/rocker_ofdpa.c: In function 'ofdpa_cmd_flow_tbl_add': drivers/net/ethernet/rocker/rocker_ofdpa.c:621:1: error: the frame size of 2752 bytes is larger than 1536 bytes [-Werror=frame-larger-than=] gcc-8 can now consolidate the stack slots itself, but on older versions we get the same behavior by using a temporary variable that holds a copy of the inline function argument. Cc: stable@vger.kernel.org Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715 Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/rocker/rocker_tlv.h | 48 ++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/rocker/rocker_tlv.h b/drivers/net/ethernet/rocker/rocker_tlv.h index a63ef82e7c72..dfae3c9d57c6 100644 --- a/drivers/net/ethernet/rocker/rocker_tlv.h +++ b/drivers/net/ethernet/rocker/rocker_tlv.h @@ -139,40 +139,52 @@ rocker_tlv_start(struct rocker_desc_info *desc_info) int rocker_tlv_put(struct rocker_desc_info *desc_info, int attrtype, int attrlen, const void *data); -static inline int rocker_tlv_put_u8(struct rocker_desc_info *desc_info, - int attrtype, u8 value) +static inline int +rocker_tlv_put_u8(struct rocker_desc_info *desc_info, int attrtype, u8 value) { - return rocker_tlv_put(desc_info, attrtype, sizeof(u8), &value); + u8 tmp = value; /* work around GCC PR81715 */ + + return rocker_tlv_put(desc_info, attrtype, sizeof(u8), &tmp); } -static inline int rocker_tlv_put_u16(struct rocker_desc_info *desc_info, - int attrtype, u16 value) +static inline int +rocker_tlv_put_u16(struct rocker_desc_info *desc_info, int attrtype, u16 value) { - return rocker_tlv_put(desc_info, attrtype, sizeof(u16), &value); + u16 tmp = value; + + return rocker_tlv_put(desc_info, attrtype, sizeof(u16), &tmp); } -static inline int rocker_tlv_put_be16(struct rocker_desc_info *desc_info, - int attrtype, __be16 value) +static inline int +rocker_tlv_put_be16(struct rocker_desc_info *desc_info, int attrtype, __be16 value) { - return rocker_tlv_put(desc_info, attrtype, sizeof(__be16), &value); + __be16 tmp = value; + + return rocker_tlv_put(desc_info, attrtype, sizeof(__be16), &tmp); } -static inline int rocker_tlv_put_u32(struct rocker_desc_info *desc_info, - int attrtype, u32 value) +static inline int +rocker_tlv_put_u32(struct rocker_desc_info *desc_info, int attrtype, u32 value) { - return rocker_tlv_put(desc_info, attrtype, sizeof(u32), &value); + u32 tmp = value; + + return rocker_tlv_put(desc_info, attrtype, sizeof(u32), &tmp); } -static inline int rocker_tlv_put_be32(struct rocker_desc_info *desc_info, - int attrtype, __be32 value) +static inline int +rocker_tlv_put_be32(struct rocker_desc_info *desc_info, int attrtype, __be32 value) { - return rocker_tlv_put(desc_info, attrtype, sizeof(__be32), &value); + __be32 tmp = value; + + return rocker_tlv_put(desc_info, attrtype, sizeof(__be32), &tmp); } -static inline int rocker_tlv_put_u64(struct rocker_desc_info *desc_info, - int attrtype, u64 value) +static inline int +rocker_tlv_put_u64(struct rocker_desc_info *desc_info, int attrtype, u64 value) { - return rocker_tlv_put(desc_info, attrtype, sizeof(u64), &value); + u64 tmp = value; + + return rocker_tlv_put(desc_info, attrtype, sizeof(u64), &tmp); } static inline struct rocker_tlv *