kcm: fix a null pointer dereference in kcm_sendmsg()
authorWANG Cong <xiyou.wangcong@gmail.com>
Mon, 13 Feb 2017 19:13:16 +0000 (11:13 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Feb 2017 18:06:37 +0000 (13:06 -0500)
In commit 98e3862ca2b1 ("kcm: fix 0-length case for kcm_sendmsg()")
I tried to avoid skb allocation for 0-length case, but missed
a check for NULL pointer in the non EOR case.

Fixes: 98e3862ca2b1 ("kcm: fix 0-length case for kcm_sendmsg()")
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Tom Herbert <tom@herbertland.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/kcm/kcmsock.c

index 64f0e8531af056b822409f234d8806f463c4d5e5..a646f348124095c1bdff2d14a77ea5c0ac892bc1 100644 (file)
@@ -1044,8 +1044,10 @@ wait_for_memory:
        } else {
                /* Message not complete, save state */
 partial_message:
-               kcm->seq_skb = head;
-               kcm_tx_msg(head)->last_skb = skb;
+               if (head) {
+                       kcm->seq_skb = head;
+                       kcm_tx_msg(head)->last_skb = skb;
+               }
        }
 
        KCM_STATS_ADD(kcm->stats.tx_bytes, copied);