]> git.baikalelectronics.ru Git - kernel.git/commit
net_sched: reject TCF_EM_SIMPLE case for complex ematch module
authorCong Wang <cong.wang@bytedance.com>
Sat, 17 Dec 2022 22:17:07 +0000 (14:17 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:33 +0000 (11:41 +0100)
commit875b0804e98036a936880325a3830da5212856a0
treeb10a5e809e7cbbb1db409f99ccd8bf23b54a459c
parent5e260db58e017ba31dc2ed97a5bfc3af4c1019f4
net_sched: reject TCF_EM_SIMPLE case for complex ematch module

[ Upstream commit 590216a95a339d74bc4762e6a9cb393909d7ce56 ]

When TCF_EM_SIMPLE was introduced, it is supposed to be convenient
for ematch implementation:

https://lore.kernel.org/all/20050105110048.GO26856@postel.suug.ch/

"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.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-and-tested-by: syzbot+4caeae4c7103813598ae@syzkaller.appspotmail.com
Reported-by: Jun Nie <jun.nie@linaro.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sched/ematch.c