bpf: fix arraymap NULL deref and missing overflow and zero size checks
[deliverable/linux.git] / net / netlink / diag.c
index 7301850eb56fe32ad700d5d50daeab25f706284d..de8c74a3c0615ac98ee13ab403491afd8fcac3eb 100644 (file)
@@ -170,6 +170,7 @@ static int netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
 
        req = nlmsg_data(cb->nlh);
 
+       mutex_lock(&nl_sk_hash_lock);
        read_lock(&nl_table_lock);
 
        if (req->sdiag_protocol == NDIAG_PROTO_ALL) {
@@ -183,6 +184,7 @@ static int netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
        } else {
                if (req->sdiag_protocol >= MAX_LINKS) {
                        read_unlock(&nl_table_lock);
+                       mutex_unlock(&nl_sk_hash_lock);
                        return -ENOENT;
                }
 
@@ -190,6 +192,7 @@ static int netlink_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
        }
 
        read_unlock(&nl_table_lock);
+       mutex_unlock(&nl_sk_hash_lock);
 
        return skb->len;
 }
This page took 0.025152 seconds and 5 git commands to generate.