aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-14 12:24:04 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-14 18:38:36 -0400
commitf9e42b853523cda0732022c2e0473c183f7aec65 (patch)
tree2fafd6347ab04c066b51759d0e85cc53a7378d35 /net/sctp
parent09ce069dff607f86dcdeb541d20734a8f42478c5 (diff)
net: sctp: sideeffect: throw BUG if primary_path is NULL
This clearly states a BUG somewhere in the SCTP code as e.g. fixed once in f28156335 ("sctp: Use correct sideffect command in duplicate cookie handling"). If this ever happens, throw a trace in the sideeffect engine where assocs clearly must have a primary_path assigned. When in sctp_seq_dump_local_addrs() also throw a WARN and bail out since we do not need to panic for printing this one asterisk. Also, it will avoid the not so obvious case when primary != NULL test passes and at a later point in time triggering a NULL ptr dereference caused by primary. While at it, also fix up the white space. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Acked-by: Vlad Yasevich <vyasevich@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r--net/sctp/proc.c12
-rw-r--r--net/sctp/sm_sideeffect.c5
2 files changed, 13 insertions, 4 deletions
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index 4e45ee35d0db..0c83162a6bf8 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -134,9 +134,15 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo
134 struct sctp_af *af; 134 struct sctp_af *af;
135 135
136 if (epb->type == SCTP_EP_TYPE_ASSOCIATION) { 136 if (epb->type == SCTP_EP_TYPE_ASSOCIATION) {
137 asoc = sctp_assoc(epb); 137 asoc = sctp_assoc(epb);
138 peer = asoc->peer.primary_path; 138
139 primary = &peer->saddr; 139 peer = asoc->peer.primary_path;
140 if (unlikely(peer == NULL)) {
141 WARN(1, "Association %p with NULL primary path!", asoc);
142 return;
143 }
144
145 primary = &peer->saddr;
140 } 146 }
141 147
142 rcu_read_lock(); 148 rcu_read_lock();
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 8aab894aeabe..ff91f47b0239 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -864,6 +864,7 @@ static void sctp_cmd_delete_tcb(sctp_cmd_seq_t *cmds,
864 (!asoc->temp) && (sk->sk_shutdown != SHUTDOWN_MASK)) 864 (!asoc->temp) && (sk->sk_shutdown != SHUTDOWN_MASK))
865 return; 865 return;
866 866
867 BUG_ON(asoc->peer.primary_path == NULL);
867 sctp_unhash_established(asoc); 868 sctp_unhash_established(asoc);
868 sctp_association_free(asoc); 869 sctp_association_free(asoc);
869} 870}
@@ -1274,8 +1275,10 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1274 sctp_outq_uncork(&asoc->outqueue); 1275 sctp_outq_uncork(&asoc->outqueue);
1275 local_cork = 0; 1276 local_cork = 0;
1276 } 1277 }
1277 asoc = cmd->obj.asoc; 1278
1278 /* Register with the endpoint. */ 1279 /* Register with the endpoint. */
1280 asoc = cmd->obj.asoc;
1281 BUG_ON(asoc->peer.primary_path == NULL);
1279 sctp_endpoint_add_asoc(ep, asoc); 1282 sctp_endpoint_add_asoc(ep, asoc);
1280 sctp_hash_established(asoc); 1283 sctp_hash_established(asoc);
1281 break; 1284 break;