提交 9cd3fd20 编写于 作者: C Cong Wang 提交者: David S. Miller

net_sched: reject TCF_EM_SIMPLE case for complex ematch module

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: 1da177e4 ("Linux-2.6.12-rc2")
Reported-and-tested-by: syzbot+4caeae4c7103813598ae@syzkaller.appspotmail.com
Reported-by: NJun Nie <jun.nie@linaro.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: NCong Wang <cong.wang@bytedance.com>
Acked-by: NPaolo Abeni <pabeni@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 89529367
...@@ -255,6 +255,8 @@ static int tcf_em_validate(struct tcf_proto *tp, ...@@ -255,6 +255,8 @@ static int tcf_em_validate(struct tcf_proto *tp,
* the value carried. * the value carried.
*/ */
if (em_hdr->flags & TCF_EM_SIMPLE) { if (em_hdr->flags & TCF_EM_SIMPLE) {
if (em->ops->datalen > 0)
goto errout;
if (data_len < sizeof(u32)) if (data_len < sizeof(u32))
goto errout; goto errout;
em->data = *(u32 *) data; em->data = *(u32 *) data;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册