From patchwork Tue Feb 20 11:54:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 128893 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4560849ljc; Tue, 20 Feb 2018 04:04:48 -0800 (PST) X-Google-Smtp-Source: AH8x225snj8Sv7gnpJttzvwIjbNoNDYMMr6vJ8ZFHbch6azOkvRAqad8Px5sB1mW/8fmOS5/2RpV X-Received: by 2002:a17:902:694c:: with SMTP id k12-v6mr11867427plt.133.1519128288459; Tue, 20 Feb 2018 04:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519128288; cv=none; d=google.com; s=arc-20160816; b=kT2PHspN6fGbYNEhJj7/PDDCBfcUvUbrbYcm36CUAWbEFE/crwWbXeSA05AXEMJsin FmmpgUeUi6lQFAIgK2Z3rmLmGiAqhNpKJaeYmu2lTuyfHdQEM5dOcC4rVK7qr/U55pr6 +yLL6/iQxBjwQ/HARZg4EEcBGmKnplXUmoolZdf7w4r0+4m0RU16KfFa/xj1uYsQaiaM QkZ4hhF3gUBbApiZfXJmxQoABECXGRgN6tVsbecRa/SAlgjVqp8b6ElOV+mIwBF2Y27D WmDaUdXX+2wsv/xRwR17rhWcL+RaedNowTy86AHcw9VbjyrCE5ir6XUJFgc+a0Cvsi78 riyQ== 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=xqqLNR0AgpK6YV06ynWMyNUCYsWVSwiyqjZKNq2We4s=; b=Otgau16EKd6Bm3H6EUr+pjiI9U+IRsjjBHAPK2VIqg2zF/qb4qUUNoGXg++RGD9zWR 0NSQFqkrCZomvdAN+Nhc9PP27msdwZLUaFFg6oy4WNC9goWx9z6iLveiXqtroDvutPQt s1ZOweNHOcvTdEKLtSuHJ56kN0G3G0lPOOMA6QLMA11MzBnlbeclv3hOII6Gk/LVyqNO SvnO9m8naI36F4F8abHhSQy/g2HdvOBfNkh9en0P5WV4IhAGVsUNJm5zQzyPgXR8xrlh keL97E4vtB/wTljmqmn55Buh1ujlm65bdOUTqfwsnyfFchquCmE8+wee1jDU26UZBdh5 85iQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 bb5-v6si597675plb.800.2018.02.20.04.04.48; Tue, 20 Feb 2018 04:04:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751661AbeBTMEr (ORCPT + 10 others); Tue, 20 Feb 2018 07:04:47 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:59449 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751672AbeBTL7Q (ORCPT ); Tue, 20 Feb 2018 06:59:16 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0M1XiL-1eUmGq1bwn-00tTjQ; Tue, 20 Feb 2018 12:59:09 +0100 From: Arnd Bergmann To: stable@vger.kernel.org Cc: Greg KH , linux-kernel@vger.kernel.org, Arnd Bergmann , "David S . Miller" , netdev@vger.kernel.org Subject: [4.4-stable 11/22] netlink: fix nla_put_{u8,u16,u32} for KASAN Date: Tue, 20 Feb 2018 12:54:58 +0100 Message-Id: <20180220115527.1806578-12-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180220115527.1806578-1-arnd@arndb.de> References: <20180220115527.1806578-1-arnd@arndb.de> X-Provags-ID: V03:K0:Xu89oNkFxYuzL4uV1TH0bm+rOk3zezfVpuqv4g4cMWWAarq64Mm GBIe5b+C314ZDF+TqPe/p0gJdoBkB8lG3KfXzBbxflLJ4aSEp0Un3F5Ryauplc77+h7h8ye 8scyqDKItXN9Q3vwwAqENimoYITroWG/zFmaVqjZSEzvJdiLqGf9L3UPpnTAvmkAh8jwo8S 4QsqXFkMrII+2Y95EllHg== X-UI-Out-Filterresults: notjunk:1; V01:K0:/89b7o/dO3E=:8zOLVFsgBm0bYiIKzqxTec tIv+StwB3Wb6bHUEMxMf74V0GtHk6cD/nWet8zRWjZihw0MPUih/yLTdFtBL+ioRTHKEndWEd OShcllop2MUkWLxCLrtQivXTgilGUoAKIlA0I4KTX9q1KxS3m04hluRFkRDeV0LFzlcgXGJUs qL03KyAmB9yhyo34VyBKDuufIqsKud80rl5YSOAZGDRTRUkFvkRalz33uwc5h8D/+uNE7zf2r sv9gAH0TMr0nuB1LypzYTruyOcaUzHi4IJ/ObwtuUdRIPdXcYZQy5tv5bQKNcxcJ6nh3cGFDn m+qvlQvNkbPC9Vqbdu6Gxf44b2ATwaL0eouucnfKEJByhqXCUmleVGwD+XD0RAgtYAefgdzEK e2At4GpdKIjlUdVjP/7ArzRqxei6b45wIoI89SBejiKBSVk/K08ebaCXMSTkTq5fvirLaa6+S lBFaKLOq6fKLbKgIagfll93K+QY7qnFGNkAL9QwIhJoWDtz4s050vw/0F3GuRY+QYOswx4dM4 cZeXEp/WvqtU/mWUki8unTbW4unaqmqkcxgXXuk63p+diO2NXqDtP5DXDQEkHJ/iIJg+kKpUn Nb7/2RPirbIVdARza4HT35AC7VtEBsCTc5e3Qexmjp/hxQR5LvE3ePqNYL2Oogh2ehbxUOTHR HidAQFKYo1aN3CK7fLDpc1GCMly4bWuSejvcATsw/cuvi2botV8vrqrdWixpgzibSzSULEvH3 TDHpxD3wg4Vcyr1zBRYlIRrE56m0mR2gDlcUog== Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org commit b4391db42308c9940944b5d7be5ca4b78fb88dd0 upstream. 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 Signed-off-by: David S. Miller [arnd: rebased to 4.4-stable] 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 0e3172751755..5ffaea4665f8 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -745,7 +745,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); } /** @@ -756,7 +759,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); } /** @@ -767,7 +772,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); } /** @@ -778,7 +785,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); } /** @@ -789,7 +798,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); } /** @@ -800,7 +811,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); } /** @@ -811,7 +824,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); } /** @@ -822,7 +837,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); } /** @@ -833,7 +850,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); } /** @@ -844,7 +863,9 @@ static inline int nla_put_le32(struct sk_buff *skb, int attrtype, __le32 value) */ static inline int nla_put_u64(struct sk_buff *skb, int attrtype, u64 value) { - return nla_put(skb, attrtype, sizeof(u64), &value); + u64 tmp = value; + + return nla_put(skb, attrtype, sizeof(u64), &tmp); } /** @@ -855,7 +876,9 @@ static inline int nla_put_u64(struct sk_buff *skb, int attrtype, u64 value) */ static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value) { - return nla_put(skb, attrtype, sizeof(__be64), &value); + __be64 tmp = value; + + return nla_put(skb, attrtype, sizeof(__be64), &tmp); } /** @@ -866,7 +889,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) { - 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); } /** @@ -877,7 +902,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) { - return nla_put(skb, attrtype, sizeof(__le64), &value); + __le64 tmp = value; + + return nla_put(skb, attrtype, sizeof(__le64), &tmp); } /** @@ -888,7 +915,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); } /** @@ -899,7 +928,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); } /** @@ -910,7 +941,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); } /** @@ -921,7 +954,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) { - return nla_put(skb, attrtype, sizeof(s64), &value); + s64 tmp = value; + + return nla_put(skb, attrtype, sizeof(s64), &tmp); } /** @@ -969,7 +1004,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); } /**