From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-cys01nam02on0137.outbound.protection.outlook.com ([104.47.37.137]:54886 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032394AbeCAPjR (ORCPT ); Thu, 1 Mar 2018 10:39:17 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Arnd Bergmann , "David S . Miller" , Sasha Levin Subject: [added to the 4.1 stable tree] netlink: fix nla_put_{u8,u16,u32} for KASAN Date: Thu, 1 Mar 2018 15:27:41 +0000 Message-ID: <20180301152116.1486-488-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Arnd Bergmann This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit b4391db42308c9940944b5d7be5ca4b78fb88dd0 ] When CONFIG_KASAN is enabled, the "--param asan-stack=3D1" causes rather la= rge 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=3Dy"). 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 warnin= gs: net/wireless/nl80211.c:4389:1: warning: the frame size of 2240 bytes is lar= ger than 2048 bytes [-Wframe-larger-than=3D] net/wireless/nl80211.c:1895:1: warning: the frame size of 3776 bytes is lar= ger than 2048 bytes [-Wframe-larger-than=3D] net/wireless/nl80211.c:1410:1: warning: the frame size of 2208 bytes is lar= ger than 2048 bytes [-Wframe-larger-than=3D] net/bridge/br_netlink.c:1282:1: warning: the frame size of 2544 bytes is la= rger than 2048 bytes [-Wframe-larger-than=3D] 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=3D81715 Signed-off-by: Arnd Bergmann Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- include/net/netlink.h | 73 ++++++++++++++++++++++++++++++++++++++---------= ---- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/include/net/netlink.h b/include/net/netlink.h index 2a5dbcc90d1c..9bb53469b704 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=3D1 */ + u8 tmp =3D value; + + return nla_put(skb, attrtype, sizeof(u8), &tmp); } =20 /** @@ -756,7 +759,9 @@ static inline int nla_put_u8(struct sk_buff *skb, int a= ttrtype, 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 =3D value; + + return nla_put(skb, attrtype, sizeof(u16), &tmp); } =20 /** @@ -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 v= alue) { - return nla_put(skb, attrtype, sizeof(__be16), &value); + __be16 tmp =3D value; + + return nla_put(skb, attrtype, sizeof(__be16), &tmp); } =20 /** @@ -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 =3D value; + + return nla_put_be16(skb, attrtype | NLA_F_NET_BYTEORDER, tmp); } =20 /** @@ -789,7 +798,9 @@ static inline int nla_put_net16(struct sk_buff *skb, in= t attrtype, __be16 value) */ static inline int nla_put_le16(struct sk_buff *skb, int attrtype, __le16 v= alue) { - return nla_put(skb, attrtype, sizeof(__le16), &value); + __le16 tmp =3D value; + + return nla_put(skb, attrtype, sizeof(__le16), &tmp); } =20 /** @@ -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 =3D value; + + return nla_put(skb, attrtype, sizeof(u32), &tmp); } =20 /** @@ -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 v= alue) { - return nla_put(skb, attrtype, sizeof(__be32), &value); + __be32 tmp =3D value; + + return nla_put(skb, attrtype, sizeof(__be32), &tmp); } =20 /** @@ -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 =3D value; + + return nla_put_be32(skb, attrtype | NLA_F_NET_BYTEORDER, tmp); } =20 /** @@ -833,7 +850,9 @@ static inline int nla_put_net32(struct sk_buff *skb, in= t attrtype, __be32 value) */ static inline int nla_put_le32(struct sk_buff *skb, int attrtype, __le32 v= alue) { - return nla_put(skb, attrtype, sizeof(__le32), &value); + __le32 tmp =3D value; + + return nla_put(skb, attrtype, sizeof(__le32), &tmp); } =20 /** @@ -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 =3D value; + + return nla_put(skb, attrtype, sizeof(u64), &tmp); } =20 /** @@ -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 v= alue) { - return nla_put(skb, attrtype, sizeof(__be64), &value); + __be64 tmp =3D value; + + return nla_put(skb, attrtype, sizeof(__be64), &tmp); } =20 /** @@ -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 =3D value; + + return nla_put_be64(skb, attrtype | NLA_F_NET_BYTEORDER, tmp); } =20 /** @@ -877,7 +902,9 @@ static inline int nla_put_net64(struct sk_buff *skb, in= t attrtype, __be64 value) */ static inline int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 v= alue) { - return nla_put(skb, attrtype, sizeof(__le64), &value); + __le64 tmp =3D value; + + return nla_put(skb, attrtype, sizeof(__le64), &tmp); } =20 /** @@ -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 =3D value; + + return nla_put(skb, attrtype, sizeof(s8), &tmp); } =20 /** @@ -899,7 +928,9 @@ static inline int nla_put_s8(struct sk_buff *skb, int a= ttrtype, 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 =3D value; + + return nla_put(skb, attrtype, sizeof(s16), &tmp); } =20 /** @@ -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 =3D value; + + return nla_put(skb, attrtype, sizeof(s32), &tmp); } =20 /** @@ -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 =3D value; + + return nla_put(skb, attrtype, sizeof(s64), &tmp); } =20 /** @@ -969,7 +1004,9 @@ static inline int nla_put_msecs(struct sk_buff *skb, i= nt 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 =3D addr; + + return nla_put_be32(skb, attrtype, tmp); } =20 /** --=20 2.14.1