Skip to contentSkip to conversation

sctp: jsctp_sf_eat_sack: fix kernel NULL ptr dereference

PATCH In review Daniel Borkmann 3 participants 5 messages Dec 14, 2012 – Dec 15, 2012 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH 1/1 sctp: jsctp_sf_eat_sack: fix kernel NULL ptr dereference

In reply to a message not in the archive

During debugging a sctp problem, I hit a kernel NULL pointer dereference in the jprobes callback jsctp_sf_eat_sack(). This small patch fixes the panic.

---
 net/sctp/probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/probe.c +1 -1
index bc6cd75..0a4e9d6 100644
@@ -134,7 +134,7 @@ sctp_disposition_t jsctp_sf_eat_sack(const struct sctp_endpoint *ep,
 
 	sp = asoc->peer.primary_path;
 
-	if ((full || sp->cwnd != lcwnd) &&
+	if (sp && (full || sp->cwnd != lcwnd) &&
 	    (!port || asoc->peer.port == port ||
 	     ep->base.bind_addr.port == port)) {
 		lcwnd = sp->cwnd;
Signature · 1 line
1.7.11.7
#2 lore raw
Quoted 16 lines · Daniel Borkmann

During debugging a sctp problem, I hit a kernel NULL pointer dereference in the jprobes callback jsctp_sf_eat_sack(). This small patch fixes the panic.

---
  net/sctp/probe.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/probe.c +0 -0
index bc6cd75..0a4e9d6 100644

net/sctp/probe.c sctp_disposition_t jsctp_sf_eat_sack(const struct sctp_endpoint *ep, · line 140

Quoted 8 lines
net/sctp/probe.c +1 -1
@@ -134,7 +134,7 @@ sctp_disposition_t jsctp_sf_eat_sack(const struct sctp_endpoint *ep,
 
  	sp = asoc->peer.primary_path;
 
-	if ((full || sp->cwnd != lcwnd) &&
+	if (sp && (full || sp->cwnd != lcwnd) &&
  	    (!port || asoc->peer.port == port ||
  	     ep->base.bind_addr.port == port)) {
  		lcwnd = sp->cwnd;

Sorry, but this patch isn't making much sense. @sp points to the primary path of the association and that can not be null if we receiving SACKs on this association.

sctp_sf_eat_sack_6_2(), which we are probing, is only called while the association is valid and all the transports still exist. It is also called under lock, so the transports can not go away while processing of the SACK. So unless there is some kind of jprobe issue, the pointer you are looking at should always be valid.

-vlad

#3 lore raw
Quoted 28 lines · Vlad Yasevich
Quoted 15 lines · Daniel Borkmann

During debugging a sctp problem, I hit a kernel NULL pointer dereference in the jprobes callback jsctp_sf_eat_sack(). This small patch fixes the panic.

---
  net/sctp/probe.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/probe.c +0 -0
index bc6cd75..0a4e9d6 100644

net/sctp/probe.c sctp_disposition_t jsctp_sf_eat_sack(const struct sctp_endpoint *ep, · line 140

Quoted 8 lines
net/sctp/probe.c +1 -1
@@ -134,7 +134,7 @@ sctp_disposition_t jsctp_sf_eat_sack(const struct sctp_endpoint *ep,
 
      sp = asoc->peer.primary_path;
 
-    if ((full || sp->cwnd != lcwnd) &&
+    if (sp && (full || sp->cwnd != lcwnd) &&
          (!port || asoc->peer.port == port ||
           ep->base.bind_addr.port == port)) {
          lcwnd = sp->cwnd;

Sorry, but this patch isn't making much sense. @sp points to the primary path of the association and that can not be null if we receiving SACKs on this association.

Quoted 2 lines

sctp_sf_eat_sack_6_2(), which we are probing, is only called while the association is valid and all the transports still exist. It is also called under lock, so the transports can not go away while processing of the SACK. So unless there is some kind of jprobe issue, the pointer you are looking at should always be valid.

Okay, I'll dig a bit deeper into that over the weekend.

#4 lore raw
Quoted 32 lines · Daniel Borkmann
Quoted 31 lines · Vlad Yasevich
Quoted 24 lines · Daniel Borkmann

During debugging a sctp problem, I hit a kernel NULL pointer dereference in the jprobes callback jsctp_sf_eat_sack(). This small patch fixes the panic.

---
  net/sctp/probe.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/probe.c +1 -1
index bc6cd75..0a4e9d6 100644
@@ -134,7 +134,7 @@ sctp_disposition_t jsctp_sf_eat_sack(const struct
 sctp_endpoint *ep,
 
      sp = asoc->peer.primary_path;
 
-    if ((full || sp->cwnd != lcwnd) &&
+    if (sp && (full || sp->cwnd != lcwnd) &&
          (!port || asoc->peer.port == port ||
           ep->base.bind_addr.port == port)) {
Quoted 1 line
          lcwnd = sp->cwnd;

Sorry, but this patch isn't making much sense. @sp points to the primary path of the association and that can not be null if we receiving SACKs on this association.

Quoted 7 lines
Quoted 5 lines

sctp_sf_eat_sack_6_2(), which we are probing, is only called while the association is valid and all the transports still exist. It is also called under lock, so the transports can not go away while processing of the SACK. So unless there is some kind of jprobe issue, the pointer
you are looking at should always be valid.

Okay, I'll dig a bit deeper into that over the weekend.

That's just for the record, I'll do further tests / debugging tomorrow ...

I compiled the net kernel with kprobes selftest / sanity test (kernel/test_kprobes.c) and it passed:

[    2.978082] Kprobe smoke test started
[    3.034014] Kprobe smoke test passed successfully

There, also jprobes are tested.

#5 lore raw
Quoted 43 lines · Daniel Borkmann
Quoted 32 lines · Daniel Borkmann
Quoted 31 lines · Vlad Yasevich
Quoted 24 lines · Daniel Borkmann

During debugging a sctp problem, I hit a kernel NULL pointer dereference in the jprobes callback jsctp_sf_eat_sack(). This small patch fixes the panic.

---
  net/sctp/probe.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/probe.c +1 -1
index bc6cd75..0a4e9d6 100644
@@ -134,7 +134,7 @@ sctp_disposition_t jsctp_sf_eat_sack(const struct
 sctp_endpoint *ep,
 
      sp = asoc->peer.primary_path;
 
-    if ((full || sp->cwnd != lcwnd) &&
+    if (sp && (full || sp->cwnd != lcwnd) &&
          (!port || asoc->peer.port == port ||
           ep->base.bind_addr.port == port)) {
Quoted 1 line
          lcwnd = sp->cwnd;

Sorry, but this patch isn't making much sense. @sp points to the primary path of the association and that can not be null if we receiving SACKs on this association.

Quoted 7 lines
Quoted 5 lines

sctp_sf_eat_sack_6_2(), which we are probing, is only called while the association is valid and all the transports still exist. It is also called under lock, so the transports can not go away while processing of the SACK. So unless there is some kind of jprobe issue, the pointer
you are looking at should always be valid.

Okay, I'll dig a bit deeper into that over the weekend.

That's just for the record, I'll do further tests / debugging tomorrow ...

Quoted 7 lines

I compiled the net kernel with kprobes selftest / sanity test (kernel/test_kprobes.c) and it passed:

[    2.978082] Kprobe smoke test started
[    3.034014] Kprobe smoke test passed successfully

There, also jprobes are tested.

Found the problem, will send a new patch for the net tree in a couple of minutes.