]> Git Repo - J-linux.git/commitdiff
net_sched: reject TCF_EM_SIMPLE case for complex ematch module
authorCong Wang <[email protected]>
Sat, 17 Dec 2022 22:17:07 +0000 (14:17 -0800)
committerDavid S. Miller <[email protected]>
Mon, 19 Dec 2022 09:43:18 +0000 (09:43 +0000)
When TCF_EM_SIMPLE was introduced, it is supposed to be convenient
for ematch implementation:

https://lore.kernel.org/all/20050105110048[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.

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]>
Acked-by: Paolo Abeni <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/sched/ematch.c

index 4ce68136185152f992ae9b34a098ef1d8ebeb1e6..5c1235e6076ae80fce8cf23c2ae6df0d42e4ec67 100644 (file)
@@ -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;
This page took 0.04856 seconds and 4 git commands to generate.