提交 f8d54afc 编写于 作者: R Robert Shearman 提交者: David S. Miller

mpls: Properly validate RTA_VIA payload length

If the nla length is less than 2 then the nla data could be accessed
beyond the accessible bounds. So ensure that the nla is big enough to
at least read the via_family before doing so. Replace magic value of
2.

Fixes: 03c05665 ("mpls: Basic support for adding and removing routes")
Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: NRobert Shearman <rshearma@brocade.com>
Acked-by: N"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 5c4b934f
......@@ -586,8 +586,11 @@ static int rtm_to_route_config(struct sk_buff *skb, struct nlmsghdr *nlh,
case RTA_VIA:
{
struct rtvia *via = nla_data(nla);
if (nla_len(nla) < offsetof(struct rtvia, rtvia_addr))
goto errout;
cfg->rc_via_family = via->rtvia_family;
cfg->rc_via_alen = nla_len(nla) - 2;
cfg->rc_via_alen = nla_len(nla) -
offsetof(struct rtvia, rtvia_addr);
if (cfg->rc_via_alen > MAX_VIA_ALEN)
goto errout;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册