Skip to content

Commit 6098d7d

Browse files
arndbdavem330
authored andcommitted
rocker: fix rocker_tlv_put_* functions for KASAN
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 <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a93ad94 commit 6098d7d

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

drivers/net/ethernet/rocker/rocker_tlv.h

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,40 +139,52 @@ rocker_tlv_start(struct rocker_desc_info *desc_info)
139139
int rocker_tlv_put(struct rocker_desc_info *desc_info,
140140
int attrtype, int attrlen, const void *data);
141141

142-
static inline int rocker_tlv_put_u8(struct rocker_desc_info *desc_info,
143-
int attrtype, u8 value)
142+
static inline int
143+
rocker_tlv_put_u8(struct rocker_desc_info *desc_info, int attrtype, u8 value)
144144
{
145-
return rocker_tlv_put(desc_info, attrtype, sizeof(u8), &value);
145+
u8 tmp = value; /* work around GCC PR81715 */
146+
147+
return rocker_tlv_put(desc_info, attrtype, sizeof(u8), &tmp);
146148
}
147149

148-
static inline int rocker_tlv_put_u16(struct rocker_desc_info *desc_info,
149-
int attrtype, u16 value)
150+
static inline int
151+
rocker_tlv_put_u16(struct rocker_desc_info *desc_info, int attrtype, u16 value)
150152
{
151-
return rocker_tlv_put(desc_info, attrtype, sizeof(u16), &value);
153+
u16 tmp = value;
154+
155+
return rocker_tlv_put(desc_info, attrtype, sizeof(u16), &tmp);
152156
}
153157

154-
static inline int rocker_tlv_put_be16(struct rocker_desc_info *desc_info,
155-
int attrtype, __be16 value)
158+
static inline int
159+
rocker_tlv_put_be16(struct rocker_desc_info *desc_info, int attrtype, __be16 value)
156160
{
157-
return rocker_tlv_put(desc_info, attrtype, sizeof(__be16), &value);
161+
__be16 tmp = value;
162+
163+
return rocker_tlv_put(desc_info, attrtype, sizeof(__be16), &tmp);
158164
}
159165

160-
static inline int rocker_tlv_put_u32(struct rocker_desc_info *desc_info,
161-
int attrtype, u32 value)
166+
static inline int
167+
rocker_tlv_put_u32(struct rocker_desc_info *desc_info, int attrtype, u32 value)
162168
{
163-
return rocker_tlv_put(desc_info, attrtype, sizeof(u32), &value);
169+
u32 tmp = value;
170+
171+
return rocker_tlv_put(desc_info, attrtype, sizeof(u32), &tmp);
164172
}
165173

166-
static inline int rocker_tlv_put_be32(struct rocker_desc_info *desc_info,
167-
int attrtype, __be32 value)
174+
static inline int
175+
rocker_tlv_put_be32(struct rocker_desc_info *desc_info, int attrtype, __be32 value)
168176
{
169-
return rocker_tlv_put(desc_info, attrtype, sizeof(__be32), &value);
177+
__be32 tmp = value;
178+
179+
return rocker_tlv_put(desc_info, attrtype, sizeof(__be32), &tmp);
170180
}
171181

172-
static inline int rocker_tlv_put_u64(struct rocker_desc_info *desc_info,
173-
int attrtype, u64 value)
182+
static inline int
183+
rocker_tlv_put_u64(struct rocker_desc_info *desc_info, int attrtype, u64 value)
174184
{
175-
return rocker_tlv_put(desc_info, attrtype, sizeof(u64), &value);
185+
u64 tmp = value;
186+
187+
return rocker_tlv_put(desc_info, attrtype, sizeof(u64), &tmp);
176188
}
177189

178190
static inline struct rocker_tlv *

0 commit comments

Comments
 (0)