net/dccp: set safe upper bound for option length
Subsystems (2)
PATCH 1/1 net/dccp: set safe upper bound for option length
[DCCP]: current upper limit for option length is 128 bytes; much less than actually possible. This patch sets a safe upper bound on option length of 992, under worst-case assumptions.
This patches against the 2.6.19 tree by David.
--- dccp.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
net/dccp/dccp.h +11 -6
@@ -40,12 +40,17 @@ extern void dccp_tw_deschedule(struct inextern void dccp_time_wait (struct sock *sk,int state,int timeo); -/* FIXME: Right size this */ -#define DCCP_MAX_OPT_LEN 128 - -#define DCCP_MAX_PACKET_HDR 32 - -#define MAX_DCCP_HEADER (DCCP_MAX_PACKET_HDR + DCCP_MAX_OPT_LEN + MAX_HEADER) +/* +* Set safe upper bounds for header and option length. Since Data Offset is 8 +* bits (RFC 4340, sec. 5.1), the total header length can never be more than +* 8 * 255 = 1020 bytes. The largest possible header length is 28 bytes (X=1): +* - DCCP-Response with ACK Subheader and 4 bytes of Service code OR +* - DCCP-Reset with ACK Subheader and 4 bytes of Reset Code fields +* Hence a safe upper bound for the maximum option length is 1020-28 = 992 +*/ +#define DCCP_MAX_OPT_LEN 992 +#define DCCP_MAX_PACKET_HDR 28 +#define MAX_DCCP_HEADER (1020 + MAX_HEADER)#define DCCP_TIMEWAIT_LEN (60 * HZ)/* how long to wait to destroy TIME-WAIT * state, about 60 seconds */
Stupid me, it should read 4 * 255 = 1020, not 8 * 255; this is fixed below.
--
net/dccp/dccp.h +11 -6
@@ -40,12 +40,17 @@ extern void dccp_tw_deschedule(struct inextern void dccp_time_wait (struct sock *sk,int state,int timeo); -/* FIXME: Right size this */ -#define DCCP_MAX_OPT_LEN 128 - -#define DCCP_MAX_PACKET_HDR 32 - -#define MAX_DCCP_HEADER (DCCP_MAX_PACKET_HDR + DCCP_MAX_OPT_LEN + MAX_HEADER) +/* +* Set safe upper bounds for header and option length. Since Data Offset is 8 +* bits (RFC 4340, sec. 5.1), the total header length can never be more than +* 4 * 255 = 1020 bytes. The largest possible header length is 28 bytes (X=1): +* - DCCP-Response with ACK Subheader and 4 bytes of Service code OR +* - DCCP-Reset with ACK Subheader and 4 bytes of Reset Code fields +* Hence a safe upper bound for the maximum option length is 1020-28 = 992 +*/ +#define DCCP_MAX_OPT_LEN 992 +#define DCCP_MAX_PACKET_HDR 28 +#define MAX_DCCP_HEADER (1020 + MAX_HEADER)#define DCCP_TIMEWAIT_LEN (60 * HZ)/* how long to wait to destroy TIME-WAIT * state, about 60 seconds */
Quoted 5 lines · Gerrit Renker
[DCCP]: current upper limit for option length is 128 bytes; much less than actually possible. This patch sets a safe upper bound on option length of 992, under worst-case assumptions.
This patches against the 2.6.19 tree by David.
Gerrit, could you please use my net-2.6.19? I'm going over the pending dccp patches backlog and it is possible that this patch now doesn't applies, haven't checked tho as I'm going out, will check in 20 minutes or so.
Ah, and please keep [email protected] instead of netdev when the patch is only dccp specific.
Thanks,
- Arnaldo
Hi Arnaldo
| Gerrit, could you please use my net-2.6.19?
Of course - I didn't know it was active. I have just pulled your tree and the patch applies without problem.
Will use this tree now for all dccp work.
Gerrit
Quoted 4 lines · Gerrit Renker
Hi Arnaldo
| Gerrit, could you please use my net-2.6.19?
Of course - I didn't know it was active. I have just pulled your tree and the patch applies without problem.
OK, going over it now.
Quoted 1 line
Will use this tree now for all dccp work.
Thanks,
- Arnaldo
Quoted 23 lines · Arnaldo Carvalho de Melo
Quoted 4 lines · Gerrit Renker
Hi Arnaldo
| Gerrit, could you please use my net-2.6.19?
Of course - I didn't know it was active. I have just pulled your tree and the patch applies without problem.OK, going over it now.
net/dccp/dccp.h +1
-6@@ -40,12 +40,17 @@ extern void dccp_tw_deschedule(struct inextern void dccp_time_wait (struct sock *sk,int state,int timeo); -/* FIXME: Right size this */ -#define DCCP_MAX_OPT_LEN 128 - -#define DCCP_MAX_PACKET_HDR 32 - -#define MAX_DCCP_HEADER (DCCP_MAX_PACKET_HDR + DCCP_MAX_OPT_LEN + MAX_HEADER) +/*
net/dccp/dccp.h extern void dccp_tw_deschedule(struct in · line 53
Quoted 10 lines
net/dccp/dccp.h +10
-0+* Set safe upper bounds for header and option length. Since Data Offset is 8 +* bits (RFC 4340, sec. 5.1), the total header length can never be more than +* 4 * 255 = 1020 bytes. The largest possible header length is 28 bytes (X=1): +* - DCCP-Response with ACK Subheader and 4 bytes of Service code OR +* - DCCP-Reset with ACK Subheader and 4 bytes of Reset Code fields +* Hence a safe upper bound for the maximum option length is 1020-28 = 992 +*/ +#define DCCP_MAX_OPT_LEN 992 +#define DCCP_MAX_PACKET_HDR 28 +#define MAX_DCCP_HEADER (1020 + MAX_HEADER)
With this change DCCP_MAX_PACKET_HDR is not used anywhere, I'm rewriting it so that we use it to calculate MAX_DCCP_HEADER, something like:
#define MAX_DCCP_SPECIFIC_HEADER (255 * sizeof(int))
#define DCCP_MAX_PACKET_HDR 28
#define DCCP_MAX_OPT_LEN (MAX_DCCP_SPECIFIC_HEADER - DCCP_MAX_PACKET_HDR) #define MAX_DCCP_HEADER (MAX_DCCP_SPECIFIC_HEADER + MAX_HEADER)
Thanks,
- Arnaldo
Hi Arnaldo
| With this change DCCP_MAX_PACKET_HDR is not used anywhere, I'm | rewriting it so that we use it to calculate MAX_DCCP_HEADER,
That is great, thank you for updating.
Gerrit