aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/dccp.h
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2010-10-11 14:35:40 -0400
committerGerrit Renker <gerrit@erg.abdn.ac.uk>2010-10-12 00:57:40 -0400
commit0b53d4604ac2b4f2faa9a62a04ea9b383ad2efe0 (patch)
tree70ed0d136ef719f33655f78b31650d1c88cd3e00 /net/dccp/dccp.h
parent0ed8ddf4045fcfcac36bad753dc4046118c603ec (diff)
dccp: fix the adjustments to AWL and SWL
This fixes a problem and a potential loophole with regard to seqno/ackno validity: currently the initial adjustments to AWL/SWL are only performed once at the begin of the connection, during the handshake. Since the Sequence Window feature is always greater than Wmin=32 (7.5.2), it is however necessary to perform these adjustments at least for the first W/W' (variables as per 7.5.1) packets in the lifetime of a connection. This requirement is complicated by the fact that W/W' can change at any time during the lifetime of a connection. Therefore it is better to perform that safety check each time SWL/AWL are updated, as implemented by the patch. A second problem solved by this patch is that the remote/local Sequence Window feature values (which set the bounds for AWL/SWL/SWH) are undefined until the feature negotiation has completed. During the initial handshake we have more stringent sequence number protection; the changes added by this patch effect that {A,S}W{L,H} are within the correct bounds at the instant that feature negotiation completes (since the SeqWin feature activation handlers call dccp_update_gsr/gss()). Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp/dccp.h')
-rw-r--r--net/dccp/dccp.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 019d6ffee354..e051c774ef5c 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -414,6 +414,23 @@ static inline void dccp_update_gsr(struct sock *sk, u64 seq)
414 dp->dccps_gsr = seq; 414 dp->dccps_gsr = seq;
415 /* Sequence validity window depends on remote Sequence Window (7.5.1) */ 415 /* Sequence validity window depends on remote Sequence Window (7.5.1) */
416 dp->dccps_swl = SUB48(ADD48(dp->dccps_gsr, 1), dp->dccps_r_seq_win / 4); 416 dp->dccps_swl = SUB48(ADD48(dp->dccps_gsr, 1), dp->dccps_r_seq_win / 4);
417 /*
418 * Adjust SWL so that it is not below ISR. In contrast to RFC 4340,
419 * 7.5.1 we perform this check beyond the initial handshake: W/W' are
420 * always > 32, so for the first W/W' packets in the lifetime of a
421 * connection we always have to adjust SWL.
422 * A second reason why we are doing this is that the window depends on
423 * the feature-remote value of Sequence Window: nothing stops the peer
424 * from updating this value while we are busy adjusting SWL for the
425 * first W packets (we would have to count from scratch again then).
426 * Therefore it is safer to always make sure that the Sequence Window
427 * is not artificially extended by a peer who grows SWL downwards by
428 * continually updating the feature-remote Sequence-Window.
429 * If sequence numbers wrap it is bad luck. But that will take a while
430 * (48 bit), and this measure prevents Sequence-number attacks.
431 */
432 if (before48(dp->dccps_swl, dp->dccps_isr))
433 dp->dccps_swl = dp->dccps_isr;
417 dp->dccps_swh = ADD48(dp->dccps_gsr, (3 * dp->dccps_r_seq_win) / 4); 434 dp->dccps_swh = ADD48(dp->dccps_gsr, (3 * dp->dccps_r_seq_win) / 4);
418} 435}
419 436
@@ -424,6 +441,9 @@ static inline void dccp_update_gss(struct sock *sk, u64 seq)
424 dp->dccps_gss = seq; 441 dp->dccps_gss = seq;
425 /* Ack validity window depends on local Sequence Window value (7.5.1) */ 442 /* Ack validity window depends on local Sequence Window value (7.5.1) */
426 dp->dccps_awl = SUB48(ADD48(dp->dccps_gss, 1), dp->dccps_l_seq_win); 443 dp->dccps_awl = SUB48(ADD48(dp->dccps_gss, 1), dp->dccps_l_seq_win);
444 /* Adjust AWL so that it is not below ISS - see comment above for SWL */
445 if (before48(dp->dccps_awl, dp->dccps_iss))
446 dp->dccps_awl = dp->dccps_iss;
427 dp->dccps_awh = dp->dccps_gss; 447 dp->dccps_awh = dp->dccps_gss;
428} 448}
429 449