Commit de7b508f authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Juerg Haefliger

rocker: fix rocker_tlv_put_* functions for KASAN

BugLink: https://bugs.launchpad.net/bugs/1811080

commit 6098d7dd upstream.

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=81715Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 69f93bc6
...@@ -821,37 +821,49 @@ static int rocker_tlv_put(struct rocker_desc_info *desc_info, ...@@ -821,37 +821,49 @@ static int rocker_tlv_put(struct rocker_desc_info *desc_info,
static int rocker_tlv_put_u8(struct rocker_desc_info *desc_info, static int rocker_tlv_put_u8(struct rocker_desc_info *desc_info,
int attrtype, u8 value) 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 int rocker_tlv_put_u16(struct rocker_desc_info *desc_info, static int rocker_tlv_put_u16(struct rocker_desc_info *desc_info,
int attrtype, u16 value) 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 int rocker_tlv_put_be16(struct rocker_desc_info *desc_info, static int rocker_tlv_put_be16(struct rocker_desc_info *desc_info,
int attrtype, __be16 value) 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 int rocker_tlv_put_u32(struct rocker_desc_info *desc_info, static int rocker_tlv_put_u32(struct rocker_desc_info *desc_info,
int attrtype, u32 value) 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 int rocker_tlv_put_be32(struct rocker_desc_info *desc_info, static int rocker_tlv_put_be32(struct rocker_desc_info *desc_info,
int attrtype, __be32 value) 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 int rocker_tlv_put_u64(struct rocker_desc_info *desc_info, static int rocker_tlv_put_u64(struct rocker_desc_info *desc_info,
int attrtype, u64 value) 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 struct rocker_tlv * static struct rocker_tlv *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment