mpls: Prevent use of implicit NULL label as outgoing label
authorRobert Shearman <rshearma@brocade.com>
Wed, 22 Apr 2015 10:14:39 +0000 (11:14 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Apr 2015 18:24:54 +0000 (14:24 -0400)
The reserved implicit-NULL label isn't allowed to appear in the label
stack for packets, so make it an error for the control plane to
specify it as an outgoing label.

Suggested-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Robert Shearman <rshearma@brocade.com>
Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mpls/af_mpls.c

index 9fdd94cba83e4949f51c3c96479f0937f6ec0333..954810c76a8650d87ec4bddc62fa5618e48c1341 100644 (file)
@@ -646,6 +646,15 @@ int nla_get_labels(const struct nlattr *nla,
                if ((dec.bos != bos) || dec.ttl || dec.tc)
                        return -EINVAL;
 
+               switch (dec.label) {
+               case LABEL_IMPLICIT_NULL:
+                       /* RFC3032: This is a label that an LSR may
+                        * assign and distribute, but which never
+                        * actually appears in the encapsulation.
+                        */
+                       return -EINVAL;
+               }
+
                label[i] = dec.label;
        }
        *labels = nla_labels;