提交 680825e1 编写于 作者: C Cong Wang 提交者: Yang Yingliang

net_sched: fix datalen for ematch

stable inclusion
from linux-4.19.100
commit 66ac8ee96faa582a252ae19510f35529c9143670

--------------------------------

[ Upstream commit 61678d28 ]

syzbot reported an out-of-bound access in em_nbyte. As initially
analyzed by Eric, this is because em_nbyte sets its own em->datalen
in em_nbyte_change() other than the one specified by user, but this
value gets overwritten later by its caller tcf_em_validate().
We should leave em->datalen untouched to respect their choices.

I audit all the in-tree ematch users, all of those implement
->change() set em->datalen, so we can just avoid setting it twice
in this case.

Reported-and-tested-by: syzbot+5af9a90dad568aa9f611@syzkaller.appspotmail.com
Reported-by: syzbot+2f07903a5b05e7f36410@syzkaller.appspotmail.com
Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: NCong Wang <xiyou.wangcong@gmail.com>
Reviewed-by: NEric Dumazet <edumazet@google.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NLi Aichun <liaichun@huawei.com>
Reviewed-by: Nguodeqing <geffrey.guo@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 47039ada
...@@ -267,12 +267,12 @@ static int tcf_em_validate(struct tcf_proto *tp, ...@@ -267,12 +267,12 @@ static int tcf_em_validate(struct tcf_proto *tp,
} }
em->data = (unsigned long) v; em->data = (unsigned long) v;
} }
em->datalen = data_len;
} }
} }
em->matchid = em_hdr->matchid; em->matchid = em_hdr->matchid;
em->flags = em_hdr->flags; em->flags = em_hdr->flags;
em->datalen = data_len;
em->net = net; em->net = net;
err = 0; err = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册