Skip to content

Commit

Permalink
kcm: fix a null pointer dereference in kcm_sendmsg()
Browse files Browse the repository at this point in the history
In commit 98e3862 ("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: 98e3862 ("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>
  • Loading branch information
WANG Cong authored and David S. Miller committed Feb 14, 2017
1 parent 01f8902 commit cd27b96
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/kcm/kcmsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,8 +1044,10 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
} 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);
Expand Down

0 comments on commit cd27b96

Please sign in to comment.