forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
-Wattribute-warningCONFIG_WERRORHas in an error with CONFIG_WERROR (all{mod,yes}config) (or emits a non-compiler warning)Has in an error with CONFIG_WERROR (all{mod,yes}config) (or emits a non-compiler warning)[BUG] linuxA bug that should be fixed in the mainline kernel.A bug that should be fixed in the mainline kernel.[FIXED][LINUX] 5.19This bug was fixed in Linux 5.19This bug was fixed in Linux 5.19[__bos] miscalculationThis bug was due to an undiagnosed problem with __builtin_object_sizeThis bug was due to an undiagnosed problem with __builtin_object_sizeloop unroller
Description
With both ARCH=arm64 allmodconfig
and ARCH=x86_64 allmodconfig
on linux-next, I see:
$ make -skj"$(nproc)" LLVM=1 mrproper allmodconfig drivers/net/ethernet/huawei/hinic/hinic_devlink.o
In file included from drivers/net/ethernet/huawei/hinic/hinic_devlink.c:15:
In file included from ./include/linux/netlink.h:7:
In file included from ./include/linux/skbuff.h:15:
In file included from ./include/linux/time.h:60:
In file included from ./include/linux/time32.h:13:
In file included from ./include/linux/timex.h:65:
In file included from ./arch/x86/include/asm/timex.h:5:
In file included from ./arch/x86/include/asm/processor.h:22:
In file included from ./arch/x86/include/asm/msr.h:11:
In file included from ./arch/x86/include/asm/cpumask.h:5:
In file included from ./include/linux/cpumask.h:12:
In file included from ./include/linux/bitmap.h:11:
In file included from ./include/linux/string.h:253:
./include/linux/fortify-string.h:328:4: error: call to __write_overflow_field declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
__write_overflow_field(p_size_field, size);
^
1 error generated.
This comes from the new fortify checks. Specifically, it appears to come from the memcpy()
in check_image_valid()
:
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
index 60ae8bfc5f69..11a52cc375a2 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
@@ -43,9 +43,11 @@ static bool check_image_valid(struct hinic_devlink_priv *priv, const u8 *buf,
for (i = 0; i < fw_image->fw_info.fw_section_cnt; i++) {
len += fw_image->fw_section_info[i].fw_section_len;
+ /*
memcpy(&host_image->image_section_info[i],
&fw_image->fw_section_info[i],
sizeof(struct fw_section_info_st));
+ */
}
if (len != fw_image->fw_len ||
static bool check_image_valid(struct hinic_devlink_priv *priv, const u8 *buf,
u32 image_size, struct host_image_st *host_image)
{
struct fw_image_st *fw_image = NULL;
u32 len = 0;
u32 i;
fw_image = (struct fw_image_st *)buf;
if (fw_image->fw_magic != HINIC_MAGIC_NUM) {
dev_err(&priv->hwdev->hwif->pdev->dev, "Wrong fw_magic read from file, fw_magic: 0x%x\n",
fw_image->fw_magic);
return false;
}
if (fw_image->fw_info.fw_section_cnt > MAX_FW_TYPE_NUM) {
dev_err(&priv->hwdev->hwif->pdev->dev, "Wrong fw_type_num read from file, fw_type_num: 0x%x\n",
fw_image->fw_info.fw_section_cnt);
return false;
}
for (i = 0; i < fw_image->fw_info.fw_section_cnt; i++) {
len += fw_image->fw_section_info[i].fw_section_len;
memcpy(&host_image->image_section_info[i],
&fw_image->fw_section_info[i],
sizeof(struct fw_section_info_st));
}
...
From drivers/net/ethernet/huawei/hinic/hinic_devlink.h
:
...
#define MAX_FW_TYPE_NUM 30
...
struct fw_section_info_st {
u32 fw_section_len;
u32 fw_section_offset;
u32 fw_section_version;
u32 fw_section_type;
u32 fw_section_crc;
};
struct fw_image_st {
u32 fw_version;
u32 fw_len;
u32 fw_magic;
struct {
u32 fw_section_cnt:16;
u32 resd:16;
} fw_info;
struct fw_section_info_st fw_section_info[MAX_FW_TYPE_NUM];
u32 device_id;
u32 res[101];
void *bin_data;
};
struct host_image_st {
struct fw_section_info_st image_section_info[MAX_FW_TYPE_NUM];
struct {
u32 up_total_len;
u32 fw_version;
} image_info;
u32 section_type_num;
u32 device_id;
};
I am struggling to see what clang
finds problematic here?
cc @kees
Metadata
Metadata
Assignees
Labels
-Wattribute-warningCONFIG_WERRORHas in an error with CONFIG_WERROR (all{mod,yes}config) (or emits a non-compiler warning)Has in an error with CONFIG_WERROR (all{mod,yes}config) (or emits a non-compiler warning)[BUG] linuxA bug that should be fixed in the mainline kernel.A bug that should be fixed in the mainline kernel.[FIXED][LINUX] 5.19This bug was fixed in Linux 5.19This bug was fixed in Linux 5.19[__bos] miscalculationThis bug was due to an undiagnosed problem with __builtin_object_sizeThis bug was due to an undiagnosed problem with __builtin_object_sizeloop unroller