summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCong Wang <cong.wang@bytedance.com>2022-12-17 14:17:07 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-01-18 11:30:32 +0100
commit134b529db48a70ab479f6902cd72b484ff39d30f (patch)
treef0ac4f107013a9285f354ea34ce51cd5be95475c
parent2d59f0ca153e9573ec4f140988c0ccca0eb4181b (diff)
downloadlinux-stable-134b529db48a70ab479f6902cd72b484ff39d30f.tar.gz
linux-stable-134b529db48a70ab479f6902cd72b484ff39d30f.tar.bz2
linux-stable-134b529db48a70ab479f6902cd72b484ff39d30f.zip
net_sched: reject TCF_EM_SIMPLE case for complex ematch module
[ Upstream commit 9cd3fd2054c3b3055163accbf2f31a4426f10317 ] 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>
-rw-r--r--net/sched/ematch.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/sched/ematch.c b/net/sched/ematch.c
index 113a133ee544..5ba3548d2eb7 100644
--- a/net/sched/ematch.c
+++ b/net/sched/ematch.c
@@ -259,6 +259,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;