diff options
author | Neil Horman <nhorman@tuxdriver.com> | 2012-10-29 04:32:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-03 14:54:55 -0400 |
commit | b26ddd813031666293c95e84c997eb8b1f97bd38 (patch) | |
tree | 598f6fb4ac28998d9ac1101d297558199fb6e980 /net/sctp | |
parent | 1a9408355e91c21eaf4626386d65988a0ad7dc21 (diff) |
sctp: Clean up type-punning in sctp_cmd_t union
Lots of points in the sctp_cmd_interpreter function treat the sctp_cmd_t arg as
a void pointer, even though they are written as various other types. Theres no
need for this as doing so just leads to possible type-punning issues that could
cause crashes, and if we remain type-consistent we can actually just remove the
void * member of the union entirely.
Change Notes:
v2)
* Dropped chunk that modified SCTP_NULL to create a marker pattern
should anyone try to use a SCTP_NULL() assigned sctp_arg_t, Assigning
to .zero provides the same effect and should be faster, per Vlad Y.
v3)
* Reverted part of V2, opting to use memset instead of .zero, so that
the entire union is initalized thus avoiding the i164 speculative load
problems previously encountered, per Dave M.. Also rewrote
SCTP_[NO]FORCE so as to use common infrastructure a little more
Signed-off-by: Neil Horman <nhorman@tuxdriver.com
CC: Vlad Yasevich <vyasevich@gmail.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: linux-sctp@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r-- | net/sctp/sm_sideeffect.c | 45 | ||||
-rw-r--r-- | net/sctp/ulpqueue.c | 3 |
2 files changed, 23 insertions, 25 deletions
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index 6773d7803627..6eecf7e6338d 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c | |||
@@ -1268,14 +1268,14 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
1268 | sctp_outq_uncork(&asoc->outqueue); | 1268 | sctp_outq_uncork(&asoc->outqueue); |
1269 | local_cork = 0; | 1269 | local_cork = 0; |
1270 | } | 1270 | } |
1271 | asoc = cmd->obj.ptr; | 1271 | asoc = cmd->obj.asoc; |
1272 | /* Register with the endpoint. */ | 1272 | /* Register with the endpoint. */ |
1273 | sctp_endpoint_add_asoc(ep, asoc); | 1273 | sctp_endpoint_add_asoc(ep, asoc); |
1274 | sctp_hash_established(asoc); | 1274 | sctp_hash_established(asoc); |
1275 | break; | 1275 | break; |
1276 | 1276 | ||
1277 | case SCTP_CMD_UPDATE_ASSOC: | 1277 | case SCTP_CMD_UPDATE_ASSOC: |
1278 | sctp_assoc_update(asoc, cmd->obj.ptr); | 1278 | sctp_assoc_update(asoc, cmd->obj.asoc); |
1279 | break; | 1279 | break; |
1280 | 1280 | ||
1281 | case SCTP_CMD_PURGE_OUTQUEUE: | 1281 | case SCTP_CMD_PURGE_OUTQUEUE: |
@@ -1315,7 +1315,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
1315 | break; | 1315 | break; |
1316 | 1316 | ||
1317 | case SCTP_CMD_PROCESS_FWDTSN: | 1317 | case SCTP_CMD_PROCESS_FWDTSN: |
1318 | sctp_cmd_process_fwdtsn(&asoc->ulpq, cmd->obj.ptr); | 1318 | sctp_cmd_process_fwdtsn(&asoc->ulpq, cmd->obj.chunk); |
1319 | break; | 1319 | break; |
1320 | 1320 | ||
1321 | case SCTP_CMD_GEN_SACK: | 1321 | case SCTP_CMD_GEN_SACK: |
@@ -1331,7 +1331,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
1331 | case SCTP_CMD_PROCESS_SACK: | 1331 | case SCTP_CMD_PROCESS_SACK: |
1332 | /* Process an inbound SACK. */ | 1332 | /* Process an inbound SACK. */ |
1333 | error = sctp_cmd_process_sack(commands, asoc, | 1333 | error = sctp_cmd_process_sack(commands, asoc, |
1334 | cmd->obj.ptr); | 1334 | cmd->obj.chunk); |
1335 | break; | 1335 | break; |
1336 | 1336 | ||
1337 | case SCTP_CMD_GEN_INIT_ACK: | 1337 | case SCTP_CMD_GEN_INIT_ACK: |
@@ -1352,15 +1352,15 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
1352 | * layer which will bail. | 1352 | * layer which will bail. |
1353 | */ | 1353 | */ |
1354 | error = sctp_cmd_process_init(commands, asoc, chunk, | 1354 | error = sctp_cmd_process_init(commands, asoc, chunk, |
1355 | cmd->obj.ptr, gfp); | 1355 | cmd->obj.init, gfp); |
1356 | break; | 1356 | break; |
1357 | 1357 | ||
1358 | case SCTP_CMD_GEN_COOKIE_ECHO: | 1358 | case SCTP_CMD_GEN_COOKIE_ECHO: |
1359 | /* Generate a COOKIE ECHO chunk. */ | 1359 | /* Generate a COOKIE ECHO chunk. */ |
1360 | new_obj = sctp_make_cookie_echo(asoc, chunk); | 1360 | new_obj = sctp_make_cookie_echo(asoc, chunk); |
1361 | if (!new_obj) { | 1361 | if (!new_obj) { |
1362 | if (cmd->obj.ptr) | 1362 | if (cmd->obj.chunk) |
1363 | sctp_chunk_free(cmd->obj.ptr); | 1363 | sctp_chunk_free(cmd->obj.chunk); |
1364 | goto nomem; | 1364 | goto nomem; |
1365 | } | 1365 | } |
1366 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, | 1366 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, |
@@ -1369,9 +1369,9 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
1369 | /* If there is an ERROR chunk to be sent along with | 1369 | /* If there is an ERROR chunk to be sent along with |
1370 | * the COOKIE_ECHO, send it, too. | 1370 | * the COOKIE_ECHO, send it, too. |
1371 | */ | 1371 | */ |
1372 | if (cmd->obj.ptr) | 1372 | if (cmd->obj.chunk) |
1373 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, | 1373 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, |
1374 | SCTP_CHUNK(cmd->obj.ptr)); | 1374 | SCTP_CHUNK(cmd->obj.chunk)); |
1375 | 1375 | ||
1376 | if (new_obj->transport) { | 1376 | if (new_obj->transport) { |
1377 | new_obj->transport->init_sent_count++; | 1377 | new_obj->transport->init_sent_count++; |
@@ -1417,18 +1417,18 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
1417 | case SCTP_CMD_CHUNK_ULP: | 1417 | case SCTP_CMD_CHUNK_ULP: |
1418 | /* Send a chunk to the sockets layer. */ | 1418 | /* Send a chunk to the sockets layer. */ |
1419 | SCTP_DEBUG_PRINTK("sm_sideff: %s %p, %s %p.\n", | 1419 | SCTP_DEBUG_PRINTK("sm_sideff: %s %p, %s %p.\n", |
1420 | "chunk_up:", cmd->obj.ptr, | 1420 | "chunk_up:", cmd->obj.chunk, |
1421 | "ulpq:", &asoc->ulpq); | 1421 | "ulpq:", &asoc->ulpq); |
1422 | sctp_ulpq_tail_data(&asoc->ulpq, cmd->obj.ptr, | 1422 | sctp_ulpq_tail_data(&asoc->ulpq, cmd->obj.chunk, |
1423 | GFP_ATOMIC); | 1423 | GFP_ATOMIC); |
1424 | break; | 1424 | break; |
1425 | 1425 | ||
1426 | case SCTP_CMD_EVENT_ULP: | 1426 | case SCTP_CMD_EVENT_ULP: |
1427 | /* Send a notification to the sockets layer. */ | 1427 | /* Send a notification to the sockets layer. */ |
1428 | SCTP_DEBUG_PRINTK("sm_sideff: %s %p, %s %p.\n", | 1428 | SCTP_DEBUG_PRINTK("sm_sideff: %s %p, %s %p.\n", |
1429 | "event_up:",cmd->obj.ptr, | 1429 | "event_up:",cmd->obj.ulpevent, |
1430 | "ulpq:",&asoc->ulpq); | 1430 | "ulpq:",&asoc->ulpq); |
1431 | sctp_ulpq_tail_event(&asoc->ulpq, cmd->obj.ptr); | 1431 | sctp_ulpq_tail_event(&asoc->ulpq, cmd->obj.ulpevent); |
1432 | break; | 1432 | break; |
1433 | 1433 | ||
1434 | case SCTP_CMD_REPLY: | 1434 | case SCTP_CMD_REPLY: |
@@ -1438,12 +1438,12 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
1438 | local_cork = 1; | 1438 | local_cork = 1; |
1439 | } | 1439 | } |
1440 | /* Send a chunk to our peer. */ | 1440 | /* Send a chunk to our peer. */ |
1441 | error = sctp_outq_tail(&asoc->outqueue, cmd->obj.ptr); | 1441 | error = sctp_outq_tail(&asoc->outqueue, cmd->obj.chunk); |
1442 | break; | 1442 | break; |
1443 | 1443 | ||
1444 | case SCTP_CMD_SEND_PKT: | 1444 | case SCTP_CMD_SEND_PKT: |
1445 | /* Send a full packet to our peer. */ | 1445 | /* Send a full packet to our peer. */ |
1446 | packet = cmd->obj.ptr; | 1446 | packet = cmd->obj.packet; |
1447 | sctp_packet_transmit(packet); | 1447 | sctp_packet_transmit(packet); |
1448 | sctp_ootb_pkt_free(packet); | 1448 | sctp_ootb_pkt_free(packet); |
1449 | break; | 1449 | break; |
@@ -1480,7 +1480,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
1480 | break; | 1480 | break; |
1481 | 1481 | ||
1482 | case SCTP_CMD_SETUP_T2: | 1482 | case SCTP_CMD_SETUP_T2: |
1483 | sctp_cmd_setup_t2(commands, asoc, cmd->obj.ptr); | 1483 | sctp_cmd_setup_t2(commands, asoc, cmd->obj.chunk); |
1484 | break; | 1484 | break; |
1485 | 1485 | ||
1486 | case SCTP_CMD_TIMER_START_ONCE: | 1486 | case SCTP_CMD_TIMER_START_ONCE: |
@@ -1514,7 +1514,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
1514 | break; | 1514 | break; |
1515 | 1515 | ||
1516 | case SCTP_CMD_INIT_CHOOSE_TRANSPORT: | 1516 | case SCTP_CMD_INIT_CHOOSE_TRANSPORT: |
1517 | chunk = cmd->obj.ptr; | 1517 | chunk = cmd->obj.chunk; |
1518 | t = sctp_assoc_choose_alter_transport(asoc, | 1518 | t = sctp_assoc_choose_alter_transport(asoc, |
1519 | asoc->init_last_sent_to); | 1519 | asoc->init_last_sent_to); |
1520 | asoc->init_last_sent_to = t; | 1520 | asoc->init_last_sent_to = t; |
@@ -1665,17 +1665,16 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
1665 | break; | 1665 | break; |
1666 | 1666 | ||
1667 | case SCTP_CMD_PART_DELIVER: | 1667 | case SCTP_CMD_PART_DELIVER: |
1668 | sctp_ulpq_partial_delivery(&asoc->ulpq, cmd->obj.ptr, | 1668 | sctp_ulpq_partial_delivery(&asoc->ulpq, GFP_ATOMIC); |
1669 | GFP_ATOMIC); | ||
1670 | break; | 1669 | break; |
1671 | 1670 | ||
1672 | case SCTP_CMD_RENEGE: | 1671 | case SCTP_CMD_RENEGE: |
1673 | sctp_ulpq_renege(&asoc->ulpq, cmd->obj.ptr, | 1672 | sctp_ulpq_renege(&asoc->ulpq, cmd->obj.chunk, |
1674 | GFP_ATOMIC); | 1673 | GFP_ATOMIC); |
1675 | break; | 1674 | break; |
1676 | 1675 | ||
1677 | case SCTP_CMD_SETUP_T4: | 1676 | case SCTP_CMD_SETUP_T4: |
1678 | sctp_cmd_setup_t4(commands, asoc, cmd->obj.ptr); | 1677 | sctp_cmd_setup_t4(commands, asoc, cmd->obj.chunk); |
1679 | break; | 1678 | break; |
1680 | 1679 | ||
1681 | case SCTP_CMD_PROCESS_OPERR: | 1680 | case SCTP_CMD_PROCESS_OPERR: |
@@ -1734,8 +1733,8 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
1734 | break; | 1733 | break; |
1735 | 1734 | ||
1736 | default: | 1735 | default: |
1737 | pr_warn("Impossible command: %u, %p\n", | 1736 | pr_warn("Impossible command: %u\n", |
1738 | cmd->verb, cmd->obj.ptr); | 1737 | cmd->verb); |
1739 | break; | 1738 | break; |
1740 | } | 1739 | } |
1741 | 1740 | ||
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c index 360d8697b95c..ada17464b65b 100644 --- a/net/sctp/ulpqueue.c +++ b/net/sctp/ulpqueue.c | |||
@@ -997,7 +997,6 @@ static __u16 sctp_ulpq_renege_frags(struct sctp_ulpq *ulpq, __u16 needed) | |||
997 | 997 | ||
998 | /* Partial deliver the first message as there is pressure on rwnd. */ | 998 | /* Partial deliver the first message as there is pressure on rwnd. */ |
999 | void sctp_ulpq_partial_delivery(struct sctp_ulpq *ulpq, | 999 | void sctp_ulpq_partial_delivery(struct sctp_ulpq *ulpq, |
1000 | struct sctp_chunk *chunk, | ||
1001 | gfp_t gfp) | 1000 | gfp_t gfp) |
1002 | { | 1001 | { |
1003 | struct sctp_ulpevent *event; | 1002 | struct sctp_ulpevent *event; |
@@ -1060,7 +1059,7 @@ void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk, | |||
1060 | sctp_tsnmap_mark(&asoc->peer.tsn_map, tsn, chunk->transport); | 1059 | sctp_tsnmap_mark(&asoc->peer.tsn_map, tsn, chunk->transport); |
1061 | sctp_ulpq_tail_data(ulpq, chunk, gfp); | 1060 | sctp_ulpq_tail_data(ulpq, chunk, gfp); |
1062 | 1061 | ||
1063 | sctp_ulpq_partial_delivery(ulpq, chunk, gfp); | 1062 | sctp_ulpq_partial_delivery(ulpq, gfp); |
1064 | } | 1063 | } |
1065 | 1064 | ||
1066 | sk_mem_reclaim(asoc->base.sk); | 1065 | sk_mem_reclaim(asoc->base.sk); |