2021-04-19 01:03:47

by Valdis Klētnieks

[permalink] [raw]
Subject: drivers/net/ethernet/mediatek/mtk_ppe_offload.c - suspicious code?

While doing some code auditing for -Woverride_init, I spotted some questionable code

commit 502e84e2382d92654a2ecbc52cdbdb5a11cdcec7
Author: Felix Fietkau <[email protected]>
Date: Wed Mar 24 02:30:54 2021 +0100

net: ethernet: mtk_eth_soc: add flow offloading support

In drivers/net/ethernet/mediatek/mtk_ppe_offload.c:

+static const struct rhashtable_params mtk_flow_ht_params = {
+ .head_offset = offsetof(struct mtk_flow_entry, node),
+ .head_offset = offsetof(struct mtk_flow_entry, cookie),
+ .key_len = sizeof(unsigned long),
+ .automatic_shrinking = true,
+};

What's intended for head_offset here?

Christoph: This was the only actual questionable code caught by override-init
across allmodconfig builds of arm, arm64, and x86_64. The other 218 warnings
not already silenced by Makefile twiddling of CFLAGS are all legitimate. I
admit not being sure what that means for its use in W=1 builds in general.


Attachments:
(No filename) (849.00 B)

2021-04-19 09:18:42

by Pablo Neira Ayuso

[permalink] [raw]
Subject: Re: drivers/net/ethernet/mediatek/mtk_ppe_offload.c - suspicious code?

On Sun, Apr 18, 2021 at 09:02:12PM -0400, Valdis Klētnieks wrote:
> While doing some code auditing for -Woverride_init, I spotted some questionable code
>
> commit 502e84e2382d92654a2ecbc52cdbdb5a11cdcec7
> Author: Felix Fietkau <[email protected]>
> Date: Wed Mar 24 02:30:54 2021 +0100
>
> net: ethernet: mtk_eth_soc: add flow offloading support
>
> In drivers/net/ethernet/mediatek/mtk_ppe_offload.c:
>
> +static const struct rhashtable_params mtk_flow_ht_params = {
> + .head_offset = offsetof(struct mtk_flow_entry, node),
> + .head_offset = offsetof(struct mtk_flow_entry, cookie),
> + .key_len = sizeof(unsigned long),
> + .automatic_shrinking = true,
> +};
>
> What's intended for head_offset here?

It's a bug, there's a fix here:

https://www.spinics.net/lists/netdev/msg736368.html