Skip to content

Commit 9cd3fd2

Browse files
Cong Wangdavem330
authored andcommitted
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/[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: 1da177e ("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]>
1 parent 8952936 commit 9cd3fd2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/sched/ematch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ static int tcf_em_validate(struct tcf_proto *tp,
255255
* the value carried.
256256
*/
257257
if (em_hdr->flags & TCF_EM_SIMPLE) {
258+
if (em->ops->datalen > 0)
259+
goto errout;
258260
if (data_len < sizeof(u32))
259261
goto errout;
260262
em->data = *(u32 *) data;

0 commit comments

Comments
 (0)