net_sched: reject TCF_EM_SIMPLE case for complex ematch module
Subsystems (3)
PATCH 1/1 net_sched: reject TCF_EM_SIMPLE case for complex ematch module
From: Cong Wang <[email protected]>
When TCF_EM_SIMPLE was introduced, it is supposed to be convenient for ematch implementation:
https://lore.kernel.org/all/[email protected]/
"You don't have to, providing a 32bit data chunk without TCF_EM_SIMPLE set will simply result in allocating & copy. It's an optimization, nothing more."
So if an ematch module provides ops->datalen that means it wants a complex data structure (saved in its em->data) instead of a simple u32 value. We should simply reject such a combination, otherwise this u32 could be misinterpreted as a pointer.
--- net/sched/ematch.c | 2 ++ 1 file changed, 2 insertions(+)
net/sched/ematch.c +2 -0
@@ -255,6 +255,8 @@ static int tcf_em_validate(struct tcf_proto *tp,* the value carried. */ if (em_hdr->flags &TCF_EM_SIMPLE ) { +if (em->ops->datalen >0 ) + goto errout;if (data_len <sizeof (u32)) goto errout; em->data = *(u32 *) data;
Signature · 1 line
2.34.1
Hello,
Quoted 31 lines · Cong Wang
From: Cong Wang <[email protected]>
When
TCF_EM_SIMPLEwas introduced, it is supposed to be convenient for ematch implementation:https://lore.kernel.org/all/[email protected]/
"You don't have to, providing a 32bit data chunk without
TCF_EM_SIMPLEset will simply result in allocating & copy. It's an optimization, nothing more."So if an ematch module provides
ops->datalenthat means it wants a complex data structure (saved in itsem->data) instead of a simple u32 value. We should simply reject such a combination, otherwise this u32 could be misinterpreted as a pointer.Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Reported-and-tested-by [email protected]Reported-by Jun Nie <[email protected]>Cc Jamal Hadi Salim <[email protected]>Cc Paolo Abeni <[email protected]>Signed-off-by Cong Wang <[email protected]>--- net/sched/ematch.c | 2 ++ 1 file changed, 2 insertions(+)net/sched/ematch.c +0
-0
net/sched/ematch.c static int tcf_em_validate(struct tcf_proto *tp, · line 262
Quoted 8 lines
net/sched/ematch.c +2
-0@@ -255,6 +255,8 @@ static int tcf_em_validate(struct tcf_proto *tp,* the value carried. */ if (em_hdr->flags &TCF_EM_SIMPLE ) { +if (em->ops->datalen >0 ) + goto errout;if (data_len <sizeof (u32)) goto errout; em->data = *(u32 *) data;
The patch LGTM, thanks!
If I read correctly, this effectively rejects any ematch with TCF_EM_SIMPLE set (all the existing tcf_ematch_ops structs have eiter .change or . datalen > 0).
It looks like EM_SIMPLE does not work as intended since a lot of time (possibly since its introduction !?!). Can we drop it completely?
Cheers,
Paolo
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 8 lines · On Sat, 17 Dec 2022 14:17:07 -0800 you wrote:
From: Cong Wang <[email protected]>
When
TCF_EM_SIMPLEwas introduced, it is supposed to be convenient for ematch implementation:https://lore.kernel.org/all/[email protected]/
[...]
Here is the summary with links:
- [net] net_sched: reject TCF_EM_SIMPLE case for complex ematch module
https://git.kernel.org/netdev/net/c/9cd3fd2054c3
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html