Skip to contentSkip to conversation

kcm: fix a null pointer dereference in kcm_sendmsg()

PATCH Applied Cong Wang 3 participants 3 messages Feb 13, 2017 – Feb 14, 2017

Subsystems (2)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 kcm: fix a null pointer dereference in kcm_sendmsg()

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()")
Cc Tom Herbert <[email protected]>
---
 net/kcm/kcmsock.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/kcm/kcmsock.c +4 -2
index 64f0e85..a646f34 100644
@@ -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);
Signature · 1 line
2.5.5
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Cong Wang

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()")
Cc Tom Herbert <[email protected]>
Quoted 24 lines
---
 net/kcm/kcmsock.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/kcm/kcmsock.c +4 -3
index 64f0e85..a646f34 100644
@@ -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);
--

2.5.5

maintainer Applied
#2 lore raw
In reply to Cong Wang

From: Cong Wang <[email protected]>
Date: Mon, 13 Feb 2017 11:13:16 -0800

Quoted 8 lines

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()")
Cc Tom Herbert <[email protected]>

Applied, thanks.