From: Yonglong Liu <liuyonglong@huawei.com>
In hclge_add_fd_entry(), if the flow type is FLOW_EXT, and the data of
m_ext is all zero, then some members of the local variable "info" are
not initialized.
Fixes: 67b0e1428e2f ("net: hns3: add support for user-def data of flow director")
Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 92f9b8ec76d9..f61355b03e14 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -6545,8 +6545,8 @@ static int hclge_add_fd_entry(struct hnae3_handle *handle,
struct ethtool_rxnfc *cmd)
{
struct hclge_vport *vport = hclge_get_vport(handle);
+ struct hclge_fd_user_def_info info = {0};
struct hclge_dev *hdev = vport->back;
- struct hclge_fd_user_def_info info;
u16 dst_vport_id = 0, q_index = 0;
struct ethtool_rx_flow_spec *fs;
struct hclge_fd_rule *rule;
--
2.33.0
On Wed, Apr 02, 2025 at 08:09:59PM +0800, Jijie Shao wrote:
> From: Yonglong Liu <liuyonglong@huawei.com>
>
> In hclge_add_fd_entry(), if the flow type is FLOW_EXT, and the data of
> m_ext is all zero, then some members of the local variable "info" are
> not initialized.
Hi,
I am assuming that this occurs when hclge_fd_check_spec() returns early
like this:
if (!(fs->flow_type & FLOW_EXT) || hclge_fd_is_user_def_all_masked(fs))
return 0;
But if so, should the description be "flow type is not FLOW_EXT, ..."
(note the "not")? Or perhaps more clearly refer to the FLOW_EXT bit
not being set?
Also, I think it would be worth mentioning hclge_fd_check_spec()
in the patch description, perhaps something like this.
In hclge_add_fd_entry(), if hclge_fd_check_spec() returns early
because the FLOW_EXT bit is not set in the flow type, and ...
Also, does this manifest in a user-visible problem? If so, I think
it would be good to describe it in the patch description.
If not, I think it would be good to mention how the problem was found.
E.g.: "flagged by static analysis" (and mention the tool if it is publicly
Available. Or, "found by inspection".
>
> Fixes: 67b0e1428e2f ("net: hns3: add support for user-def data of flow director")
> Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
...
on 2025/4/2 21:58, Simon Horman wrote:
> On Wed, Apr 02, 2025 at 08:09:59PM +0800, Jijie Shao wrote:
>> From: Yonglong Liu <liuyonglong@huawei.com>
>>
>> In hclge_add_fd_entry(), if the flow type is FLOW_EXT, and the data of
>> m_ext is all zero, then some members of the local variable "info" are
>> not initialized.
> Hi,
>
> I am assuming that this occurs when hclge_fd_check_spec() returns early
> like this:
>
> if (!(fs->flow_type & FLOW_EXT) || hclge_fd_is_user_def_all_masked(fs))
> return 0;
>
> But if so, should the description be "flow type is not FLOW_EXT, ..."
> (note the "not")? Or perhaps more clearly refer to the FLOW_EXT bit
> not being set?
>
> Also, I think it would be worth mentioning hclge_fd_check_spec()
> in the patch description, perhaps something like this.
>
> In hclge_add_fd_entry(), if hclge_fd_check_spec() returns early
> because the FLOW_EXT bit is not set in the flow type, and ...
>
> Also, does this manifest in a user-visible problem? If so, I think
> it would be good to describe it in the patch description.
>
> If not, I think it would be good to mention how the problem was found.
> E.g.: "flagged by static analysis" (and mention the tool if it is publicly
> Available. Or, "found by inspection".
Yes, your comments are reasonable.
I will add the description in v2
Thanks,
Jijie Shao
>
>> Fixes: 67b0e1428e2f ("net: hns3: add support for user-def data of flow director")
>> Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
>> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> ...
© 2016 - 2026 Red Hat, Inc.