netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sctp: verify length provided in heartbeat information parameter
@ 2012-11-30 12:16 Thomas Graf
  2012-11-30 16:01 ` Neil Horman
  2012-11-30 17:34 ` Vlad Yasevich
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Graf @ 2012-11-30 12:16 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-sctp

If the variable parameter length provided in the mandatory
heartbeat information parameter exceeds the calculated payload
length the packet has been corrupted. Reply with a parameter
length protocol violation message.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
---
 net/sctp/sm_statefuns.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index b6adef8..e92079d 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -1055,6 +1055,7 @@ sctp_disposition_t sctp_sf_beat_8_3(struct net *net,
 				    void *arg,
 				    sctp_cmd_seq_t *commands)
 {
+	sctp_paramhdr_t *param_hdr;
 	struct sctp_chunk *chunk = arg;
 	struct sctp_chunk *reply;
 	size_t paylen = 0;
@@ -1072,12 +1073,17 @@ sctp_disposition_t sctp_sf_beat_8_3(struct net *net,
 	 * Information field copied from the received HEARTBEAT chunk.
 	 */
 	chunk->subh.hb_hdr = (sctp_heartbeathdr_t *) chunk->skb->data;
+	param_hdr = (sctp_paramhdr_t *) chunk->subh.hb_hdr;
 	paylen = ntohs(chunk->chunk_hdr->length) - sizeof(sctp_chunkhdr_t);
+
+	if (ntohs(param_hdr->length) > paylen)
+		return sctp_sf_violation_paramlen(net, ep, asoc, type, arg,
+						  param_hdr, commands);
+
 	if (!pskb_pull(chunk->skb, paylen))
 		goto nomem;
 
-	reply = sctp_make_heartbeat_ack(asoc, chunk,
-					chunk->subh.hb_hdr, paylen);
+	reply = sctp_make_heartbeat_ack(asoc, chunk, param_hdr, paylen);
 	if (!reply)
 		goto nomem;
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] sctp: verify length provided in heartbeat information parameter
  2012-11-30 12:16 [PATCH] sctp: verify length provided in heartbeat information parameter Thomas Graf
@ 2012-11-30 16:01 ` Neil Horman
  2012-11-30 17:26   ` David Miller
  2012-11-30 17:34 ` Vlad Yasevich
  1 sibling, 1 reply; 4+ messages in thread
From: Neil Horman @ 2012-11-30 16:01 UTC (permalink / raw)
  To: Thomas Graf; +Cc: davem, netdev, linux-sctp

On Fri, Nov 30, 2012 at 12:16:27PM +0000, Thomas Graf wrote:
> If the variable parameter length provided in the mandatory
> heartbeat information parameter exceeds the calculated payload
> length the packet has been corrupted. Reply with a parameter
> length protocol violation message.
> 
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
> ---
>  net/sctp/sm_statefuns.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> index b6adef8..e92079d 100644
> --- a/net/sctp/sm_statefuns.c
> +++ b/net/sctp/sm_statefuns.c
> @@ -1055,6 +1055,7 @@ sctp_disposition_t sctp_sf_beat_8_3(struct net *net,
>  				    void *arg,
>  				    sctp_cmd_seq_t *commands)
>  {
> +	sctp_paramhdr_t *param_hdr;
>  	struct sctp_chunk *chunk = arg;
>  	struct sctp_chunk *reply;
>  	size_t paylen = 0;
> @@ -1072,12 +1073,17 @@ sctp_disposition_t sctp_sf_beat_8_3(struct net *net,
>  	 * Information field copied from the received HEARTBEAT chunk.
>  	 */
>  	chunk->subh.hb_hdr = (sctp_heartbeathdr_t *) chunk->skb->data;
> +	param_hdr = (sctp_paramhdr_t *) chunk->subh.hb_hdr;
>  	paylen = ntohs(chunk->chunk_hdr->length) - sizeof(sctp_chunkhdr_t);
> +
> +	if (ntohs(param_hdr->length) > paylen)
> +		return sctp_sf_violation_paramlen(net, ep, asoc, type, arg,
> +						  param_hdr, commands);
> +
>  	if (!pskb_pull(chunk->skb, paylen))
>  		goto nomem;
>  
> -	reply = sctp_make_heartbeat_ack(asoc, chunk,
> -					chunk->subh.hb_hdr, paylen);
> +	reply = sctp_make_heartbeat_ack(asoc, chunk, param_hdr, paylen);
>  	if (!reply)
>  		goto nomem;
>  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
Looks good, thanks Thomas.
Acked-by: Neil Horman <nhorman@tuxdriver.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sctp: verify length provided in heartbeat information parameter
  2012-11-30 16:01 ` Neil Horman
@ 2012-11-30 17:26   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2012-11-30 17:26 UTC (permalink / raw)
  To: nhorman; +Cc: tgraf, netdev, linux-sctp

From: Neil Horman <nhorman@tuxdriver.com>
Date: Fri, 30 Nov 2012 11:01:57 -0500

> On Fri, Nov 30, 2012 at 12:16:27PM +0000, Thomas Graf wrote:
>> If the variable parameter length provided in the mandatory
>> heartbeat information parameter exceeds the calculated payload
>> length the packet has been corrupted. Reply with a parameter
>> length protocol violation message.
>> 
>> Signed-off-by: Thomas Graf <tgraf@suug.ch>
...
>> 
> Looks good, thanks Thomas.
> Acked-by: Neil Horman <nhorman@tuxdriver.com>
> 

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sctp: verify length provided in heartbeat information parameter
  2012-11-30 12:16 [PATCH] sctp: verify length provided in heartbeat information parameter Thomas Graf
  2012-11-30 16:01 ` Neil Horman
@ 2012-11-30 17:34 ` Vlad Yasevich
  1 sibling, 0 replies; 4+ messages in thread
From: Vlad Yasevich @ 2012-11-30 17:34 UTC (permalink / raw)
  To: Thomas Graf; +Cc: davem, netdev, linux-sctp

On 11/30/2012 07:16 AM, Thomas Graf wrote:
> If the variable parameter length provided in the mandatory
> heartbeat information parameter exceeds the calculated payload
> length the packet has been corrupted. Reply with a parameter
> length protocol violation message.
>
> Signed-off-by: Thomas Graf <tgraf@suug.ch>

Acked-by: Vlad Yasevich <vyasevich@gmail.com>

-vlad

> ---
>   net/sctp/sm_statefuns.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> index b6adef8..e92079d 100644
> --- a/net/sctp/sm_statefuns.c
> +++ b/net/sctp/sm_statefuns.c
> @@ -1055,6 +1055,7 @@ sctp_disposition_t sctp_sf_beat_8_3(struct net *net,
>   				    void *arg,
>   				    sctp_cmd_seq_t *commands)
>   {
> +	sctp_paramhdr_t *param_hdr;
>   	struct sctp_chunk *chunk = arg;
>   	struct sctp_chunk *reply;
>   	size_t paylen = 0;
> @@ -1072,12 +1073,17 @@ sctp_disposition_t sctp_sf_beat_8_3(struct net *net,
>   	 * Information field copied from the received HEARTBEAT chunk.
>   	 */
>   	chunk->subh.hb_hdr = (sctp_heartbeathdr_t *) chunk->skb->data;
> +	param_hdr = (sctp_paramhdr_t *) chunk->subh.hb_hdr;
>   	paylen = ntohs(chunk->chunk_hdr->length) - sizeof(sctp_chunkhdr_t);
> +
> +	if (ntohs(param_hdr->length) > paylen)
> +		return sctp_sf_violation_paramlen(net, ep, asoc, type, arg,
> +						  param_hdr, commands);
> +
>   	if (!pskb_pull(chunk->skb, paylen))
>   		goto nomem;
>
> -	reply = sctp_make_heartbeat_ack(asoc, chunk,
> -					chunk->subh.hb_hdr, paylen);
> +	reply = sctp_make_heartbeat_ack(asoc, chunk, param_hdr, paylen);
>   	if (!reply)
>   		goto nomem;
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-11-30 17:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-30 12:16 [PATCH] sctp: verify length provided in heartbeat information parameter Thomas Graf
2012-11-30 16:01 ` Neil Horman
2012-11-30 17:26   ` David Miller
2012-11-30 17:34 ` Vlad Yasevich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).