From patchwork Fri Sep 22 21:29:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 114106 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3758166qgf; Fri, 22 Sep 2017 14:33:15 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCvo5Kwdtx6r0qVLrnz33++2oIsKcw2ufBozuIM9M4DQA1vonhJAX4+8VD0C/XokcNZgulJ X-Received: by 10.98.89.91 with SMTP id n88mr409694pfb.280.1506115995408; Fri, 22 Sep 2017 14:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506115995; cv=none; d=google.com; s=arc-20160816; b=UTZuIjmhOwa4gkh38c9ZeNxEiKiYSDVSZvdi4f2bmspdwBWOIIMv1jb6wXenGA011t K4RJ7rZIXYRRz9ErgpRrovPKxE/9PFHKLS+8vb2IU1aqg1AZC91BzwQ6cRTb5NXxfTK5 N1klgEa/MyVLvaEC4GYBCtMFDbc1a5d7xAvR8CZq6OSlaTc/v5wA4fVLYyef/VlYDsz4 gwAx5mFLLfvM0UXFx5p24FoOxfpXhrwlP+vbbzqVrh9W0jaXfIR8JZ1IYuvR+eW28zji zx/YncQGXKl0Aj+aly11y6FvQvuHW1s8RX7qMAnPY3i0qVJnSboHmSTmRq/QU4xitymg IjJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Ik2NwolvGKQG64ElNYa7cqsOmRtXfQEeNqRmTEqJRqU=; b=m5LD6KcUunLPONbMj7996ouT/G9qt7neo0Gmuk5Mgni6ig2N6Qh8/ZJcCR1AlBIbKX 6cCgc+69ka1l4K2Kob579JAd3rus3SoxiAMrfd65R9P7KPKdJ8MjCSq1ZbTJhITgRlWq sBco9HUDsOuDkOyxdm8ilrKXibbugIO/1PeW79pXd97Yt36rJB2MStYFDASk7owFfhfe 28Pa+ZlKPkL2w4Zu4lJsveMm+IZSRDYD7ZTUqSyzXAyo7tEfVOqyv4y61f+oMkhpGpWB QQTMlatk43HPZ9hjcRs8Rer+S2fcQpLBP51VKOOeetykvVmede0vjaUfHA6LxsG7/MS/ dWeg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u19si395139pfg.303.2017.09.22.14.33.15; Fri, 22 Sep 2017 14:33:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752851AbdIVVdN (ORCPT + 26 others); Fri, 22 Sep 2017 17:33:13 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:56769 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752622AbdIVVco (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 0M4Nqe-1dAAmn2q4a-00yiSw; Fri, 22 Sep 2017 23:31:17 +0200 From: Arnd Bergmann To: "David S. Miller" Cc: Arnd Bergmann , Mauro Carvalho Chehab , Jiri Pirko , Arend van Spriel , Kalle Valo , 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_Li=C5=A1ka?= , stable@vger.kernel.org Subject: [PATCH v4 8/9] netlink: fix nla_put_{u8,u16,u32} for KASAN Date: Fri, 22 Sep 2017 23:29:19 +0200 Message-Id: <20170922212930.620249-9-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:5fd1PTIUsekEKn7pLd/yVh+583BOgexHMgOgtoE0B0k3AZ7JFZB QeOdCMI5g7g/hlRkL+Y0YWh+oTcfYKkUE74Q+eF2vgjis7kPQRnQeM6J3IHBidP5DPIxw7U gDVEglAHPZIpuhw3Afg6VAnPTV3q47rzIwadEGv+oj5moS7tyu8t5clK9NVIH/4HciFa1rt 51nJ76jGOOMf+MaLKpnbw== X-UI-Out-Filterresults: notjunk:1; V01:K0:4DaHNn7aP90=:TI5z2YahQJXcnawvZesEZ4 3GZZKWXODNrwqpWadAx73qyJsAIchEtJlgNIcc1IhSAq5YRcwB+fyJANBnbV3F8SPuh2QAw2m DexrXYamIrtbn/3zbdbTiV0KVtS9ewB06MPYMwbF9km0gREPrx1iHRr3V03f4E/8eKttXYU+z OhchkVXlVIxFZ9R1AP4YMKyOr5W6YvCUyoVhPpxiDwZgHGU0+j+r+5kwfp3IEQHV7DqTCzK2i gOPE+BK2YpmIQgehISnzd3zBMWK73Ptj9GRCK/MVI345b84ESfjmRiu4VNNOgcLz+hJcl+D7c siHtvy8yTP7CwaVvDfkYsK2u19mWFVnD9MExI+3H26B3kKH47w8lV+//1iEfForfUJ9xxxyNn WpwrhPDTwJ5ikyLv0TVwpuU2ntb4HWgazB3kxUhuyhcY34lZinb6hikl5RDmeKhV1KBu4eKeG PR0Ou6VHiXe4F7onQhMFCYjcKXsE1O5mKLOJekusbTx2pk8THlvJB6xpSoXQq7nUN4pPWtAsU TR0+Fb4Kodq3MNgLcHoRTiiq2vaJh4+qTagwwgW7312kkkZs0OEUJdUIN1xxK7wr/LswZJcwg 410OiY3yvHNTyFGmYxbhUbw5VYHLMT70+rEPjOQiJlwNWco5TBGhy6Sp5BYERsg+yzHSGFAny 5HJan2BQs2SNdYu4SYukC3cbxMDTf9SoQzoGE6OZS17uTYrhiaVGvkyEIuvXf7S94QLYidT7J HovbvnlI7l6owwqlln3Jw9TBMapCx/E3K0CRzA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When CONFIG_KASAN is enabled, the "--param asan-stack=1" causes rather large stack frames in some functions. This goes unnoticed normally because CONFIG_FRAME_WARN is disabled with CONFIG_KASAN by default as of commit 3f181b4d8652 ("lib/Kconfig.debug: disable -Wframe-larger-than warnings with KASAN=y"). The kernelci.org build bot however has the warning enabled and that led me to investigate it a little further, as every build produces these warnings: net/wireless/nl80211.c:4389:1: warning: the frame size of 2240 bytes is larger than 2048 bytes [-Wframe-larger-than=] net/wireless/nl80211.c:1895:1: warning: the frame size of 3776 bytes is larger than 2048 bytes [-Wframe-larger-than=] net/wireless/nl80211.c:1410:1: warning: the frame size of 2208 bytes is larger than 2048 bytes [-Wframe-larger-than=] net/bridge/br_netlink.c:1282:1: warning: the frame size of 2544 bytes is larger than 2048 bytes [-Wframe-larger-than=] Most of this problem is now solved in gcc-8, which can consolidate the stack slots for the inline function arguments. On older compilers we can add a workaround by declaring a local variable in each function to pass 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 --- include/net/netlink.h | 73 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 18 deletions(-) -- 2.9.0 diff --git a/include/net/netlink.h b/include/net/netlink.h index e51cf5f81597..14c289393071 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -773,7 +773,10 @@ static inline int nla_parse_nested(struct nlattr *tb[], int maxtype, */ static inline int nla_put_u8(struct sk_buff *skb, int attrtype, u8 value) { - return nla_put(skb, attrtype, sizeof(u8), &value); + /* temporary variables to work around GCC PR81715 with asan-stack=1 */ + u8 tmp = value; + + return nla_put(skb, attrtype, sizeof(u8), &tmp); } /** @@ -784,7 +787,9 @@ static inline int nla_put_u8(struct sk_buff *skb, int attrtype, u8 value) */ static inline int nla_put_u16(struct sk_buff *skb, int attrtype, u16 value) { - return nla_put(skb, attrtype, sizeof(u16), &value); + u16 tmp = value; + + return nla_put(skb, attrtype, sizeof(u16), &tmp); } /** @@ -795,7 +800,9 @@ static inline int nla_put_u16(struct sk_buff *skb, int attrtype, u16 value) */ static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value) { - return nla_put(skb, attrtype, sizeof(__be16), &value); + __be16 tmp = value; + + return nla_put(skb, attrtype, sizeof(__be16), &tmp); } /** @@ -806,7 +813,9 @@ static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value) */ static inline int nla_put_net16(struct sk_buff *skb, int attrtype, __be16 value) { - return nla_put_be16(skb, attrtype | NLA_F_NET_BYTEORDER, value); + __be16 tmp = value; + + return nla_put_be16(skb, attrtype | NLA_F_NET_BYTEORDER, tmp); } /** @@ -817,7 +826,9 @@ static inline int nla_put_net16(struct sk_buff *skb, int attrtype, __be16 value) */ static inline int nla_put_le16(struct sk_buff *skb, int attrtype, __le16 value) { - return nla_put(skb, attrtype, sizeof(__le16), &value); + __le16 tmp = value; + + return nla_put(skb, attrtype, sizeof(__le16), &tmp); } /** @@ -828,7 +839,9 @@ static inline int nla_put_le16(struct sk_buff *skb, int attrtype, __le16 value) */ static inline int nla_put_u32(struct sk_buff *skb, int attrtype, u32 value) { - return nla_put(skb, attrtype, sizeof(u32), &value); + u32 tmp = value; + + return nla_put(skb, attrtype, sizeof(u32), &tmp); } /** @@ -839,7 +852,9 @@ static inline int nla_put_u32(struct sk_buff *skb, int attrtype, u32 value) */ static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value) { - return nla_put(skb, attrtype, sizeof(__be32), &value); + __be32 tmp = value; + + return nla_put(skb, attrtype, sizeof(__be32), &tmp); } /** @@ -850,7 +865,9 @@ static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value) */ static inline int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 value) { - return nla_put_be32(skb, attrtype | NLA_F_NET_BYTEORDER, value); + __be32 tmp = value; + + return nla_put_be32(skb, attrtype | NLA_F_NET_BYTEORDER, tmp); } /** @@ -861,7 +878,9 @@ static inline int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 value) */ static inline int nla_put_le32(struct sk_buff *skb, int attrtype, __le32 value) { - return nla_put(skb, attrtype, sizeof(__le32), &value); + __le32 tmp = value; + + return nla_put(skb, attrtype, sizeof(__le32), &tmp); } /** @@ -874,7 +893,9 @@ static inline int nla_put_le32(struct sk_buff *skb, int attrtype, __le32 value) static inline int nla_put_u64_64bit(struct sk_buff *skb, int attrtype, u64 value, int padattr) { - return nla_put_64bit(skb, attrtype, sizeof(u64), &value, padattr); + u64 tmp = value; + + return nla_put_64bit(skb, attrtype, sizeof(u64), &tmp, padattr); } /** @@ -887,7 +908,9 @@ static inline int nla_put_u64_64bit(struct sk_buff *skb, int attrtype, static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value, int padattr) { - return nla_put_64bit(skb, attrtype, sizeof(__be64), &value, padattr); + __be64 tmp = value; + + return nla_put_64bit(skb, attrtype, sizeof(__be64), &tmp, padattr); } /** @@ -900,7 +923,9 @@ static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value, static inline int nla_put_net64(struct sk_buff *skb, int attrtype, __be64 value, int padattr) { - return nla_put_be64(skb, attrtype | NLA_F_NET_BYTEORDER, value, + __be64 tmp = value; + + return nla_put_be64(skb, attrtype | NLA_F_NET_BYTEORDER, tmp, padattr); } @@ -914,7 +939,9 @@ static inline int nla_put_net64(struct sk_buff *skb, int attrtype, __be64 value, static inline int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 value, int padattr) { - return nla_put_64bit(skb, attrtype, sizeof(__le64), &value, padattr); + __le64 tmp = value; + + return nla_put_64bit(skb, attrtype, sizeof(__le64), &tmp, padattr); } /** @@ -925,7 +952,9 @@ static inline int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 value, */ static inline int nla_put_s8(struct sk_buff *skb, int attrtype, s8 value) { - return nla_put(skb, attrtype, sizeof(s8), &value); + s8 tmp = value; + + return nla_put(skb, attrtype, sizeof(s8), &tmp); } /** @@ -936,7 +965,9 @@ static inline int nla_put_s8(struct sk_buff *skb, int attrtype, s8 value) */ static inline int nla_put_s16(struct sk_buff *skb, int attrtype, s16 value) { - return nla_put(skb, attrtype, sizeof(s16), &value); + s16 tmp = value; + + return nla_put(skb, attrtype, sizeof(s16), &tmp); } /** @@ -947,7 +978,9 @@ static inline int nla_put_s16(struct sk_buff *skb, int attrtype, s16 value) */ static inline int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value) { - return nla_put(skb, attrtype, sizeof(s32), &value); + s32 tmp = value; + + return nla_put(skb, attrtype, sizeof(s32), &tmp); } /** @@ -960,7 +993,9 @@ static inline int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value) static inline int nla_put_s64(struct sk_buff *skb, int attrtype, s64 value, int padattr) { - return nla_put_64bit(skb, attrtype, sizeof(s64), &value, padattr); + s64 tmp = value; + + return nla_put_64bit(skb, attrtype, sizeof(s64), &tmp, padattr); } /** @@ -1010,7 +1045,9 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype, static inline int nla_put_in_addr(struct sk_buff *skb, int attrtype, __be32 addr) { - return nla_put_be32(skb, attrtype, addr); + __be32 tmp = addr; + + return nla_put_be32(skb, attrtype, tmp); } /**