All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vlad Yasevich <vladislav.yasevich@hp.com>
To: linux-sctp@vger.kernel.org
Subject: Re: [PATCH] SCTP: Validate initiate tag and chunk type if verification
Date: Fri, 06 Jun 2008 14:52:02 +0000	[thread overview]
Message-ID: <48494F12.9020108@hp.com> (raw)
In-Reply-To: <4848E5FE.7080309@cn.fujitsu.com>

Wei Yongjun wrote:
> This patch add to validate initiate tag and chunk type if verification 
> tag is 0 when handling ICMP message.
> 
> RFC 4960, Appendix C. ICMP Handling
> 
> ICMP6) An implementation MUST validate that the Verification Tag 
> contained in the ICMP message matches the Verification Tag of the peer.  
> If the Verification Tag is not 0 and does NOT match, discard the ICMP 
> message.  If it is 0 and the ICMP message contains enough bytes to 
> verify that the chunk type is an INIT chunk and that the Initiate Tag 
> matches the tag of the peer, continue with ICMP7.  If the ICMP message 
> is too short or the chunk type or the Initiate Tag does not match, 
> silently discard the packet.
> 
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> 
> --- a/net/sctp/input.c    2008-05-31 23:49:24.000000000 -0400
> +++ b/net/sctp/input.c    2008-06-01 04:23:27.000000000 -0400
> @@ -430,6 +430,9 @@ struct sock *sctp_err_lookup(int family,
>     struct sock *sk = NULL;
>     struct sctp_association *asoc;
>     struct sctp_transport *transport = NULL;
> +    struct sctp_init_chunk *chunkhdr;
> +    __u32 vtag = ntohl(sctphdr->vtag);
> +    int len = skb->len - ((void *)sctphdr - (void *)skb->data);
> 
>     *app = NULL; *tpp = NULL;
> 
> @@ -451,7 +454,29 @@ struct sock *sctp_err_lookup(int family,
> 
>     sk = asoc->base.sk;
> 
> -    if (ntohl(sctphdr->vtag) != asoc->c.peer_vtag) {
> +    /* RFC 4960, Appendix C. ICMP Handling
> +     *
> +     * ICMP6) An implementation MUST validate that the Verification Tag
> +     * contained in the ICMP message matches the Verification Tag of
> +     * the peer.  If the Verification Tag is not 0 and does NOT
> +     * match, discard the ICMP message.  If it is 0 and the ICMP
> +     * message contains enough bytes to verify that the chunk type is
> +     * an INIT chunk and that the Initiate Tag matches the tag of the
> +     * peer, continue with ICMP7.  If the ICMP message is too short
> +     * or the chunk type or the Initiate Tag does not match, silently
> +     * discard the packet.
> +     */
> +    if (vtag = 0) {
> +        chunkhdr = (struct sctp_init_chunk *)((void *)sctphdr
> +                + sizeof(struct sctphdr));
> +        if (len < sizeof(struct sctphdr) + sizeof(sctp_chunkhdr_t)
> +              + sizeof(__be32)
> +            || chunkhdr->chunk_hdr.type != SCTP_CID_INIT
> +            || ntohl(chunkhdr->init_hdr.init_tag) != asoc->c.my_vtag) {

The logical operands usually go on the line above like this:

	if ( foo ||
              bar)

> +            ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);

This ICMP_INC_STAT_BH causes a double count, since when we return NULL out
of this function the parent sctp_v4_err() or sctp_v6_err() will count this
stat.

> +            goto out;
> +        }
> +    } else if (vtag != asoc->c.peer_vtag) {
>         ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);

Same here.  Latent bug.

-vlad

>         goto out;
>     }
> 
> 
> 
> -- 
> 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
> 


  parent reply	other threads:[~2008-06-06 14:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-06  7:23 [PATCH] SCTP: Validate initiate tag and chunk type if verification Wei Yongjun
2008-06-06 14:22 ` [PATCH] SCTP: Validate initiate tag and chunk type if Neil Horman
2008-06-06 14:31 ` [PATCH] SCTP: Validate initiate tag and chunk type if verification Vlad Yasevich
2008-06-06 14:36 ` [PATCH] SCTP: Validate initiate tag and chunk type if Neil Horman
2008-06-06 14:52 ` Vlad Yasevich [this message]
2008-06-10  1:12 ` [PATCH] SCTP: Validate initiate tag and chunk type if verification Wei Yongjun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48494F12.9020108@hp.com \
    --to=vladislav.yasevich@hp.com \
    --cc=linux-sctp@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.