提交 794eb6bf 编写于 作者: J Jesper Juhl 提交者: David S. Miller

[NETLABEL]: Fix NULL deref in netlbl_unlabel_staticlist_gen() if ifindex not found

dev_get_by_index() may return NULL if nothing is found. In 
net/netlabel/netlabel_unlabeled.c::netlbl_unlabel_staticlist_gen() the 
function is called, but the return value is never checked. If it returns 
NULL then we'll deref a NULL pointer on the very next line.
I checked the callers, and I don't think this can actually happen today, 
but code changes over time and in the future it might happen and it does 
no harm to be defensive and check for the failure, so that if/when it 
happens we'll fail gracefully instead of crashing.
Signed-off-by: NJesper Juhl <jesper.juhl@gmail.com>
Acked-by: NPaul Moore <paul.moore@hp.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 f5ba2d32
......@@ -1339,6 +1339,10 @@ static int netlbl_unlabel_staticlist_gen(u32 cmd,
if (iface->ifindex > 0) {
dev = dev_get_by_index(&init_net, iface->ifindex);
if (!dev) {
ret_val = -ENODEV;
goto list_cb_failure;
}
ret_val = nla_put_string(cb_arg->skb,
NLBL_UNLABEL_A_IFACE, dev->name);
dev_put(dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册