Implement SCTP-AUTH specification.
Subsystems (3)
cover Implement SCTP-AUTH specification.
Hi All
The following series of 8 patches is the implementation of SCTP-AUTH spec (RFC 4895) that was tested at the 9th SCTP Interop. The code is based on the implementation of the Supported Extensions parameter that was send out separately for inclusion into 2.6.24.
I'd really appreciate people reviewing this as I hope for this to make the 2.6.24 code base.
Thanks
-vlad
PATCH 1/8 SCTP: protocol definitions for SCTP-AUTH implementation
--- include/linux/sctp.h | 100 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 99 insertions(+), 1 deletions(-)
include/linux/sctp.h +99 -1
@@ -102,6 +102,9 @@ typedef enum {SCTP_CID_ECN_CWR =13 ,SCTP_CID_SHUTDOWN_COMPLETE =14 , +/* AUTH Extension Section 4.1 */ +SCTP_CID_AUTH =0x0F , +/* PR-SCTP Sec 3.2 */ SCTP_CID_FWD_TSN = 0xC0,
@@ -180,6 +183,11 @@ typedef enum {SCTP_PARAM_SUPPORTED_ADDRESS_TYPES =__constant_htons (12 ),SCTP_PARAM_ECN_CAPABLE =__constant_htons (0x8000 ), +/* AUTH Extension Section 3 */ +SCTP_PARAM_RANDOM =__constant_htons (0x8002 ), +SCTP_PARAM_CHUNKS =__constant_htons (0x8003 ), +SCTP_PARAM_HMAC_ALGO =__constant_htons (0x8004 ), +/* Add-IP: Supported Extensions, Section 4.2 */ SCTP_PARAM_SUPPORTED_EXT = __constant_htons(0x8008),
@@ -305,6 +313,24 @@ typedef struct sctp_supported_ext_param {__u8 chunks[0 ]; } __attribute__((packed)) sctp_supported_ext_param_t; +/* AUTH Section 3.1 Random */ +typedef struct sctp_random_param { +sctp_paramhdr_t param_hdr; +__u8 random_val[0 ]; +} __attribute__((packed))sctp_random_param_t ; + +/* AUTH Section 3.2 Chunk List */ +typedef struct sctp_chunks_param { +sctp_paramhdr_t param_hdr; +__u8 chunks[0 ]; +} __attribute__((packed))sctp_chunks_param_t ; + +/* AUTH Section 3.3 HMAC Algorithm */ +typedef struct sctp_hmac_algo_param { +sctp_paramhdr_t param_hdr; +__be16 hmac_ids[0 ]; +} __attribute__((packed))sctp_hmac_algo_param_t ; +/* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2): * The INIT ACK chunk is used to acknowledge the initiation of an SCTP * association.
@@ -471,7 +497,19 @@ typedef enum {SCTP_ERROR_RSRC_LOW =__constant_htons (0x0101 ),SCTP_ERROR_DEL_SRC_IP =__constant_htons (0x0102 ),SCTP_ERROR_ASCONF_ACK =__constant_htons (0x0103 ), - SCTP_ERROR_REQ_REFUSED = __constant_htons(0x0104) +SCTP_ERROR_REQ_REFUSED =__constant_htons (0x0104 ), + +/* AUTH Section 4. New Error Cause +* +* This section defines a new error cause that will be sent if an AUTH +* chunk is received with an unsupported HMAC identifier. +* illustrates the new error cause. +* +* Cause Code Error Cause Name +* -------------------------------------------------------------- +* 0x0105 Unsupported HMAC Identifier +*/ + SCTP_ERROR_UNSUP_HMAC = __constant_htons(0x0105) } sctp_error_t;
@@ -609,4 +647,64 @@ typedef struct sctp_addip_chunk {sctp_addiphdr_t addip_hdr; } __attribute__((packed)) sctp_addip_chunk_t; +/* AUTH +* Section 4.1 Authentication Chunk (AUTH) +* +* This chunk is used to hold the result of the HMAC calculation. +* +* 0 1 2 3 +* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +* | Type = 0x0F | Flags=0 | Length | +* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +* | Shared Key Identifier | HMAC Identifier | +* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +* | | +* \ HMAC / +* / \ +* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +* +* Type: 1 byte (unsigned integer) +* This value MUST be set to 0x0F for all AUTH-chunks. +* +* Flags: 1 byte (unsigned integer) +* Set to zero on transmit and ignored on receipt. +* +* Length: 2 bytes (unsigned integer) +* This value holds the length of the HMAC in bytes plus 8. +* +* Shared Key Identifier: 2 bytes (unsigned integer) +* This value describes which endpoint pair shared key is used. +* +* HMAC Identifier: 2 bytes (unsigned integer) +* This value describes which message digest is being used. Table 2 +* shows the currently defined values. +* +* The following Table 2 shows the currently defined values for HMAC +* identifiers. +* +* +-----------------+--------------------------+ +* | HMAC Identifier | Message Digest Algorithm | +* +-----------------+--------------------------+ +* | 0 | Reserved | +* | 1 | SHA-1 defined in [8] | +* | 2 | Reserved | +* | 3 | SHA-256 defined in [8] | +* +-----------------+--------------------------+ +* +* +* HMAC: n bytes (unsigned integer) This hold the result of the HMAC +* calculation. +*/ +typedef struct sctp_authhdr { +__be16 shkey_id; +__be16 hmac_id; +__u8 hmac[0 ]; +} __attribute__((packed))sctp_authhdr_t ; + +typedef struct sctp_auth_chunk { +sctp_chunkhdr_t chunk_hdr; +sctp_authhdr_t auth_hdr; +} __attribute__((packed))sctp_auth_chunk_t ; +#endif /* __LINUX_SCTP_H__ */
Signature · 1 line
1.5.2.4
Re: [PATCH 1/8] SCTP: protocol definitions for SCTP-AUTH implementation
From: Vlad Yasevich <[email protected]>
Date: Fri, 14 Sep 2007 14:44:52 -0400
Quoted 1 line
Signed-off-by Vlad Yasevich <[email protected]>
Applied to net-2.6.24
PATCH 2/8 SCTP: Implement SCTP-AUTH internals
In reply to Vlad YasevichThis patch implements the internals operations of the AUTH, such as key computation and storage. It also adds necessary variables to the SCTP data structures.
--- include/net/sctp/auth.h | 112 +++++++ include/net/sctp/constants.h | 49 +++- include/net/sctp/sctp.h | 1 + include/net/sctp/structs.h | 71 ++++- net/sctp/Makefile | 3 +- net/sctp/auth.c | 744 ++++++++++++++++++++++++++++++++++++++++++ net/sctp/objcnt.c | 2 + 7 files changed, 975 insertions(+), 7 deletions(-) create mode 100644 include/net/sctp/auth.h create mode 100644 net/sctp/auth.c
include/net/sctp/auth.h new file +112 -0
@@ -0,0 +1,112 @@ +/* SCTP kernel reference Implementation +* (C) Copyright 2007 Hewlett-Packard Development Company, L.P. +* +* This file is part of the SCTP kernel reference Implementation +* +* The SCTP reference implementation is free software; +* you can redistribute it and/or modify it under the terms of +* the GNU General Public License as published by +* the Free Software Foundation; either version 2, or (at your option) +* any later version. +* +* The SCTP reference implementation is distributed in the hope that it +* will be useful, but WITHOUT ANY WARRANTY; without even the implied +* ************************ +* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* See the GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GNU CC; see the file COPYING. If not, write to +* the Free Software Foundation, 59 Temple Place - Suite 330, +* Boston, MA 02111-1307, USA. +* +* Please send any bug reports or fixes you make to the +* email address(es): +* lksctp developers <[email protected]> +* +* Or submit a bug report through the following website: +* http://www.sf.net/projects/lksctp +* +* Written or modified by: +* Vlad Yasevich <[email protected]> +* +* Any bugs reported given to us we will try to fix... any fixes shared will +* be incorporated into the next SCTP release. +*/ + +#ifndef __sctp_auth_h__ +#define __sctp_auth_h__ + +#include <linux/list.h> +#include <linux/crypto.h> + +struct sctp_endpoint ; +struct sctp_association ; +struct sctp_authkey ; + +/* +* Define a generic struct that will hold all the info +* necessary for an HMAC transform +*/ +struct sctp_hmac { +__u16 hmac_id;/* one of the above ids */ +char *hmac_name;/* name for loading */ +__u16 hmac_len;/* length of the signature */ +}; + +/* This is generic structure that containst authentication bytes used +* as keying material. It's a what is referred to as byte-vector all +* over SCTP-AUTH +*/ +struct sctp_auth_bytes { +atomic_t refcnt; +__u32 len; +__u8 data[]; +}; + +/* Definition for a shared key, weather endpoint or association */ +struct sctp_shared_key { +struct list_head key_list; +__u16 key_id; +struct sctp_auth_bytes *key; +}; + +#define key_for_each (__key, __list_head) \ + list_for_each_entry(__key, __list_head, key_list) + +#define key_for_each_safe (__key, __tmp, __list_head) \ + list_for_each_entry_safe(__key, __tmp, __list_head, key_list) + +static inline void sctp_auth_key_hold (struct sctp_auth_bytes *key) +{ +if (!key) +return ; + +atomic_inc (&key->refcnt); +} + +void sctp_auth_key_put (struct sctp_auth_bytes *key); +struct sctp_shared_key *sctp_auth_shkey_create (__u16 key_id,gfp_t gfp); +void sctp_auth_shkey_free (struct sctp_shared_key *sh_key); +void sctp_auth_destroy_keys (struct list_head *keys); +int sctp_auth_asoc_init_active_key (struct sctp_association *asoc,gfp_t gfp); +struct sctp_shared_key *sctp_auth_get_shkey ( +const struct sctp_association *asoc, +__u16 key_id); +int sctp_auth_asoc_copy_shkeys (const struct sctp_endpoint *ep, +struct sctp_association *asoc, +gfp_t gfp); +int sctp_auth_init_hmacs (struct sctp_endpoint *ep,gfp_t gfp); +void sctp_auth_destroy_hmacs (struct crypto_hash *auth_hmacs[]); +struct sctp_hmac *sctp_auth_get_hmac (__u16 hmac_id); +struct sctp_hmac *sctp_auth_asoc_get_hmac (const struct sctp_association *asoc); +void sctp_auth_asoc_set_default_hmac (struct sctp_association *asoc, +struct sctp_hmac_algo_param *hmacs); +int sctp_auth_asoc_verify_hmac_id (const struct sctp_association *asoc, +__u16 hmac_id); +int sctp_auth_send_cid (sctp_cid_t chunk,const struct sctp_association *asoc); +int sctp_auth_recv_cid (sctp_cid_t chunk,const struct sctp_association *asoc); +void sctp_auth_calculate_hmac (const struct sctp_association *asoc, +struct sk_buff *skb, +struct sctp_auth_chunk *auth,gfp_t gfp); +#endif
include/net/sctp/constants.h +48 -1
64 lines not on this page · raw message
include/net/sctp/sctp.h +1 -0
@@ -340,6 +340,7 @@ extern atomic_t sctp_dbg_objcnt_bind_bucket;extern atomic_t sctp_dbg_objcnt_addr;extern atomic_t sctp_dbg_objcnt_ssnmap;extern atomic_t sctp_dbg_objcnt_datamsg; +extern atomic_t sctp_dbg_objcnt_keys;/* Macros to atomically increment/decrement objcnt counters. */ #define SCTP_DBG_OBJCNT_INC (name) \
include/net/sctp/structs.h +66 -5
148 lines not on this page · raw message
net/sctp/Makefile +2 -1
@@ -9,7 +9,8 @@ sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \ transport.o chunk.o sm_make_chunk.o ulpevent.o \ inqueue.o outqueue.o ulpqueue.o command.o \ tsnmap.o bind_addr.o socket.o primitive.o \ - output.o input.o debug.o ssnmap.o proc.o crc32c.o + output.o input.o debug.o ssnmap.o proc.o crc32c.o \ + auth.o sctp-$(CONFIG_SCTP_DBG_OBJCNT) += objcnt.o sctp-$(CONFIG_SYSCTL) += sysctl.o
net/sctp/auth.c new file +744 -0
744 lines not on this page · raw message
net/sctp/objcnt.c +2 -0
@@ -58,6 +58,7 @@ SCTP_DBG_OBJCNT(chunk);SCTP_DBG_OBJCNT (addr);SCTP_DBG_OBJCNT (ssnmap);SCTP_DBG_OBJCNT (datamsg); +SCTP_DBG_OBJCNT (keys);/* An array to make it easy to pretty print the debug information * to the proc fs.
@@ -73,6 +74,7 @@ static sctp_dbg_objcnt_entry_t sctp_dbg_objcnt[] = {SCTP_DBG_OBJCNT_ENTRY (addr),SCTP_DBG_OBJCNT_ENTRY (ssnmap),SCTP_DBG_OBJCNT_ENTRY (datamsg), + SCTP_DBG_OBJCNT_ENTRY(keys), };/* Callback from procfs to read out objcount information.
Signature · 1 line
1.5.2.4
Re: [PATCH 2/8] SCTP: Implement SCTP-AUTH internals
From: Vlad Yasevich <[email protected]>
Date: Fri, 14 Sep 2007 14:44:53 -0400
Quoted 5 lines
This patch implements the internals operations of the AUTH, such as key computation and storage. It also adds necessary variables to the SCTP data structures.
Signed-off-by Vlad Yasevich <[email protected]>
Applied to net-2.6.24, with lots of trailing whitspace fixed.
Please check your patches with GIT by using something such as "git apply --check --whitespace=error-all foo.diff" in the future, and you'll see stuff like this:
Adds trailing whitespace.
diff:696:
Adds trailing whitespace.
diff:732: return secret;
Adds trailing whitespace.
diff:805:
Adds trailing whitespace.
diff:815:/*
Adds trailing whitespace.
diff:1034: break;
Adds trailing whitespace.
diff:1098:
Adds trailing whitespace.
diff:1109:
fatal: 7 lines add trailing whitespaces.
Thanks.
PATCH 3/8 SCTP: Implement SCTP-AUTH initializations.
In reply to Vlad YasevichThe patch initializes AUTH related members of the generic SCTP structures and provides a way to enable/disable auth extension.
--- net/sctp/associola.c | 34 +++++++++++++++++++ net/sctp/endpointola.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ net/sctp/output.c | 4 ++ net/sctp/protocol.c | 3 ++ net/sctp/sysctl.c | 9 +++++ 5 files changed, 133 insertions(+), 0 deletions(-)
net/sctp/associola.c +34 -0
@@ -74,6 +74,8 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a {struct sctp_sock *sp;int i; +sctp_paramhdr_t *p; +int err;/* Retrieve the SCTP per socket area. */ sp =sctp_sk ((struct sock *)sk);
@@ -299,6 +301,30 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a asoc->default_timetolive = sp->default_timetolive; asoc->default_rcv_context = sp->default_rcv_context; +/* AUTH related initializations */ +INIT_LIST_HEAD (&asoc->endpoint_shared_keys); + err =sctp_auth_asoc_copy_shkeys (ep, asoc, gfp); +if (err) + goto fail_init; + + asoc->active_key_id = ep->active_key_id; + asoc->asoc_shared_key =NULL ; + + asoc->default_hmac_id =0 ; +/* Save the hmacs and chunks list into this association */ +if (ep->auth_hmacs_list) +memcpy (asoc->c.auth_hmacs, ep->auth_hmacs_list, +ntohs (ep->auth_hmacs_list->param_hdr.length)); +if (ep->auth_chunk_list) +memcpy (asoc->c.auth_chunks, ep->auth_chunk_list, +ntohs (ep->auth_chunk_list->param_hdr.length)); + +/* Get the AUTH random number for this association */ + p = (sctp_paramhdr_t *)asoc->c.auth_random; + p->type =SCTP_PARAM_RANDOM ; + p->length =htons (sizeof (sctp_paramhdr_t) +SCTP_AUTH_RANDOM_LENGTH ); +get_random_bytes (p+1 ,SCTP_AUTH_RANDOM_LENGTH ); +return asoc; fail_init:
@@ -408,6 +434,12 @@ void sctp_association_free(struct sctp_association *asoc)if (asoc->addip_last_asconf)sctp_chunk_free (asoc->addip_last_asconf); +/* AUTH - Free the endpoint shared keys */ +sctp_auth_destroy_keys (&asoc->endpoint_shared_keys); + +/* AUTH - Free the association shared key */ +sctp_auth_key_put (asoc->asoc_shared_key); +sctp_association_put (asoc); }
@@ -1116,6 +1148,8 @@ void sctp_assoc_update(struct sctp_association *asoc,sctp_assoc_set_id (asoc,GFP_ATOMIC ); } } + +/* SCTP-AUTH: XXX something needs to be done here*/ }/* Update the retran path for sending a retransmitted packet.
net/sctp/endpointola.c +83 -0
108 lines not on this page · raw message
net/sctp/output.c +4 -0
@@ -79,7 +79,9 @@ struct sctp_packet *sctp_packet_config(struct sctp_packet *packet, packet->vtag = vtag; packet->has_cookie_echo =0 ; packet->has_sack =0 ; + packet->has_auth =0 ; packet->ipfragok =0 ; + packet->auth =NULL ;if (ecn_capable &&sctp_packet_empty (packet)) { chunk =sctp_get_ecne_prepend (packet->transport->asoc);
@@ -121,8 +123,10 @@ struct sctp_packet *sctp_packet_init(struct sctp_packet *packet, packet->vtag =0 ; packet->has_cookie_echo =0 ; packet->has_sack =0 ; + packet->has_auth =0 ; packet->ipfragok =0 ; packet->malloced =0 ; + packet->auth =NULL ;return packet; }
net/sctp/protocol.c +3 -0
@@ -1167,6 +1167,9 @@ SCTP_STATIC __init int sctp_init(void)/* Enable PR-SCTP by default. */ sctp_prsctp_enable =1 ; +/* Disable AUTH by default. */ + sctp_auth_enable =0 ; +sctp_sysctl_register ();INIT_LIST_HEAD (&sctp_address_families);
net/sctp/sysctl.c +9 -0
@@ -254,6 +254,15 @@ static ctl_table sctp_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "auth_enable", + .data = &sctp_auth_enable, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + .strategy = &sysctl_intvec + }, { .ctl_name = 0 } };
Signature · 1 line
1.5.2.4
Re: [PATCH 3/8] SCTP: Implement SCTP-AUTH initializations.
From: Vlad Yasevich <[email protected]>
Date: Fri, 14 Sep 2007 14:44:54 -0400
Quoted 4 lines
The patch initializes AUTH related members of the generic SCTP structures and provides a way to enable/disable auth extension.
Signed-off-by Vlad Yasevich <[email protected]>
Applied to net-2.6.24
PATCH 4/8 SCTP: Implete SCTP-AUTH parameter processing
In reply to Vlad YasevichImplement processing for the CHUNKS, RANDOM, and HMAC parameters and deal with how this parameters are effected by association restarts. In particular, during unexpeted INIT processing, we need to reply with parameters from the original INIT chunk. Also, after restart, we need to update the old association with new peer parameters and change the association shared keys.
--- include/net/sctp/command.h | 1 + net/sctp/associola.c | 21 ++++++- net/sctp/sm_make_chunk.c | 162 +++++++++++++++++++++++++++++++++++++++++++- net/sctp/sm_sideeffect.c | 5 ++ net/sctp/sm_statefuns.c | 35 ++++++++++ 5 files changed, 220 insertions(+), 4 deletions(-)
include/net/sctp/command.h +1 -0
@@ -102,6 +102,7 @@ typedef enum {SCTP_CMD_SET_SK_ERR ,/* Set sk_err */ SCTP_CMD_ASSOC_CHANGE ,/* generate and send assoc_change event */ SCTP_CMD_ADAPTATION_IND ,/* generate and send adaptation event */ +SCTP_CMD_ASSOC_SHKEY ,/* generate the association shared keys */ SCTP_CMD_LAST } sctp_verb_t;
net/sctp/associola.c +20 -1
@@ -416,6 +416,9 @@ void sctp_association_free(struct sctp_association *asoc)/* Free peer's cached cookie. */ kfree (asoc->peer.cookie); +kfree (asoc->peer.peer_random); +kfree (asoc->peer.peer_chunks); +kfree (asoc->peer.peer_hmacs);/* Release the transport structures. */ list_for_each_safe (pos, temp, &asoc->peer.transport_addr_list) {
@@ -1149,7 +1152,23 @@ void sctp_assoc_update(struct sctp_association *asoc, } } -/* SCTP-AUTH: XXX something needs to be done here*/ +/* SCTP-AUTH: Save the peer parameters from the new assocaitions +* and also move the association shared keys over +*/ +kfree (asoc->peer.peer_random); + asoc->peer.peer_random = new->peer.peer_random; + new->peer.peer_random =NULL ; + +kfree (asoc->peer.peer_chunks); + asoc->peer.peer_chunks = new->peer.peer_chunks; + new->peer.peer_chunks =NULL ; + +kfree (asoc->peer.peer_hmacs); + asoc->peer.peer_hmacs = new->peer.peer_hmacs; + new->peer.peer_hmacs =NULL ; + +sctp_auth_key_put (asoc->asoc_shared_key); +sctp_auth_asoc_init_active_key (asoc,GFP_ATOMIC ); }/* Update the retran path for sending a retransmitted packet.
net/sctp/sm_make_chunk.c +159 -3
235 lines not on this page · raw message
net/sctp/sm_sideeffect.c +5 -0
@@ -1524,6 +1524,11 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,sctp_cmd_adaptation_ind (commands, asoc);break ; +case SCTP_CMD_ASSOC_SHKEY : + error =sctp_auth_asoc_init_active_key (asoc, +GFP_ATOMIC ); +break ; +default :printk (KERN_WARNING "Impossible command: %u, %p\n" , cmd->verb, cmd->obj.ptr);
net/sctp/sm_statefuns.c +35 -0
@@ -524,6 +524,11 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep,sctp_add_cmd_sf (commands,SCTP_CMD_NEW_STATE ,SCTP_STATE (SCTP_STATE_COOKIE_ECHOED )); +/* SCTP-AUTH: genereate the assocition shared keys so that +* we can potentially signe the COOKIE-ECHO. +*/ +sctp_add_cmd_sf (commands,SCTP_CMD_ASSOC_SHKEY ,SCTP_NULL ()); +/* 5.1 C) "A" shall then send the State Cookie received in the * INIT ACK chunk in a COOKIE ECHO chunk, ... */
@@ -661,6 +666,14 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, peer_init, GFP_ATOMIC)) goto nomem_init; +/* SCTP-AUTH: Now that we've populate required fields in +* sctp_process_init, set up the assocaition shared keys as +* necessary so that we can potentially authenticate the ACK +*/ + error =sctp_auth_asoc_init_active_key (new_asoc,GFP_ATOMIC ); +if (error) + goto nomem_init; + repl =sctp_make_cookie_ack (new_asoc, chunk);if (!repl) goto nomem_init;
@@ -1222,6 +1235,26 @@ static void sctp_tietags_populate(struct sctp_association *new_asoc, new_asoc->c.initial_tsn = asoc->c.initial_tsn; } +static void sctp_auth_params_populate (struct sctp_association *new_asoc, +const struct sctp_association *asoc) +{ +/* Only perform this if AUTH extension is enabled */ +if (!sctp_auth_enable) +return ; + +/* We need to provide the same parameter information as +* was in the original INIT. This means that we need to copy +* the HMACS, CHUNKS, and RANDOM parameter from the original +* assocaition. +*/ +memcpy (new_asoc->c.auth_random, asoc->c.auth_random, +sizeof (asoc->c.auth_random)); +memcpy (new_asoc->c.auth_hmacs, asoc->c.auth_hmacs, +sizeof (asoc->c.auth_hmacs)); +memcpy (new_asoc->c.auth_chunks, asoc->c.auth_chunks, +sizeof (asoc->c.auth_chunks)); +} +/* * Compare vtag/tietag values to determine unexpected COOKIE-ECHO * handling action.
@@ -1379,6 +1412,8 @@ static sctp_disposition_t sctp_sf_do_unexpected_init(sctp_tietags_populate (new_asoc, asoc); +sctp_auth_params_populate (new_asoc, asoc); +/* B) "Z" shall respond immediately with an INIT ACK chunk. */ /* If there are errors need to be reported for unknown parameters,
Signature · 1 line
1.5.2.4
Re: [PATCH 4/8] SCTP: Implete SCTP-AUTH parameter processing
From: Vlad Yasevich <[email protected]>
Date: Fri, 14 Sep 2007 14:44:55 -0400
Quoted 8 lines
Implement processing for the CHUNKS, RANDOM, and HMAC parameters and deal with how this parameters are effected by association restarts. In particular, during unexpeted INIT processing, we need to reply with parameters from the original INIT chunk. Also, after restart, we need to update the old association with new peer parameters and change the association shared keys.
Signed-off-by Vlad Yasevich <[email protected]>
Applied to net-2.6.24, thanks.
PATCH 5/8 SCTP: Enable the sending of the AUTH chunk.
In reply to Vlad YasevichSCTP-AUTH, Section 6.2:
Endpoints MUST send all requested chunks authenticated where this has been requested by the peer. The other chunks MAY be sent authenticated or not. If endpoint pair shared keys are used, one of them MUST be selected for authentication.
To send chunks in an authenticated way, the sender MUST include these chunks after an AUTH chunk. This means that a sender MUST bundle chunks in order to authenticate them.
If the endpoint has no endpoint pair shared key for the peer, it MUST use Shared Key Identifier 0 with an empty endpoint pair shared key. If there are multiple endpoint shared keys the sender selects one and uses the corresponding Shared Key Identifier
--- include/net/sctp/sm.h | 1 + include/net/sctp/structs.h | 3 + net/sctp/chunk.c | 12 ++++ net/sctp/output.c | 131 +++++++++++++++++++++++++++++++++++--------- net/sctp/sm_make_chunk.c | 39 +++++++++++++ 5 files changed, 159 insertions(+), 27 deletions(-)
include/net/sctp/sm.h +1 -0
@@ -254,6 +254,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,struct sctp_chunk *sctp_make_fwdtsn (const struct sctp_association *asoc,__u32 new_cum_tsn,size_t nstreams,struct sctp_fwdtsn_skip *skiplist); +struct sctp_chunk *sctp_make_auth (const struct sctp_association *asoc);void sctp_chunk_assign_tsn (struct sctp_chunk *);void sctp_chunk_assign_ssn (struct sctp_chunk *);
include/net/sctp/structs.h +3 -0
@@ -791,6 +791,9 @@ struct sctp_packet {/* This packet contains an AUTH chunk */ __u8 has_auth; +/* This packet contains at least 1 DATA chunk */ +__u8 has_data; +/* SCTP cannot fragment this packet. So let ip fragment it. */ __u8 ipfragok;
net/sctp/chunk.c +12 -0
@@ -194,6 +194,18 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc, max = asoc->frag_point; +/* If the the peer requested that we authenticate DATA chunks +* we need to accound for bundling of the AUTH chunks along with +* DATA. +*/ +if (sctp_auth_send_cid (SCTP_CID_DATA , asoc)) { +struct sctp_hmac *hmac_desc =sctp_auth_asoc_get_hmac (asoc); + +if (hmac_desc) + max -=WORD_ROUND (sizeof (sctp_auth_chunk_t) + + hmac_desc->hmac_len); + } + whole =0 ; first_len = max;
net/sctp/output.c +104 -27
205 lines not on this page · raw message
net/sctp/sm_make_chunk.c +39 -0
@@ -1111,6 +1111,41 @@ nodata:return retval; } +struct sctp_chunk *sctp_make_auth (const struct sctp_association *asoc) +{ +struct sctp_chunk *retval; +struct sctp_hmac *hmac_desc; +struct sctp_authhdr auth_hdr; +__u8 *hmac; + +/* Get the first hmac that the peer told us to use */ + hmac_desc =sctp_auth_asoc_get_hmac (asoc); +if (unlikely (!hmac_desc)) +return NULL ; + + retval =sctp_make_chunk (asoc,SCTP_CID_AUTH ,0 , + hmac_desc->hmac_len +sizeof (sctp_authhdr_t)); +if (!retval) +return NULL ; + + auth_hdr.hmac_id =htons (hmac_desc->hmac_id); + auth_hdr.shkey_id =htons (asoc->active_key_id); + + retval->subh.auth_hdr =sctp_addto_chunk (retval,sizeof (sctp_authhdr_t), + &auth_hdr); + + hmac =skb_put (retval->skb, hmac_desc->hmac_len); +memset (hmac,0 , hmac_desc->hmac_len); + +/* Adjust the chunk header to include the empty MAC */ + retval->chunk_hdr->length = +htons (ntohs (retval->chunk_hdr->length) + hmac_desc->hmac_len); + retval->chunk_end =skb_tail_pointer (retval->skb); + +return retval; +} + +/******************************************************************** * 2nd Level Abstractions ********************************************************************/
@@ -1225,6 +1260,10 @@ struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc, retval->chunk_hdr = chunk_hdr; retval->chunk_end = ((__u8 *)chunk_hdr) +sizeof (struct sctp_chunkhdr ); +/* Determine if the chunk needs to be authenticated */ +if (sctp_auth_send_cid (type, asoc)) + retval->auth =1 ; +/* Set the skb to the belonging sock for accounting. */ skb->sk = sk;
Signature · 1 line
1.5.2.4
Re: [PATCH 5/8] SCTP: Enable the sending of the AUTH chunk.
From: Vlad Yasevich <[email protected]>
Date: Fri, 14 Sep 2007 14:44:56 -0400
Quoted 11 lines
SCTP-AUTH, Section 6.2:
Endpoints MUST send all requested chunks authenticated where this has been requested by the peer. The other chunks MAY be sent authenticated or not. If endpoint pair shared keys are used, one of them MUST be selected for authentication.
To send chunks in an authenticated way, the sender MUST include these chunks after an AUTH chunk. This means that a sender MUST bundle chunks in order to authenticate them.
Quoted 6 lines
If the endpoint has no endpoint pair shared key for the peer, it MUST use Shared Key Identifier 0 with an empty endpoint pair shared key. If there are multiple endpoint shared keys the sender selects one and uses the corresponding Shared Key Identifier
Signed-off-by Vlad Yasevich <[email protected]>
Applied to net-2.6.24, thanks.
PATCH 6/8 SCTP: Implement the receive and verification of AUTH chunk
In reply to Vlad YasevichThis patch implements the receive path needed to process authenticated chunks. Add ability to process the AUTH chunk and handle edge cases for authenticated COOKIE-ECHO as well.
--- include/net/sctp/constants.h | 4 +- include/net/sctp/sm.h | 1 + include/net/sctp/structs.h | 8 ++ net/sctp/associola.c | 10 ++ net/sctp/endpointola.c | 29 ++++++ net/sctp/input.c | 65 +++++++++++-- net/sctp/inqueue.c | 19 ++++ net/sctp/sm_statefuns.c | 218 +++++++++++++++++++++++++++++++++++++++++- net/sctp/sm_statetable.c | 33 +++++++ 9 files changed, 374 insertions(+), 13 deletions(-)
include/net/sctp/constants.h +3 -1
@@ -183,7 +183,9 @@ typedef enum {SCTP_IERROR_NO_DATA ,SCTP_IERROR_BAD_STREAM ,SCTP_IERROR_BAD_PORTS , - +SCTP_IERROR_AUTH_BAD_HMAC , +SCTP_IERROR_AUTH_BAD_KEYID , +SCTP_IERROR_PROTO_VIOLATION , } sctp_ierror_t;
include/net/sctp/sm.h +1 -0
@@ -144,6 +144,7 @@ sctp_state_fn_t sctp_sf_do_asconf_ack;sctp_state_fn_t sctp_sf_do_9_2_reshutack;sctp_state_fn_t sctp_sf_eat_fwd_tsn;sctp_state_fn_t sctp_sf_eat_fwd_tsn_fast; +sctp_state_fn_t sctp_sf_eat_auth;/* Prototypes for primitive event state functions. */ sctp_state_fn_t sctp_sf_do_prm_asoc;
include/net/sctp/structs.h +8 -0
@@ -719,6 +719,13 @@ struct sctp_chunk {*/ struct sctp_transport *transport; +/* SCTP-AUTH: For the special case inbound processing of COOKIE-ECHO +* we need save a pointer to the AUTH chunk, since the SCTP-AUTH +* spec violates the principle premis that all chunks are processed +* in order. +*/ +struct sk_buff *auth_chunk; +__u8 rtt_in_progress;/* Is this chunk used for RTT calculation? */ __u8 resent;/* Has this chunk ever been retransmitted. */ __u8 has_tsn;/* Does this chunk have a TSN yet? */
@@ -1060,6 +1067,7 @@ void sctp_inq_init(struct sctp_inq *);void sctp_inq_free (struct sctp_inq *);void sctp_inq_push (struct sctp_inq *,struct sctp_chunk *packet);struct sctp_chunk *sctp_inq_pop (struct sctp_inq *); +struct sctp_chunkhdr *sctp_inq_peek (struct sctp_inq *);void sctp_inq_set_th_handler (struct sctp_inq *,work_func_t );/* This is the structure we use to hold outbound chunks. You push
net/sctp/associola.c +10 -0
@@ -1015,6 +1015,16 @@ static void sctp_assoc_bh_rcv(struct work_struct *work) state = asoc->state; subtype =SCTP_ST_CHUNK (chunk->chunk_hdr->type); +/* SCTP-AUTH, Section 6.3: +* The receiver has a list of chunk types which it expects +* to be received only after an AUTH-chunk. This list has +* been sent to the peer during the association setup. It +* MUST silently discard these chunks if they are not placed +* after an AUTH chunk in the packet. +*/ +if (sctp_auth_recv_cid (subtype.chunk, asoc) && !chunk->auth) +continue ; +/* Remember where the last DATA chunk came from so we * know where to send the SACK. */
net/sctp/endpointola.c +29 -0
@@ -413,6 +413,7 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work)sctp_subtype_t subtype;sctp_state_t state;int error =0 ; +int first_time =1 ;/* is this the first time through the looop */ if (ep->base.dead)return ;
@@ -424,6 +425,29 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work)while (NULL != (chunk =sctp_inq_pop (inqueue))) { subtype =SCTP_ST_CHUNK (chunk->chunk_hdr->type); +/* If the first chunk in the packet is AUTH, do special +* processing specified in Section 6.3 of SCTP-AUTH spec +*/ +if (first_time && (subtype.chunk ==SCTP_CID_AUTH )) { +struct sctp_chunkhdr *next_hdr; + + next_hdr =sctp_inq_peek (inqueue); +if (!next_hdr) + goto normal; + +/* If the next chunk is COOKIE-ECHO, skip the AUTH +* chunk while saving a pointer to it so we can do +* Authentication later (during cookie-echo +* processing). +*/ +if (next_hdr->type ==SCTP_CID_COOKIE_ECHO ) { + chunk->auth_chunk =skb_clone (chunk->skb, +GFP_ATOMIC ); + chunk->auth =1 ; +continue ; + } + } +normal:/* We might have grown an association since last we * looked, so try again. *
@@ -439,6 +463,8 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work) } state = asoc ? asoc->state :SCTP_STATE_CLOSED ; +if (sctp_auth_recv_cid (subtype.chunk, asoc) && !chunk->auth) +continue ;/* Remember where the last DATA chunk came from so we * know where to send the SACK.
@@ -462,5 +488,8 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work)*/ if (!sctp_sk (sk)->ep)break ; + +if (first_time) + first_time =0 ; } }
net/sctp/input.c +55 -10
83 lines not on this page · raw message
net/sctp/inqueue.c +19 -0
@@ -100,6 +100,25 @@ void sctp_inq_push(struct sctp_inq *q, struct sctp_chunk *chunk) q->immediate.func (&q->immediate); } +/* Peek at the next chunk on the inqeue. */ +struct sctp_chunkhdr *sctp_inq_peek (struct sctp_inq *queue) +{ +struct sctp_chunk *chunk; +sctp_chunkhdr_t *ch =NULL ; + + chunk = queue->in_progress; +/* If there is no more chunks in this packet, say so */ +if (chunk->singleton || + chunk->end_of_packet || + chunk->pdiscard) +return NULL ; + + ch = (sctp_chunkhdr_t *)chunk->chunk_end; + +return ch; +} + +/* Extract a chunk from an SCTP inqueue. * * WARNING: If you need to put the chunk on another queue, you need to
net/sctp/sm_statefuns.c +216 -2
260 lines not on this page · raw message
net/sctp/sm_statetable.c +33 -0
@@ -523,6 +523,34 @@ static const sctp_sm_table_entry_t prsctp_chunk_event_table[SCTP_NUM_PRSCTP_CHUN TYPE_SCTP_FWD_TSN, };/*state_fn_t prsctp_chunk_event_table[][] */ +#define TYPE_SCTP_AUTH { \ +/* SCTP_STATE_EMPTY */ \ +TYPE_SCTP_FUNC (sctp_sf_ootb), \ +/* SCTP_STATE_CLOSED */ \ +TYPE_SCTP_FUNC (sctp_sf_tabort_8_4_8 ), \ +/* SCTP_STATE_COOKIE_WAIT */ \ +TYPE_SCTP_FUNC (sctp_sf_discard_chunk ), \ +/* SCTP_STATE_COOKIE_ECHOED */ \ +TYPE_SCTP_FUNC (sctp_sf_eat_auth ), \ +/* SCTP_STATE_ESTABLISHED */ \ +TYPE_SCTP_FUNC (sctp_sf_eat_auth ), \ +/* SCTP_STATE_SHUTDOWN_PENDING */ \ +TYPE_SCTP_FUNC (sctp_sf_eat_auth ), \ +/* SCTP_STATE_SHUTDOWN_SENT */ \ +TYPE_SCTP_FUNC (sctp_sf_eat_auth ), \ +/* SCTP_STATE_SHUTDOWN_RECEIVED */ \ +TYPE_SCTP_FUNC (sctp_sf_eat_auth ), \ +/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ +TYPE_SCTP_FUNC (sctp_sf_eat_auth ), \ +} /* TYPE_SCTP_AUTH */ + +/* The primary index for this table is the chunk type. + * The secondary index for this table is the state. + */ +static const sctp_sm_table_entry_t auth_chunk_event_table[SCTP_NUM_AUTH_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = { +TYPE_SCTP_AUTH , +};/*state_fn_t auth_chunk_event_table[][] */ +static const sctp_sm_table_entry_t chunk_event_table_unknown[SCTP_STATE_NUM_STATES ] = {/* SCTP_STATE_EMPTY */
@@ -976,5 +1004,10 @@ static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid,return &addip_chunk_event_table[1 ][state]; } +if (sctp_auth_enable) { +if (cid ==SCTP_CID_AUTH ) +return &auth_chunk_event_table[0 ][state]; + } +return &chunk_event_table_unknown[state]; }
Signature · 1 line
1.5.2.4
Re: [PATCH 6/8] SCTP: Implement the receive and verification of AUTH chunk
From: Vlad Yasevich <[email protected]>
Date: Fri, 14 Sep 2007 14:44:57 -0400
Quoted 5 lines
This patch implements the receive path needed to process authenticated chunks. Add ability to process the AUTH chunk and handle edge cases for authenticated COOKIE-ECHO as well.
Signed-off-by Vlad Yasevich <[email protected]>
Applied to net-2.6.24, thanks.
PATCH 7/8 SCTP: API updates to suport SCTP-AUTH extensions.
In reply to Vlad YasevichAdd SCTP-AUTH API. The API implemented here was agreed to between implementors at the 9th SCTP Interop. It will be documented in the next revision of the SCTP socket API spec.
--- include/net/sctp/auth.h | 16 +++ include/net/sctp/ulpevent.h | 4 + include/net/sctp/user.h | 90 +++++++++++++ net/sctp/auth.c | 193 +++++++++++++++++++++++++++ net/sctp/sm_statefuns.c | 13 ++ net/sctp/socket.c | 304 +++++++++++++++++++++++++++++++++++++++++++ net/sctp/ulpevent.c | 37 +++++ 7 files changed, 657 insertions(+), 0 deletions(-)
include/net/sctp/auth.h +16 -0
@@ -43,6 +43,7 @@struct sctp_endpoint ;struct sctp_association ;struct sctp_authkey ; +struct sctp_hmacalgo ;/* * Define a generic struct that will hold all the info
@@ -109,4 +110,19 @@ int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc);void sctp_auth_calculate_hmac (const struct sctp_association *asoc,struct sk_buff *skb,struct sctp_auth_chunk *auth,gfp_t gfp); + +/* API Helpers */ +int sctp_auth_ep_add_chunkid (struct sctp_endpoint *ep,__u8 chunk_id); +int sctp_auth_ep_set_hmacs (struct sctp_endpoint *ep, +struct sctp_hmacalgo *hmacs); +int sctp_auth_set_key (struct sctp_endpoint *ep, +struct sctp_association *asoc, +struct sctp_authkey *auth_key); +int sctp_auth_set_active_key (struct sctp_endpoint *ep, +struct sctp_association *asoc, +__u16 key_id); +int sctp_auth_del_key_id (struct sctp_endpoint *ep, +struct sctp_association *asoc, +__u16 key_id); +#endif
include/net/sctp/ulpevent.h +4 -0
@@ -128,6 +128,10 @@ struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,struct sctp_chunk *chunk, gfp_t gfp); +struct sctp_ulpevent *sctp_ulpevent_make_authkey ( +const struct sctp_association *asoc,__u16 key_id, +__u32 indication,gfp_t gfp); +void sctp_ulpevent_read_sndrcvinfo (const struct sctp_ulpevent *event,struct msghdr *);__u16 sctp_ulpevent_get_notification_type (const struct sctp_ulpevent *event);
include/net/sctp/user.h +90 -0
126 lines not on this page · raw message
net/sctp/auth.c +193 -0
196 lines not on this page · raw message
net/sctp/sm_statefuns.c +13 -0
@@ -3776,6 +3776,19 @@ sctp_disposition_t sctp_sf_eat_auth(const struct sctp_endpoint *ep,break ; } +if (asoc->active_key_id !=ntohs (auth_hdr->shkey_id)) { +struct sctp_ulpevent *ev; + + ev =sctp_ulpevent_make_authkey (asoc,ntohs (auth_hdr->shkey_id), +SCTP_AUTH_NEWKEY ,GFP_ATOMIC ); + +if (!ev) +return -ENOMEM ; + +sctp_add_cmd_sf (commands,SCTP_CMD_EVENT_ULP , +SCTP_ULPEVENT (ev)); + } +return SCTP_DISPOSITION_CONSUME ; }
net/sctp/socket.c +304 -0
328 lines not on this page · raw message
net/sctp/ulpevent.c +37 -0
@@ -813,6 +813,43 @@ fail:return NULL ; } +struct sctp_ulpevent *sctp_ulpevent_make_authkey ( +const struct sctp_association *asoc,__u16 key_id, +__u32 indication,gfp_t gfp) +{ +struct sctp_ulpevent *event; +struct sctp_authkey_event *ak; +struct sk_buff *skb; + + event =sctp_ulpevent_new (sizeof (struct sctp_authkey_event ), +MSG_NOTIFICATION , gfp); +if (!event) + goto fail; + + skb =sctp_event2skb (event); + ak = (struct sctp_authkey_event *) +skb_put (skb,sizeof (struct sctp_authkey_event )); + + ak->auth_type =SCTP_AUTHENTICATION_EVENT ; + ak->auth_flags =0 ; + ak->auth_length =sizeof (struct sctp_authkey_event ); + + ak->auth_keynumber = key_id; + ak->auth_altkeynumber =0 ; + ak->auth_indication = indication; + +/* +* The association id field, holds the identifier for the association. +*/ +sctp_ulpevent_set_owner (event, asoc); + ak->auth_assoc_id =sctp_assoc2id (asoc); + +return event; +fail: +return NULL ; +} + +/* Return the notification type, assuming this is a notification * event. */
Signature · 1 line
1.5.2.4
Re: [PATCH 7/8] SCTP: API updates to suport SCTP-AUTH extensions.
From: Vlad Yasevich <[email protected]>
Date: Fri, 14 Sep 2007 14:44:58 -0400
Quoted 6 lines
Add SCTP-AUTH API. The API implemented here was agreed to between implementors at the 9th SCTP Interop. It will be documented in the next revision of the SCTP socket API spec.
Signed-off-by Vlad Yasevich <[email protected]>
Applied to net-2.6.24, thanks.
PATCH 8/8 SCTP: Tie ADD-IP and AUTH functionality as required by spec.
In reply to Vlad YasevichADD-IP spec requires AUTH. It is, in fact, dangerous without AUTH. So, disable ADD-IP functionality if the peer claims to support ADD-IP, but not AUTH.
--- include/net/sctp/structs.h | 1 + net/sctp/sm_make_chunk.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletions(-)
include/net/sctp/structs.h +1 -0
@@ -1537,6 +1537,7 @@ struct sctp_association {__u8 asconf_capable;/* Does peer support ADDIP? */ __u8 prsctp_capable;/* Can peer do PR-SCTP? */ __u8 auth_capable;/* Is peer doing SCTP-AUTH? */ +__u8 addip_capable;/* Can peer do ADD-IP *? __u32 adaptation_ind; /* Adaptation Code point. */
net/sctp/sm_make_chunk.c +12 -1
@@ -1851,7 +1851,8 @@ static void sctp_process_ext_param(struct sctp_association *asoc,break ;case SCTP_CID_ASCONF :case SCTP_CID_ASCONF_ACK : -/* don't need to do anything for ASCONF */ + asoc->peer.addip_capable =1 ; +break ;default :break ; }
@@ -2137,6 +2138,16 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid, !asoc->peer.peer_hmacs)) asoc->peer.auth_capable =0 ; + +/* If the peer claims support for ADD-IP without support +* for AUTH, disable support for ADD-IP. +*/ +if (asoc->peer.addip_capable && !asoc->peer.auth_capable) { + asoc->peer.addip_disable_mask |= (SCTP_PARAM_ADD_IP | +SCTP_PARAM_DEL_IP | +SCTP_PARAM_SET_PRIMARY ); + } +/* Walk list of transports, removing transports in the UNKNOWN state. */ list_for_each_safe (pos, temp, &asoc->peer.transport_addr_list) { transport = list_entry(pos, struct sctp_transport, transports);
Signature · 1 line
1.5.2.4
PATCH v2 8/8 SCTP: Tie ADD-IP and AUTH functionality as required by spec.
[.. forgot to refresh the patch, the other version has compile problems ..]
ADD-IP spec requires AUTH. It is, in fact, dangerous without AUTH. So, disable ADD-IP functionality if the peer claims to support ADD-IP, but not AUTH.
--- include/net/sctp/structs.h | 1 + net/sctp/sm_make_chunk.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletions(-)
include/net/sctp/structs.h +1 -0
@@ -1537,6 +1537,7 @@ struct sctp_association {__u8 asconf_capable;/* Does peer support ADDIP? */ __u8 prsctp_capable;/* Can peer do PR-SCTP? */ __u8 auth_capable;/* Is peer doing SCTP-AUTH? */ +__u8 addip_capable;/* Can peer do ADD-IP */ __u32 adaptation_ind;/* Adaptation Code point. */
net/sctp/sm_make_chunk.c +12 -1
@@ -1851,7 +1851,8 @@ static void sctp_process_ext_param(struct sctp_association *asoc,break ;case SCTP_CID_ASCONF :case SCTP_CID_ASCONF_ACK : -/* don't need to do anything for ASCONF */ + asoc->peer.addip_capable =1 ; +break ;default :break ; }
@@ -2137,6 +2138,16 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid, !asoc->peer.peer_hmacs)) asoc->peer.auth_capable =0 ; + +/* If the peer claims support for ADD-IP without support +* for AUTH, disable support for ADD-IP. +*/ +if (asoc->peer.addip_capable && !asoc->peer.auth_capable) { + asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP | +SCTP_PARAM_DEL_IP | +SCTP_PARAM_SET_PRIMARY ); + } +/* Walk list of transports, removing transports in the UNKNOWN state. */ list_for_each_safe (pos, temp, &asoc->peer.transport_addr_list) { transport = list_entry(pos, struct sctp_transport, transports);
Signature · 1 line
1.5.2.4
David Miller
maintainerRe: [v2 PATCH 8/8] SCTP: Tie ADD-IP and AUTH functionality as required by spec.
From: Vlad Yasevich <[email protected]>
Date: Fri, 14 Sep 2007 15:14:50 -0400
Quoted 7 lines
[.. forgot to refresh the patch, the other version has compile problems ..]
ADD-IP spec requires AUTH. It is, in fact, dangerous without AUTH. So, disable ADD-IP functionality if the peer claims to support ADD-IP, but not AUTH.
Signed-off-by Vlad Yasevich <[email protected]>
Aha, I caught this and applied the correct patch.
Re: [PATCH 8/8] SCTP: Tie ADD-IP and AUTH functionality as required by spec.
In reply to Vlad YasevichFrom: Vlad Yasevich <[email protected]>
Date: Fri, 14 Sep 2007 14:44:59 -0400
Quoted 5 lines
ADD-IP spec requires AUTH. It is, in fact, dangerous without AUTH. So, disable ADD-IP functionality if the peer claims to support ADD-IP, but not AUTH.
Signed-off-by Vlad Yasevich <[email protected]>
Applied to net-2.6.24, thanks.