Skip to contentSkip to conversation

ipv6: Disable IPv6 Destination Options RX processing by default

RFC In review Tom Herbert 2 participants 13 messages Nov 12, 2025 – Nov 24, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ipv6: Disable IPv6 Destination Options RX processing by default

Set IP6_DEFAULT_MAX_DST_OPTS_CNT to zero. This disables processing of Destinations Options extension headers by default. Processing can be enabled by setting the net.ipv6.max_dst_opts_number to a non-zero value.

The rationale for this is that Destination Options pose a serious risk of Denial off Service attack. The problem is that even if the default limit is set to a small number (previously it was eight) there is still the possibility of a DoS attack. All an attacker needs to do is create and MTU size packet filled with 8 bytes Destination Options Extension Headers. Each Destination EH simply contains a single padding option with six bytes of zeroes.

In a 1500 byte MTU size packet, 182 of these dummy Destination Options headers can be placed in a packet. Per RFC8200, a host must accept and process a packet with any number of Destination Options extension headers. So when the stack processes such a packet it is a lot of work and CPU cycles that provide zero benefit. The packet can be designed such that every byte after the IP header requires a conditional check and branch prediction can be rendered useless for that. This also may mean over twenty cache misses per packet. In other words, these packets filled with dummy Destination Options extension headers are the basis for what would be an effective DoS attack.

Disabling Destination Options is not a major issue for the following reasons:

* Linux kernel only supports one Destination Option (Home Address Option). There is no evidence this has seen any real world use
* On the Internet packets with Destination Options are dropped with a high enough rate such that use of Destination Options is not feasible
* It is unknown however quite possible that no one anywhere is using Destination Options for anything but experiments, class projects, or DoS. If someone is using them in their private network then it's easy enough to configure a non-zero limit for their use case

Tom Herbert (3):
ipv6: Check of max HBH or DestOp sysctl is zero and drop if it is
ipv6: Disable IPv6 Destination Options RX processing by default
ipv6: Document defauit of zero for max_dst_opts_number

 Documentation/networking/ip-sysctl.rst | 38 ++++++++++++++++++--------
 include/net/ipv6.h                     |  7 +++--
 net/ipv6/exthdrs.c                     |  6 ++--
 3 files changed, 36 insertions(+), 15 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

RFC 1/3 ipv6: Check of max HBH or DestOp sysctl is zero and drop if it is

In IPv6 destitaion options processing function check if net->ipv6.sysctl.max_dst_opts_cnt is zero up front. If is zero then drop the packet since Destination Options processing is disabled.

Similarly, in IPv6 hop-by-hop options processing function check if net->ipv6.sysctl.max_hbh_opts_cnt is zero up front. If is zero then drop the packet since Hop-by-Hop Options processing is disabled.

---
 net/ipv6/exthdrs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv6/exthdrs.c +4 -2
index a23eb8734e15..11ff3d4df129 100644
@@ -303,7 +303,8 @@ static int ipv6_destopt_rcv(struct sk_buff *skb)
 	struct net *net = dev_net(skb->dev);
 	int extlen;
 
-	if (!pskb_may_pull(skb, skb_transport_offset(skb) + 8) ||
+	if (!net->ipv6.sysctl.max_dst_opts_cnt ||
+	    !pskb_may_pull(skb, skb_transport_offset(skb) + 8) ||
 	    !pskb_may_pull(skb, (skb_transport_offset(skb) +
 				 ((skb_transport_header(skb)[1] + 1) << 3)))) {
 		__IP6_INC_STATS(dev_net(dst_dev(dst)), idev,
@@ -1040,7 +1041,8 @@ int ipv6_parse_hopopts(struct sk_buff *skb)
 	 * sizeof(struct ipv6hdr) by definition of
 	 * hop-by-hop options.
 	 */
-	if (!pskb_may_pull(skb, sizeof(struct ipv6hdr) + 8) ||
+	if (!net->ipv6.sysctl.max_hbh_opts_cnt ||
+	    !pskb_may_pull(skb, sizeof(struct ipv6hdr) + 8) ||
 	    !pskb_may_pull(skb, (sizeof(struct ipv6hdr) +
 				 ((skb_transport_header(skb)[1] + 1) << 3)))) {
 fail_and_free:
Signature · 1 line
2.43.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [RFC net-next 1/3] ipv6: Check of max HBH or DestOp sysctl is zero and drop if it is

Quoted 1 line · Tom Herbert

In IPv6 destitaion options processing function check if

s/destitaion/destination

Quoted 25 lines

net->ipv6.sysctl.max_dst_opts_cnt is zero up front. If is zero then drop the packet since Destination Options processing is disabled.

Similarly, in IPv6 hop-by-hop options processing function check if net->ipv6.sysctl.max_hbh_opts_cnt is zero up front. If is zero then drop the packet since Hop-by-Hop Options processing is disabled.

---
  net/ipv6/exthdrs.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv6/exthdrs.c +2 -1
index a23eb8734e15..11ff3d4df129 100644
@@ -303,7 +303,8 @@ static int ipv6_destopt_rcv(struct sk_buff *skb)
  	struct net *net = dev_net(skb->dev);
  	int extlen;
 
-	if (!pskb_may_pull(skb, skb_transport_offset(skb) + 8) ||
+	if (!net->ipv6.sysctl.max_dst_opts_cnt ||
+	    !pskb_may_pull(skb, skb_transport_offset(skb) + 8) ||
  	    !pskb_may_pull(skb, (skb_transport_offset(skb) +
  				 ((skb_transport_header(skb)[1] + 1) << 3)))) {
  		__IP6_INC_STATS(dev_net(dst_dev(dst)), idev,

net/ipv6/exthdrs.c int ipv6_parse_hopopts(struct sk_buff *skb) · line 1048

Quoted 9 lines
net/ipv6/exthdrs.c +2 -1
@@ -1040,7 +1041,8 @@ int ipv6_parse_hopopts(struct sk_buff *skb)
  	 * sizeof(struct ipv6hdr) by definition of
  	 * hop-by-hop options.
  	 */
-	if (!pskb_may_pull(skb, sizeof(struct ipv6hdr) + 8) ||
+	if (!net->ipv6.sysctl.max_hbh_opts_cnt ||
+	    !pskb_may_pull(skb, sizeof(struct ipv6hdr) + 8) ||
  	    !pskb_may_pull(skb, (sizeof(struct ipv6hdr) +
  				 ((skb_transport_header(skb)[1] + 1) << 3)))) {
  fail_and_free:

IMO, this patch is necessary, whether or not this series is applied at some point.

Despite being an RFC:

#3 lore raw

Re: [RFC net-next 1/3] ipv6: Check of max HBH or DestOp sysctl is zero and drop if it is

Quoted 35 lines · Justin Iurman
Quoted 1 line · Tom Herbert

In IPv6 destitaion options processing function check if

s/destitaion/destination

Quoted 29 lines

net->ipv6.sysctl.max_dst_opts_cnt is zero up front. If is zero then drop the packet since Destination Options processing is disabled.

Similarly, in IPv6 hop-by-hop options processing function check if net->ipv6.sysctl.max_hbh_opts_cnt is zero up front. If is zero then drop the packet since Hop-by-Hop Options processing is disabled.

---
  net/ipv6/exthdrs.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv6/exthdrs.c +2 -2
index a23eb8734e15..11ff3d4df129 100644
@@ -303,7 +303,8 @@ static int ipv6_destopt_rcv(struct sk_buff *skb)
      struct net *net = dev_net(skb->dev);
      int extlen;
 
-     if (!pskb_may_pull(skb, skb_transport_offset(skb) + 8) ||
+     if (!net->ipv6.sysctl.max_dst_opts_cnt ||
+         !pskb_may_pull(skb, skb_transport_offset(skb) + 8) ||
          !pskb_may_pull(skb, (skb_transport_offset(skb) +
                               ((skb_transport_header(skb)[1] + 1) << 3)))) {
              __IP6_INC_STATS(dev_net(dst_dev(dst)), idev,
@@ -1040,7 +1041,8 @@ int ipv6_parse_hopopts(struct sk_buff *skb)
       * sizeof(struct ipv6hdr) by definition of
       * hop-by-hop options.
       */
-     if (!pskb_may_pull(skb, sizeof(struct ipv6hdr) + 8) ||
Quoted 8 lines

net/ipv6/exthdrs.c int ipv6_parse_hopopts(struct sk_buff *skb) · line 1048

Quoted 5 lines
net/ipv6/exthdrs.c +2 -0
+     if (!net->ipv6.sysctl.max_hbh_opts_cnt ||
+         !pskb_may_pull(skb, sizeof(struct ipv6hdr) + 8) ||
          !pskb_may_pull(skb, (sizeof(struct ipv6hdr) +
                               ((skb_transport_header(skb)[1] + 1) << 3)))) {
  fail_and_free:

IMO, this patch is necessary, whether or not this series is applied at some point.

Agreed. Thanks!

Tom

Quoted 4 lines

Despite being an RFC:

#4 lore raw

RFC 2/3 ipv6: Disable IPv6 Destination Options RX processing by default

In reply to Tom Herbert

Set IP6_DEFAULT_MAX_HBH_OPTS_CNT to zero. This disables processing of Destinations Options extension headers by default. Processing can be enabled by setting the net.ipv6.max_dst_opts_number to a non-zero value.

The rationale for this is that Destination Options pose a serious risk of Denial off Service attack. The problem is that even if the default limit is set to a small number (previously it was eight) there is still the possibility of a DoS attack. All an attacker needs to do is create and MTU size packet filled with 8 bytes Destination Options Extension Headers. Each Destination EH simply contains a single padding option with six bytes of zeroes.

In a 1500 byte MTU size packet, 182 of these dummy Destination Options headers can be placed in a packet. Per RFC8200, a host must accept and process a packet with any number of Destination Options extension headers. So when the stack processes such a packet it is a lot of work and CPU cycles that provide zero benefit. The packet can be designed such that every byte after the IP header requires a conditional check and branch prediction can be rendered useless for that. This also may mean over twenty cache misses per packet. In other words, these packets filled with dummy Destination Options extension headers are the basis for what would be an effective DoS attack.

Disabling Destination Options is not a major issue for the following reasons:

* Linux kernel only supports one Destination Option (Home Address Option). There is no evidence this has seen any real world use
* On the Internet packets with Destination Options are dropped with a high enough rate such that use of Destination Options is not feasible
* It is unknown however quite possible that no one anywhere is using Destination Options for anything but experiments, class projects, or DoS. If someone is using them in their private network then it's easy enough to configure a non-zero limit for their use case

---
 include/net/ipv6.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
include/net/ipv6.h +5 -2
index 74fbf1ad8065..723a254c0b90 100644
@@ -86,8 +86,11 @@ struct ip_tunnel_info;
  * silently discarded.
  */
 
-/* Default limits for Hop-by-Hop and Destination options */
-#define IP6_DEFAULT_MAX_DST_OPTS_CNT	 8
+/* Default limits for Hop-by-Hop and Destination options. By default
+ * packets received with Destination Options headers are dropped to thwart
+ * Denial of Service attacks (see sysctl documention)
+ */
+#define IP6_DEFAULT_MAX_DST_OPTS_CNT	 0
 #define IP6_DEFAULT_MAX_HBH_OPTS_CNT	 8
 #define IP6_DEFAULT_MAX_DST_OPTS_LEN	 INT_MAX /* No limit */
 #define IP6_DEFAULT_MAX_HBH_OPTS_LEN	 INT_MAX /* No limit */
Signature · 1 line
2.43.0
#5 lore raw
Quoted 1 line · Tom Herbert

Set IP6_DEFAULT_MAX_HBH_OPTS_CNT to zero. This disables

s/IP6_DEFAULT_MAX_HBH_OPTS_CNT/IP6_DEFAULT_MAX_DST_OPTS_CNT

Quoted 12 lines

processing of Destinations Options extension headers by default. Processing can be enabled by setting the net.ipv6.max_dst_opts_number to a non-zero value.

The rationale for this is that Destination Options pose a serious risk of Denial off Service attack. The problem is that even if the default limit is set to a small number (previously it was eight) there is still the possibility of a DoS attack. All an attacker needs to do is create and MTU size packet filled with 8 bytes Destination Options Extension Headers. Each Destination EH simply contains a single padding option with six bytes of zeroes.

Quoted 11 lines

In a 1500 byte MTU size packet, 182 of these dummy Destination Options headers can be placed in a packet. Per RFC8200, a host must accept and process a packet with any number of Destination Options extension headers. So when the stack processes such a packet it is a lot of work and CPU cycles that provide zero benefit. The packet can be designed such that every byte after the IP header requires a conditional check and branch prediction can be rendered useless for that. This also may mean over twenty cache misses per packet. In other words, these packets filled with dummy Destination Options extension headers are the basis for what would be an effective DoS attack.

How about a new document to update RFC8200 Sec. 4.1.? Maybe we can get 6man consensus to enforce only one occurrence (vs. 2 for the Dest) for each extension header. Let alone the recommended order (without normative language), we could...

OLD:
Each extension header should occur at most once, except for the Destination Options header, which should occur at most twice (once before a Routing header and once before the upper-layer header).

NEW:
Each extension header MUST occur at most once, except for the Destination Options header, which MUST occur at most twice (once before a Routing header and once before the upper-layer header).

...and...

OLD:
IPv6 nodes must accept and attempt to process extension headers in any order and occurring any number of times in the same packet, except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only. Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

NEW:
IPv6 nodes must accept and attempt to process extension headers in any order in the same packet,
except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only. Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

Quoted 5 lines

Disabling Destination Options is not a major issue for the following reasons:

* Linux kernel only supports one Destination Option (Home Address Option). There is no evidence this has seen any real world use

IMO, this is precisely the one designed for such real world end-to-end use cases (e.g., PDM [RFC8250] and PDMv2 [draft-ietf-ippm-encrypted-pdmv2]).

Quoted 3 lines

* On the Internet packets with Destination Options are dropped with a high enough rate such that use of Destination Options is not feasible

I wouldn't say that a 10-20% drop is *that* bad (i.e., "not feasible") for sizes < 64 bytes. But anyway...

Quoted 16 lines

* It is unknown however quite possible that no one anywhere is using Destination Options for anything but experiments, class projects, or DoS. If someone is using them in their private network then it's easy enough to configure a non-zero limit for their use case

---
  include/net/ipv6.h | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
include/net/ipv6.h +0 -0
index 74fbf1ad8065..723a254c0b90 100644
@@ -86,8 +86,11 @@ struct ip_tunnel_info;
   * silently discarded.
   */
 

include/net/ipv6.h struct ip_tunnel_info; · line 96

Quoted 10 lines
include/net/ipv6.h +5 -2
-/* Default limits for Hop-by-Hop and Destination options */
-#define IP6_DEFAULT_MAX_DST_OPTS_CNT	 8
+/* Default limits for Hop-by-Hop and Destination options. By default
+ * packets received with Destination Options headers are dropped to thwart
+ * Denial of Service attacks (see sysctl documention)
+ */
+#define IP6_DEFAULT_MAX_DST_OPTS_CNT	 0
  #define IP6_DEFAULT_MAX_HBH_OPTS_CNT	 8
  #define IP6_DEFAULT_MAX_DST_OPTS_LEN	 INT_MAX /* No limit */
  #define IP6_DEFAULT_MAX_HBH_OPTS_LEN	 INT_MAX /* No limit */

I'd rather prefer to update RFC8200 and enforce a maximum of 2 occurrences for the Dest, and keep the default limit of 8 options.

Also, regardless of what we do here (and this remark also applies to the Hop-by-Hop), I think it's reasonable for a *host* to drop packets with a number of Hbh or Dest options that exceeds the configured limit. However, for a router (i.e., forwarding mode), I'd prefer to skip the EH chain rather than drop packets (for obvious reasons).

#6 lore raw
Quoted 30 lines · Justin Iurman
Quoted 1 line · Tom Herbert

Set IP6_DEFAULT_MAX_HBH_OPTS_CNT to zero. This disables

s/IP6_DEFAULT_MAX_HBH_OPTS_CNT/IP6_DEFAULT_MAX_DST_OPTS_CNT

Quoted 12 lines

processing of Destinations Options extension headers by default. Processing can be enabled by setting the net.ipv6.max_dst_opts_number to a non-zero value.

The rationale for this is that Destination Options pose a serious risk of Denial off Service attack. The problem is that even if the default limit is set to a small number (previously it was eight) there is still the possibility of a DoS attack. All an attacker needs to do is create and MTU size packet filled with 8 bytes Destination Options Extension Headers. Each Destination EH simply contains a single padding option with six bytes of zeroes.

Quoted 11 lines

In a 1500 byte MTU size packet, 182 of these dummy Destination Options headers can be placed in a packet. Per RFC8200, a host must accept and process a packet with any number of Destination Options extension headers. So when the stack processes such a packet it is a lot of work and CPU cycles that provide zero benefit. The packet can be designed such that every byte after the IP header requires a conditional check and branch prediction can be rendered useless for that. This also may mean over twenty cache misses per packet. In other words, these packets filled with dummy Destination Options extension headers are the basis for what would be an effective DoS attack.

Quoted 4 lines

How about a new document to update RFC8200 Sec. 4.1.? Maybe we can get 6man consensus to enforce only one occurrence (vs. 2 for the Dest) for each extension header. Let alone the recommended order (without normative language), we could...

Hi Justin,

It's a nice idea, but given the turnaround times for the IETF process it would take years. Also to implement that in the stack isn't particularly trivial. Avoiding the potential DoS attack is the higher priority problem IMO, and disabling DestOpts by default will have little impact since almost no one is using them..

Quoted 31 lines

OLD:
Each extension header should occur at most once, except for the Destination Options header, which should occur at most twice (once before a Routing header and once before the upper-layer header).

NEW:
Each extension header MUST occur at most once, except for the Destination Options header, which MUST occur at most twice (once before a Routing header and once before the upper-layer header).

...and...

OLD:
IPv6 nodes must accept and attempt to process extension headers in any order and occurring any number of times in the same packet, except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only. Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

NEW:
IPv6 nodes must accept and attempt to process extension headers in any order in the same packet,
except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only. Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

Quoted 8 lines
Quoted 5 lines

Disabling Destination Options is not a major issue for the following reasons:

* Linux kernel only supports one Destination Option (Home Address Option). There is no evidence this has seen any real world use

IMO, this is precisely the one designed for such real world end-to-end use cases (e.g., PDM [RFC8250] and PDMv2 [draft-ietf-ippm-encrypted-pdmv2]).

Sure, but where is the Linux implementation? Deployment?

Quoted 7 lines
Quoted 4 lines

* On the Internet packets with Destination Options are dropped with a high enough rate such that use of Destination Options is not feasible

I wouldn't say that a 10-20% drop is *that* bad (i.e., "not feasible") for sizes < 64 bytes. But anyway...

The drop rates for Destination Options vary by size of the extension header. AP NIC data shows that 32 bytes options have about a 30% drop rate, 64 byte options have about a 40% drop rate, but 128 byte options have over 80% drop rate. The drops are coming from routers and not hosts, Linux has no problem with different sizes. As you know from the 6man list discussions, I proposed a minimum level of support that routers must forward packets with up to 64 bytes of extension headers, but that draft was rejected because of concerns that it would ossify an already ossified protocol :-(. Even if a 40% drop rate isn't "that bad" the 80% drop rate of 128 bytes EH would seem to qualify as "bad". In any case, no one in IETF has offered an alternative plan to address the high loss rates and without a solution I believe it's fair to say that use of Destination Options is not feasible.

Quoted 31 lines
Quoted 17 lines

* It is unknown however quite possible that no one anywhere is using Destination Options for anything but experiments, class projects, or DoS. If someone is using them in their private network thenthatit it's easy enough to configure a non-zero limit for their use case

---
  include/net/ipv6.h | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
include/net/ipv6.h +0 -0
index 74fbf1ad8065..723a254c0b90 100644
@@ -86,8 +86,11 @@ struct ip_tunnel_info;
   * silently discarded.
   */
 

include/net/ipv6.h struct ip_tunnel_info; · line 96

Quoted 10 lines
include/net/ipv6.h +5 -2
-/* Default limits for Hop-by-Hop and Destination options */
-#define IP6_DEFAULT_MAX_DST_OPTS_CNT  8
+/* Default limits for Hop-by-Hop and Destination options. By default
+ * packets received with Destination Options headers are dropped to thwart
+ * Denial of Service attacks (see sysctl documention)
+ */
+#define IP6_DEFAULT_MAX_DST_OPTS_CNT  0
  #define IP6_DEFAULT_MAX_HBH_OPTS_CNT         8
  #define IP6_DEFAULT_MAX_DST_OPTS_LEN         INT_MAX /* No limit */
  #define IP6_DEFAULT_MAX_HBH_OPTS_LEN         INT_MAX /* No limit */

I'd rather prefer to update RFC8200 and enforce a maximum of 2 occurrences for the Dest, and keep the default limit of 8 options.

Quoted 5 lines

Also, regardless of what we do here (and this remark also applies to the Hop-by-Hop), I think it's reasonable for a *host* to drop packets with a number of Hbh or Dest options that exceeds the configured limit. However, for a router (i.e., forwarding mode), I'd prefer to skip the EH chain rather than drop packets (for obvious reasons).

I considered that, but there is a problem in that when we process HBH options we don't know if we're a host (i.e. the final destination) or a router (i.e. the packet will be forwarded). I would prefer to keep it simple and drop whenever a limit is exceeded. RFC9673 does allow a host to skip over HBH options, but IMO it's too risky to blindly accept a packet without verifying all the headers.

Tom

#7 lore raw
Quoted 31 lines · Tom Herbert
Quoted 30 lines · Justin Iurman
Quoted 1 line · Tom Herbert

Set IP6_DEFAULT_MAX_HBH_OPTS_CNT to zero. This disables

s/IP6_DEFAULT_MAX_HBH_OPTS_CNT/IP6_DEFAULT_MAX_DST_OPTS_CNT

Quoted 23 lines

processing of Destinations Options extension headers by default. Processing can be enabled by setting the net.ipv6.max_dst_opts_number to a non-zero value.

The rationale for this is that Destination Options pose a serious risk of Denial off Service attack. The problem is that even if the default limit is set to a small number (previously it was eight) there is still the possibility of a DoS attack. All an attacker needs to do is create and MTU size packet filled with 8 bytes Destination Options Extension Headers. Each Destination EH simply contains a single padding option with six bytes of zeroes.

In a 1500 byte MTU size packet, 182 of these dummy Destination Options headers can be placed in a packet. Per RFC8200, a host must accept and process a packet with any number of Destination Options extension headers. So when the stack processes such a packet it is a lot of work and CPU cycles that provide zero benefit. The packet can be designed such that every byte after the IP header requires a conditional check and branch prediction can be rendered useless for that. This also may mean over twenty cache misses per packet. In other words, these packets filled with dummy Destination Options extension headers are the basis for what would be an effective DoS attack.

Quoted 6 lines
Quoted 4 lines

How about a new document to update RFC8200 Sec. 4.1.? Maybe we can get 6man consensus to enforce only one occurrence (vs. 2 for the Dest) for each extension header. Let alone the recommended order (without normative language), we could...

Hi Justin,

Hi Tom,

Quoted 1 line

It's a nice idea, but given the turnaround times for the IETF process

Indeed, but I think we'll need that at some point. I'll craft something and send it to 6man to get feedback.

Quoted 1 line

it would take years. Also to implement that in the stack isn't

I don't think it would be difficult thanks to struct inet6_skb_parm that is stored in the control buffer of skb's. We already have some flags that are set, and offsets defined.

Quoted 3 lines

particularly trivial. Avoiding the potential DoS attack is the higher priority problem IMO, and disabling DestOpts by default will have little impact since almost no one is using them..

Agree, but both issues are linked. If we don't explicitly limit (funny, in this case, I'd be OK to use that term ;-) the number of Destination Options header to 2 (as it should be), then the attack surface increases.

Quoted 34 lines
Quoted 34 lines

OLD:
Each extension header should occur at most once, except for the Destination Options header, which should occur at most twice (once before a Routing header and once before the upper-layer header).

NEW:
Each extension header MUST occur at most once, except for the Destination Options header, which MUST occur at most twice (once before a Routing header and once before the upper-layer header).

...and...

OLD:
IPv6 nodes must accept and attempt to process extension headers in any order and occurring any number of times in the same packet, except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only. Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

NEW:
IPv6 nodes must accept and attempt to process extension headers in any order in the same packet,
except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only. Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

Quoted 3 lines

Disabling Destination Options is not a major issue for the following reasons:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

* Linux kernel only supports one Destination Option (Home Address Option). There is no evidence this has seen any real world use

IMO, this is precisely the one designed for such real world end-to-end use cases (e.g., PDM [RFC8250] and PDMv2 [draft-ietf-ippm-encrypted-pdmv2]).

Sure, but where is the Linux implementation? Deployment?

Maybe they'll send it upstream one day, who knows.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

* On the Internet packets with Destination Options are dropped with a high enough rate such that use of Destination Options is not feasible

I wouldn't say that a 10-20% drop is *that* bad (i.e., "not feasible") for sizes < 64 bytes. But anyway...

Quoted 13 lines

The drop rates for Destination Options vary by size of the extension header. AP NIC data shows that 32 bytes options have about a 30% drop rate, 64 byte options have about a 40% drop rate, but 128 byte options have over 80% drop rate. The drops are coming from routers and not hosts, Linux has no problem with different sizes. As you know from the 6man list discussions, I proposed a minimum level of support that routers must forward packets with up to 64 bytes of extension headers, but that draft was rejected because of concerns that it would ossify an already ossified protocol :-(. Even if a 40% drop rate isn't "that bad" the 80% drop rate of 128 bytes EH would seem to qualify as "bad". In any case, no one in IETF has offered an alternative plan to address the high loss rates and without a solution I believe it's fair to say that use of Destination Options is not feasible.

The difference with APNIC's measurements lies in the fact that they reach end-users located behind ISPs, where EHs are heavily filtered. So their measurements are worst case scenarios (not saying they are not representative, just that it's a different location in networks). This becomes "less" problematic (don't get me wrong, there are still EH filters) if you remain at the core/edge (e.g., cloud providers, etc).

Quoted 37 lines
Quoted 31 lines
Quoted 17 lines

* It is unknown however quite possible that no one anywhere is using Destination Options for anything but experiments, class projects, or DoS. If someone is using them in their private network thenthatit it's easy enough to configure a non-zero limit for their use case

---
   include/net/ipv6.h | 7 +++++--
   1 file changed, 5 insertions(+), 2 deletions(-)
include/net/ipv6.h +0 -0
index 74fbf1ad8065..723a254c0b90 100644
@@ -86,8 +86,11 @@ struct ip_tunnel_info;
    * silently discarded.
    */
 

include/net/ipv6.h struct ip_tunnel_info; · line 96

Quoted 10 lines
include/net/ipv6.h +5 -2
-/* Default limits for Hop-by-Hop and Destination options */
-#define IP6_DEFAULT_MAX_DST_OPTS_CNT  8
+/* Default limits for Hop-by-Hop and Destination options. By default
+ * packets received with Destination Options headers are dropped to thwart
+ * Denial of Service attacks (see sysctl documention)
+ */
+#define IP6_DEFAULT_MAX_DST_OPTS_CNT  0
   #define IP6_DEFAULT_MAX_HBH_OPTS_CNT         8
   #define IP6_DEFAULT_MAX_DST_OPTS_LEN         INT_MAX /* No limit */
   #define IP6_DEFAULT_MAX_HBH_OPTS_LEN         INT_MAX /* No limit */

I'd rather prefer to update RFC8200 and enforce a maximum of 2 occurrences for the Dest, and keep the default limit of 8 options.

Quoted 5 lines

Also, regardless of what we do here (and this remark also applies to the Hop-by-Hop), I think it's reasonable for a *host* to drop packets with a number of Hbh or Dest options that exceeds the configured limit. However, for a router (i.e., forwarding mode), I'd prefer to skip the EH chain rather than drop packets (for obvious reasons).

Quoted 3 lines

I considered that, but there is a problem in that when we process HBH options we don't know if we're a host (i.e. the final destination) or a router (i.e. the packet will be forwarded). I would prefer to keep

Correct. We may consider calling ip6_route_input() earlier (this is what IOAM does already), for example before calling ipv6_parse_hopopts() in ip6_rcv_core(), instead of doing it in ip6_rcv_finish_core(). Otherwise, we'd need to rely on ipv6_chk_addr_ret(). Maybe something like (not tested):

net/ipv6/exthdrs.c +26 -2
index a23eb8734e15..0351b7fc58ee 100644
@@ -119,6 +119,7 @@ static bool ip6_parse_tlv(bool hopbyhop,
 	const unsigned char *nh = skb_network_header(skb);
 	int off = skb_network_header_len(skb);
 	bool disallow_unknowns = false;
+	int ipv6_chk_addr_ret = -1;
 	int tlv_count = 0;
 	int padlen = 0;
 
@@ -166,8 +167,30 @@ static bool ip6_parse_tlv(bool hopbyhop,
 			}
 		} else {
 			tlv_count++;
-			if (tlv_count > max_count)
-				goto bad;
+			if (tlv_count > max_count) {
+				/* Drop a Destination Options header when its
+				 * number of options exceeds the configured
+				 * limit.
+				 */
+				if (!hopbyhop)
+					goto bad;
+
+				/* Drop a Hop-by-Hop Options header when its
+				 * number of options exceeds the configured
+				 * limit IF we're the destination. Otherwise,
+				 * just skip it.
+				 */
+				if (ipv6_chk_addr_ret == -1)
+					ipv6_chk_addr_ret = ipv6_chk_addr(
+							dev_net(skb->dev),
+							&ipv6_hdr(skb)->daddr,
+							skb->dev, 0);
+
+				if (ipv6_chk_addr_ret)
+					goto bad;
+
+				goto skip;
+			}
 
 			if (hopbyhop) {
 				switch (nh[off]) {
@@ -210,6 +233,7 @@ static bool ip6_parse_tlv(bool hopbyhop,
 					break;
 				}
 			}
+skip:
 			padlen = 0;
 		}
 		off += optlen;
Quoted 3 lines

it simple and drop whenever a limit is exceeded. RFC9673 does allow a host to skip over HBH options, but IMO it's too risky to blindly accept a packet without verifying all the headers.

For a host, I agree. But as a router, I really don't think we should drop packets if the limit is exceeded. In that case, we just don't care, we're routers, it's not our job to decide if we drop a packet because of EHs. Otherwise, we'd be doing the same as operators' policies and hardware limitation in transit ASs, and we'd be exacerbating the ossification.

Justin

Quoted 1 line

Tom

#8 lore raw
Quoted 213 lines · Justin Iurman
Quoted 31 lines · Tom Herbert
Quoted 30 lines · Justin Iurman
Quoted 1 line · Tom Herbert

Set IP6_DEFAULT_MAX_HBH_OPTS_CNT to zero. This disables

s/IP6_DEFAULT_MAX_HBH_OPTS_CNT/IP6_DEFAULT_MAX_DST_OPTS_CNT

Quoted 23 lines

processing of Destinations Options extension headers by default. Processing can be enabled by setting the net.ipv6.max_dst_opts_number to a non-zero value.

The rationale for this is that Destination Options pose a serious risk of Denial off Service attack. The problem is that even if the default limit is set to a small number (previously it was eight) there is still the possibility of a DoS attack. All an attacker needs to do is create and MTU size packet filled  with 8 bytes Destination Options Extension Headers. Each Destination EH simply contains a single padding option with six bytes of zeroes.

In a 1500 byte MTU size packet, 182 of these dummy Destination Options headers can be placed in a packet. Per RFC8200, a host must accept and process a packet with any number of Destination Options extension headers. So when the stack processes such a packet it is a lot of work and CPU cycles that provide zero benefit. The packet can be designed such that every byte after the IP header requires a conditional check and branch prediction can be rendered useless for that. This also may mean over twenty cache misses per packet. In other words, these packets filled with dummy Destination Options extension headers are the basis for what would be an effective DoS attack.

Quoted 6 lines
Quoted 4 lines

How about a new document to update RFC8200 Sec. 4.1.? Maybe we can get 6man consensus to enforce only one occurrence (vs. 2 for the Dest) for each extension header. Let alone the recommended order (without normative language), we could...

Hi Justin,

Hi Tom,

Quoted 1 line

It's a nice idea, but given the turnaround times for the IETF process

Indeed, but I think we'll need that at some point. I'll craft something and send it to 6man to get feedback.

Quoted 1 line

it would take years. Also to implement that in the stack isn't

I don't think it would be difficult thanks to struct inet6_skb_parm that is stored in the control buffer of skb's. We already have some flags that are set, and offsets defined.

Quoted 3 lines

particularly trivial. Avoiding the potential DoS attack is the higher priority problem IMO, and disabling DestOpts by default will have little impact since almost no one is using them..

Agree, but both issues are linked. If we don't explicitly limit (funny, in this case, I'd be OK to use that term ;-) the number of Destination Options header to 2 (as it should be), then the attack surface increases.

Quoted 34 lines
Quoted 34 lines

OLD:
     Each extension header should occur at most once, except for the Destination Options header, which should occur at most twice (once before a Routing header and once before the upper-layer header).

NEW:
     Each extension header MUST occur at most once, except for the Destination Options header, which MUST occur at most twice (once before a Routing header and once before the upper-layer header).

...and...

OLD:
     IPv6 nodes must accept and attempt to process extension headers in any order and occurring any number of times in the same packet, except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only.  Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

NEW:
     IPv6 nodes must accept and attempt to process extension headers in any order in the same packet,
     except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only.  Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

Quoted 3 lines

Disabling Destination Options is not a major issue for the following reasons:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

* Linux kernel only supports one Destination Option (Home Address Option). There is no evidence this has seen any real world use

IMO, this is precisely the one designed for such real world end-to-end use cases (e.g., PDM [RFC8250] and PDMv2 [draft-ietf-ippm-encrypted- pdmv2]).

Sure, but  where is the Linux implementation? Deployment?

Maybe they'll send it upstream one day, who knows.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

* On the Internet packets with Destination Options are dropped with a high enough rate such that use of Destination Options is not feasible

I wouldn't say that a 10-20% drop is *that* bad (i.e., "not feasible") for sizes < 64 bytes. But anyway...

Quoted 13 lines

The drop rates for Destination Options vary by size of the extension header. AP NIC data shows that 32 bytes options have about a 30% drop rate, 64 byte options have about a 40% drop rate, but 128 byte options have over 80% drop rate. The drops are coming from routers and not hosts, Linux has no problem with different sizes. As you know from the 6man list discussions, I proposed a minimum level of support that routers must forward packets with up to 64 bytes of extension headers, but that draft was rejected because of concerns that it would ossify an already ossified protocol :-(. Even if a 40% drop rate isn't "that bad" the 80% drop rate of 128 bytes EH would seem to qualify as "bad". In any case, no one in IETF has offered an alternative plan to address the high loss rates and without a solution I believe it's fair to say that use of Destination Options is not feasible.

The difference with APNIC's measurements lies in the fact that they reach end-users located behind ISPs, where EHs are heavily filtered. So their measurements are worst case scenarios (not saying they are not representative, just that it's a different location in networks). This becomes "less" problematic (don't get me wrong, there are still EH filters) if you remain at the core/edge (e.g., cloud providers, etc).

Quoted 38 lines
Quoted 32 lines
Quoted 21 lines

* It is unknown however quite possible that no one anywhere is using Destination Options for anything but experiments, class projects, or DoS. If someone is using them in their private network thenthatit it's easy enough to configure a non-zero limit for their use case
---
   include/net/ipv6.h | 7 +++++--

   1 file changed, 5 insertions(+), 2 deletions(-)
include/net/ipv6.h +2 -2
index 74fbf1ad8065..723a254c0b90 100644
@@ -86,8 +86,11 @@ struct ip_tunnel_info;
     * silently discarded.
     */
 
-/* Default limits for Hop-by-Hop and Destination options */
-#define IP6_DEFAULT_MAX_DST_OPTS_CNT  8
+/* Default limits for Hop-by-Hop and Destination options. By default
+ * packets received with Destination Options headers are dropped to 
Quoted 7 lines

thwart
+ * Denial of Service attacks (see sysctl documention)
+ */
+#define IP6_DEFAULT_MAX_DST_OPTS_CNT  0
   #define IP6_DEFAULT_MAX_HBH_OPTS_CNT         8
   #define IP6_DEFAULT_MAX_DST_OPTS_LEN         INT_MAX /* No limit */ #define IP6_DEFAULT_MAX_HBH_OPTS_LEN         INT_MAX /* No limit */

I'd rather prefer to update RFC8200 and enforce a maximum of 2 occurrences for the Dest, and keep the default limit of 8 options.

Quoted 5 lines

Also, regardless of what we do here (and this remark also applies to the Hop-by-Hop), I think it's reasonable for a *host* to drop packets with a number of Hbh or Dest options that exceeds the configured limit. However, for a router (i.e., forwarding mode), I'd prefer to skip the EH chain rather than drop packets (for obvious reasons).

Quoted 3 lines

I considered that, but there is a problem in that when we process HBH options we don't know if we're a host (i.e. the final destination) or a router (i.e. the packet will be forwarded). I would prefer to keep

Correct. We may consider calling ip6_route_input() earlier (this is what IOAM does already), for example before calling ipv6_parse_hopopts() in ip6_rcv_core(), instead of doing it in ip6_rcv_finish_core(). Otherwise, we'd need to rely on ipv6_chk_addr_ret(). Maybe something like (not tested):

net/ipv6/exthdrs.c +25 -2
index a23eb8734e15..0351b7fc58ee 100644
@@ -119,6 +119,7 @@ static bool ip6_parse_tlv(bool hopbyhop,
      const unsigned char *nh = skb_network_header(skb);
      int off = skb_network_header_len(skb);
      bool disallow_unknowns = false;
+    int ipv6_chk_addr_ret = -1;
      int tlv_count = 0;
      int padlen = 0;
 
@@ -166,8 +167,30 @@ static bool ip6_parse_tlv(bool hopbyhop,
              }
          } else {
              tlv_count++;
-            if (tlv_count > max_count)
-                goto bad;
+            if (tlv_count > max_count) {
+                /* Drop a Destination Options header when its
+                 * number of options exceeds the configured
+                 * limit.
+                 */
+                if (!hopbyhop)
+                    goto bad;
+
+                /* Drop a Hop-by-Hop Options header when its
+                 * number of options exceeds the configured
+                 * limit IF we're the destination. Otherwise,
+                 * just skip it.
+                 */
+                if (ipv6_chk_addr_ret == -1)
+                    ipv6_chk_addr_ret = ipv6_chk_addr(
+                            dev_net(skb->dev),
+                            &ipv6_hdr(skb)->daddr,
+                            skb->dev, 0);
+
+                if (ipv6_chk_addr_ret)
+                    goto bad;
+
+                goto skip;
+            }
 
              if (hopbyhop) {
                  switch (nh[off]) {

net/ipv6/exthdrs.c static bool ip6_parse_tlv(bool hopbyhop, · line 239

Quoted 7 lines
net/ipv6/exthdrs.c +1 -0
@@ -210,6 +233,7 @@ static bool ip6_parse_tlv(bool hopbyhop,
                      break;
                  }
              }
+skip:
              padlen = 0;
          }
          off += optlen;

Of course, this would also require an early check in patch #1 of this series (for a Hbh), in order to handle the case: limit==0.

Quoted 10 lines
Quoted 3 lines

it simple and drop whenever a limit is exceeded. RFC9673 does allow a host to skip over HBH options, but IMO it's too risky to blindly accept a packet without verifying all the headers.

For a host, I agree. But as a router, I really don't think we should drop packets if the limit is exceeded. In that case, we just don't care, we're routers, it's not our job to decide if we drop a packet because of EHs. Otherwise, we'd be doing the same as operators' policies and hardware limitation in transit ASs, and we'd be exacerbating the ossification.

Justin

Quoted 1 line

Tom

#9 lore raw
In reply to Justin Iurman
Quoted 44 lines · Justin Iurman
Quoted 31 lines · Tom Herbert
Quoted 30 lines · Justin Iurman
Quoted 1 line · Tom Herbert

Set IP6_DEFAULT_MAX_HBH_OPTS_CNT to zero. This disables

s/IP6_DEFAULT_MAX_HBH_OPTS_CNT/IP6_DEFAULT_MAX_DST_OPTS_CNT

Quoted 23 lines

processing of Destinations Options extension headers by default. Processing can be enabled by setting the net.ipv6.max_dst_opts_number to a non-zero value.

The rationale for this is that Destination Options pose a serious risk of Denial off Service attack. The problem is that even if the default limit is set to a small number (previously it was eight) there is still the possibility of a DoS attack. All an attacker needs to do is create and MTU size packet filled with 8 bytes Destination Options Extension Headers. Each Destination EH simply contains a single padding option with six bytes of zeroes.

In a 1500 byte MTU size packet, 182 of these dummy Destination Options headers can be placed in a packet. Per RFC8200, a host must accept and process a packet with any number of Destination Options extension headers. So when the stack processes such a packet it is a lot of work and CPU cycles that provide zero benefit. The packet can be designed such that every byte after the IP header requires a conditional check and branch prediction can be rendered useless for that. This also may mean over twenty cache misses per packet. In other words, these packets filled with dummy Destination Options extension headers are the basis for what would be an effective DoS attack.

Quoted 6 lines
Quoted 4 lines

How about a new document to update RFC8200 Sec. 4.1.? Maybe we can get 6man consensus to enforce only one occurrence (vs. 2 for the Dest) for each extension header. Let alone the recommended order (without normative language), we could...

Hi Justin,

Hi Tom,

Quoted 1 line

It's a nice idea, but given the turnaround times for the IETF process

Quoted 8 lines

Indeed, but I think we'll need that at some point. I'll craft something and send it to 6man to get feedback.

Quoted 1 line

it would take years. Also to implement that in the stack isn't

I don't think it would be difficult thanks to struct inet6_skb_parm that is stored in the control buffer of skb's. We already have some flags that are set, and offsets defined.

Justin,

A patch for that would be good regardless of whether you take it to IETF :-).

Quoted 8 lines
Quoted 4 lines

particularly trivial. Avoiding the potential DoS attack is the higher priority problem IMO, and disabling DestOpts by default will have little impact since almost no one is using them..

Agree, but both issues are linked. If we don't explicitly limit (funny, in this case, I'd be OK to use that term ;-) the number of Destination Options header to 2 (as it should be), then the attack surface increases.

Yes, but it doesn't eliminate the potential for attack.

Quoted 67 lines
Quoted 35 lines
Quoted 35 lines

OLD:
Each extension header should occur at most once, except for the Destination Options header, which should occur at most twice (once before a Routing header and once before the upper-layer header).

NEW:
Each extension header MUST occur at most once, except for the Destination Options header, which MUST occur at most twice (once before a Routing header and once before the upper-layer header).

...and...

OLD:
IPv6 nodes must accept and attempt to process extension headers in any order and occurring any number of times in the same packet, except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only. Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

NEW:
IPv6 nodes must accept and attempt to process extension headers in any order in the same packet,
except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only. Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

Quoted 3 lines

Disabling Destination Options is not a major issue for the following reasons:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

* Linux kernel only supports one Destination Option (Home Address Option). There is no evidence this has seen any real world use

IMO, this is precisely the one designed for such real world end-to-end use cases (e.g., PDM [RFC8250] and PDMv2 [draft-ietf-ippm-encrypted-pdmv2]).

Sure, but where is the Linux implementation? Deployment?

Maybe they'll send it upstream one day, who knows.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

* On the Internet packets with Destination Options are dropped with a high enough rate such that use of Destination Options is not feasible

I wouldn't say that a 10-20% drop is *that* bad (i.e., "not feasible") for sizes < 64 bytes. But anyway...

Quoted 13 lines

The drop rates for Destination Options vary by size of the extension header. AP NIC data shows that 32 bytes options have about a 30% drop rate, 64 byte options have about a 40% drop rate, but 128 byte options have over 80% drop rate. The drops are coming from routers and not hosts, Linux has no problem with different sizes. As you know from the 6man list discussions, I proposed a minimum level of support that routers must forward packets with up to 64 bytes of extension headers, but that draft was rejected because of concerns that it would ossify an already ossified protocol :-(. Even if a 40% drop rate isn't "that bad" the 80% drop rate of 128 bytes EH would seem to qualify as "bad". In any case, no one in IETF has offered an alternative plan to address the high loss rates and without a solution I believe it's fair to say that use of Destination Options is not feasible.

Quoted 7 lines

The difference with APNIC's measurements lies in the fact that they reach end-users located behind ISPs, where EHs are heavily filtered. So their measurements are worst case scenarios (not saying they are not representative, just that it's a different location in networks). This becomes "less" problematic (don't get me wrong, there are still EH filters) if you remain at the core/edge (e.g., cloud providers, etc).

That's exactly the point though. The vast majority of our users, i.e. billions of laptops and SmartPhones, live behind ISPs and packets sent to them with EH are commonly being filtered by ISPs. IMO we need to set the defaults for the benefit of _them_, not for the relative handful of nodes that remain at the core/edge. For the latter group if they really want to use extension headers they can easily configure their devices accordingly. As contrary as it is to the end-to-end principle, it may actually be a good thing that ISPs have been filtering all along since that saves hosts from DoS attacks involving EH, but it's time to close this security hole in Linux itself.

Also we need to be honest here. The whole idea of extension headers was ill conceived from the get go. Even if we didn't know any better in the first design of IPv6 thirty years ago, I really wished the problems would have been addressed when IPv6 was promoted to Standard. Destination Options are particularly problematic since they have no security to speak of. If someone wants to send end-to-end information wouldn't they wrap this in an encrypted transport layer, I mean why expose end-to-end information in plain text for all the world to see and muck with?

In the end, the most likely future of extension headers is that they will be relegated to use in limited domains. And that's fine, in a limited domain any issues of router compatibility can be managed and security can be enforced. But on the Internet, I don't believe we'll ever see EH used. And that's why I think we should disable Destination Options by default for the greater good of humanity! ;-)

Tom

Quoted 115 lines
Quoted 37 lines
Quoted 31 lines
Quoted 17 lines

* It is unknown however quite possible that no one anywhere is using Destination Options for anything but experiments, class projects, or DoS. If someone is using them in their private network thenthatit it's easy enough to configure a non-zero limit for their use case

---
   include/net/ipv6.h | 7 +++++--
   1 file changed, 5 insertions(+), 2 deletions(-)
include/net/ipv6.h +0 -0
index 74fbf1ad8065..723a254c0b90 100644
@@ -86,8 +86,11 @@ struct ip_tunnel_info;
    * silently discarded.
    */
 

include/net/ipv6.h struct ip_tunnel_info; · line 96

Quoted 10 lines
include/net/ipv6.h +5 -2
-/* Default limits for Hop-by-Hop and Destination options */
-#define IP6_DEFAULT_MAX_DST_OPTS_CNT  8
+/* Default limits for Hop-by-Hop and Destination options. By default
+ * packets received with Destination Options headers are dropped to thwart
+ * Denial of Service attacks (see sysctl documention)
+ */
+#define IP6_DEFAULT_MAX_DST_OPTS_CNT  0
   #define IP6_DEFAULT_MAX_HBH_OPTS_CNT         8
   #define IP6_DEFAULT_MAX_DST_OPTS_LEN         INT_MAX /* No limit */
   #define IP6_DEFAULT_MAX_HBH_OPTS_LEN         INT_MAX /* No limit */

I'd rather prefer to update RFC8200 and enforce a maximum of 2 occurrences for the Dest, and keep the default limit of 8 options.

Quoted 5 lines

Also, regardless of what we do here (and this remark also applies to the Hop-by-Hop), I think it's reasonable for a *host* to drop packets with a number of Hbh or Dest options that exceeds the configured limit. However, for a router (i.e., forwarding mode), I'd prefer to skip the EH chain rather than drop packets (for obvious reasons).

Quoted 3 lines

I considered that, but there is a problem in that when we process HBH options we don't know if we're a host (i.e. the final destination) or a router (i.e. the packet will be forwarded). I would prefer to keep

Correct. We may consider calling ip6_route_input() earlier (this is what IOAM does already), for example before calling ipv6_parse_hopopts() in ip6_rcv_core(), instead of doing it in ip6_rcv_finish_core(). Otherwise, we'd need to rely on ipv6_chk_addr_ret(). Maybe something like (not tested):

net/ipv6/exthdrs.c +26 -2
index a23eb8734e15..0351b7fc58ee 100644
@@ -119,6 +119,7 @@ static bool ip6_parse_tlv(bool hopbyhop,
        const unsigned char *nh = skb_network_header(skb);
        int off = skb_network_header_len(skb);
        bool disallow_unknowns = false;
+       int ipv6_chk_addr_ret = -1;
        int tlv_count = 0;
        int padlen = 0;
 
@@ -166,8 +167,30 @@ static bool ip6_parse_tlv(bool hopbyhop,
                        }
                } else {
                        tlv_count++;
-                       if (tlv_count > max_count)
-                               goto bad;
+                       if (tlv_count > max_count) {
+                               /* Drop a Destination Options header when its
+                                * number of options exceeds the configured
+                                * limit.
+                                */
+                               if (!hopbyhop)
+                                       goto bad;
+
+                               /* Drop a Hop-by-Hop Options header when its
+                                * number of options exceeds the configured
+                                * limit IF we're the destination. Otherwise,
+                                * just skip it.
+                                */
+                               if (ipv6_chk_addr_ret == -1)
+                                       ipv6_chk_addr_ret = ipv6_chk_addr(
+                                                       dev_net(skb->dev),
+                                                       &ipv6_hdr(skb)->daddr,
+                                                       skb->dev, 0);
+
+                               if (ipv6_chk_addr_ret)
+                                       goto bad;
+
+                               goto skip;
+                       }
 
                        if (hopbyhop) {
                                switch (nh[off]) {
@@ -210,6 +233,7 @@ static bool ip6_parse_tlv(bool hopbyhop,
                                        break;
                                }
                        }
+skip:
                        padlen = 0;
                }
                off += optlen;
Quoted 4 lines

it simple and drop whenever a limit is exceeded. RFC9673 does allow a host to skip over HBH options, but IMO it's too risky to blindly accept a packet without verifying all the headers.

For a host, I agree. But as a router, I really don't think we should drop packets if the limit is exceeded. In that case, we just don't care, we're routers, it's not our job to decide if we drop a packet because of EHs. Otherwise, we'd be doing the same as operators' policies and hardware limitation in transit ASs, and we'd be exacerbating the ossification.

Justin

Quoted 1 line

Tom

#10 lore raw
Quoted 50 lines · Tom Herbert
Quoted 49 lines · Justin Iurman
Quoted 31 lines · Tom Herbert
Quoted 30 lines · Justin Iurman
Quoted 1 line · Tom Herbert

Set IP6_DEFAULT_MAX_HBH_OPTS_CNT to zero. This disables

s/IP6_DEFAULT_MAX_HBH_OPTS_CNT/IP6_DEFAULT_MAX_DST_OPTS_CNT

Quoted 23 lines

processing of Destinations Options extension headers by default. Processing can be enabled by setting the net.ipv6.max_dst_opts_number to a non-zero value.

The rationale for this is that Destination Options pose a serious risk of Denial off Service attack. The problem is that even if the default limit is set to a small number (previously it was eight) there is still the possibility of a DoS attack. All an attacker needs to do is create and MTU size packet filled with 8 bytes Destination Options Extension Headers. Each Destination EH simply contains a single padding option with six bytes of zeroes.

In a 1500 byte MTU size packet, 182 of these dummy Destination Options headers can be placed in a packet. Per RFC8200, a host must accept and process a packet with any number of Destination Options extension headers. So when the stack processes such a packet it is a lot of work and CPU cycles that provide zero benefit. The packet can be designed such that every byte after the IP header requires a conditional check and branch prediction can be rendered useless for that. This also may mean over twenty cache misses per packet. In other words, these packets filled with dummy Destination Options extension headers are the basis for what would be an effective DoS attack.

Quoted 6 lines
Quoted 4 lines

How about a new document to update RFC8200 Sec. 4.1.? Maybe we can get 6man consensus to enforce only one occurrence (vs. 2 for the Dest) for each extension header. Let alone the recommended order (without normative language), we could...

Hi Justin,

Hi Tom,

Quoted 1 line

It's a nice idea, but given the turnaround times for the IETF process

Indeed, but I think we'll need that at some point. I'll craft something and send it to 6man to get feedback.

Quoted 1 line

it would take years. Also to implement that in the stack isn't

Quoted 7 lines
Quoted 3 lines

I don't think it would be difficult thanks to struct inet6_skb_parm that is stored in the control buffer of skb's. We already have some flags that are set, and offsets defined.

Justin,

A patch for that would be good regardless of whether you take it to IETF :-).

Hi Tom,

Of course, but at the same time, we'll probably want to remain compliant with RFC8200 :-)

Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

particularly trivial. Avoiding the potential DoS attack is the higher priority problem IMO, and disabling DestOpts by default will have little impact since almost no one is using them..

Agree, but both issues are linked. If we don't explicitly limit (funny, in this case, I'd be OK to use that term ;-) the number of Destination Options header to 2 (as it should be), then the attack surface increases.

Yes, but it doesn't eliminate the potential for attack.

I think we're in violent agreement. What I meant was that... well, that's already a step forward.

Quoted 75 lines
Quoted 67 lines
Quoted 35 lines
Quoted 35 lines

OLD:
Each extension header should occur at most once, except for the Destination Options header, which should occur at most twice (once before a Routing header and once before the upper-layer header).

NEW:
Each extension header MUST occur at most once, except for the Destination Options header, which MUST occur at most twice (once before a Routing header and once before the upper-layer header).

...and...

OLD:
IPv6 nodes must accept and attempt to process extension headers in any order and occurring any number of times in the same packet, except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only. Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

NEW:
IPv6 nodes must accept and attempt to process extension headers in any order in the same packet,
except for the Hop-by-Hop Options header, which is restricted to appear immediately after an IPv6 header only. Nonetheless, it is strongly advised that sources of IPv6 packets adhere to the above recommended order until and unless subsequent specifications revise that recommendation.

Quoted 3 lines

Disabling Destination Options is not a major issue for the following reasons:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

* Linux kernel only supports one Destination Option (Home Address Option). There is no evidence this has seen any real world use

IMO, this is precisely the one designed for such real world end-to-end use cases (e.g., PDM [RFC8250] and PDMv2 [draft-ietf-ippm-encrypted-pdmv2]).

Sure, but where is the Linux implementation? Deployment?

Maybe they'll send it upstream one day, who knows.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

* On the Internet packets with Destination Options are dropped with a high enough rate such that use of Destination Options is not feasible

I wouldn't say that a 10-20% drop is *that* bad (i.e., "not feasible") for sizes < 64 bytes. But anyway...

Quoted 13 lines

The drop rates for Destination Options vary by size of the extension header. AP NIC data shows that 32 bytes options have about a 30% drop rate, 64 byte options have about a 40% drop rate, but 128 byte options have over 80% drop rate. The drops are coming from routers and not hosts, Linux has no problem with different sizes. As you know from the 6man list discussions, I proposed a minimum level of support that routers must forward packets with up to 64 bytes of extension headers, but that draft was rejected because of concerns that it would ossify an already ossified protocol :-(. Even if a 40% drop rate isn't "that bad" the 80% drop rate of 128 bytes EH would seem to qualify as "bad". In any case, no one in IETF has offered an alternative plan to address the high loss rates and without a solution I believe it's fair to say that use of Destination Options is not feasible.

Quoted 7 lines

The difference with APNIC's measurements lies in the fact that they reach end-users located behind ISPs, where EHs are heavily filtered. So their measurements are worst case scenarios (not saying they are not representative, just that it's a different location in networks). This becomes "less" problematic (don't get me wrong, there are still EH filters) if you remain at the core/edge (e.g., cloud providers, etc).

Quoted 10 lines

That's exactly the point though. The vast majority of our users, i.e. billions of laptops and SmartPhones, live behind ISPs and packets sent to them with EH are commonly being filtered by ISPs. IMO we need to set the defaults for the benefit of _them_, not for the relative handful of nodes that remain at the core/edge. For the latter group if they really want to use extension headers they can easily configure their devices accordingly. As contrary as it is to the end-to-end principle, it may actually be a good thing that ISPs have been filtering all along since that saves hosts from DoS attacks involving EH, but it's time to close this security hole in Linux itself.

Again, we're in violent agreement here (although I'd push for a default limit of 1 option for both Hbh and Dest, just to align Dest with Hbh since it is needed for the latter and RAO). I think that an update to RFC8200 + a limit of 1 in rfc8504-bis (vs. 8 in RFC8504) would provide a good compromise regarding security and usability on hosts. I checked RFC9673 and it doesn't require any change.

Quoted 9 lines

Also we need to be honest here. The whole idea of extension headers was ill conceived from the get go. Even if we didn't know any better in the first design of IPv6 thirty years ago, I really wished the problems would have been addressed when IPv6 was promoted to Standard. Destination Options are particularly problematic since they have no security to speak of. If someone wants to send end-to-end information wouldn't they wrap this in an encrypted transport layer, I mean why expose end-to-end information in plain text for all the world to see and muck with?

Mostly agree. You could still use ESP+Dest, though. Also, we may have use cases in the future that do not require confidentiality (who knows?).

Quoted 4 lines

In the end, the most likely future of extension headers is that they will be relegated to use in limited domains. And that's fine, in a limited domain any issues of router compatibility can be managed and security can be enforced. But on the Internet, I don't believe we'll

That's exactly what I've been saying for months/years. Well, not for the Destination Options (which are IMO specifically designed for that), nor for ESP, which works very well (but we know why ;-). Oh, and the Fragment header too is supposed to work on the Internet, but we also know why it doesn't. Anyway...

Quoted 2 lines

ever see EH used. And that's why I think we should disable Destination Options by default for the greater good of humanity! ;-)

I don't think I'm quite ready to see Destination Options completely disabled by default on hosts :-( See above the proposed limit of 1 (but I totally understand why you want 0, though).

Justin

Quoted 117 lines

Tom

Quoted 115 lines
Quoted 37 lines
Quoted 31 lines
Quoted 17 lines

* It is unknown however quite possible that no one anywhere is using Destination Options for anything but experiments, class projects, or DoS. If someone is using them in their private network thenthatit it's easy enough to configure a non-zero limit for their use case

---
    include/net/ipv6.h | 7 +++++--
    1 file changed, 5 insertions(+), 2 deletions(-)
include/net/ipv6.h +0 -0
index 74fbf1ad8065..723a254c0b90 100644
@@ -86,8 +86,11 @@ struct ip_tunnel_info;
     * silently discarded.
     */
 

include/net/ipv6.h struct ip_tunnel_info; · line 96

Quoted 10 lines
include/net/ipv6.h +5 -2
-/* Default limits for Hop-by-Hop and Destination options */
-#define IP6_DEFAULT_MAX_DST_OPTS_CNT  8
+/* Default limits for Hop-by-Hop and Destination options. By default
+ * packets received with Destination Options headers are dropped to thwart
+ * Denial of Service attacks (see sysctl documention)
+ */
+#define IP6_DEFAULT_MAX_DST_OPTS_CNT  0
    #define IP6_DEFAULT_MAX_HBH_OPTS_CNT         8
    #define IP6_DEFAULT_MAX_DST_OPTS_LEN         INT_MAX /* No limit */
    #define IP6_DEFAULT_MAX_HBH_OPTS_LEN         INT_MAX /* No limit */

I'd rather prefer to update RFC8200 and enforce a maximum of 2 occurrences for the Dest, and keep the default limit of 8 options.

Quoted 5 lines

Also, regardless of what we do here (and this remark also applies to the Hop-by-Hop), I think it's reasonable for a *host* to drop packets with a number of Hbh or Dest options that exceeds the configured limit. However, for a router (i.e., forwarding mode), I'd prefer to skip the EH chain rather than drop packets (for obvious reasons).

Quoted 3 lines

I considered that, but there is a problem in that when we process HBH options we don't know if we're a host (i.e. the final destination) or a router (i.e. the packet will be forwarded). I would prefer to keep

Correct. We may consider calling ip6_route_input() earlier (this is what IOAM does already), for example before calling ipv6_parse_hopopts() in ip6_rcv_core(), instead of doing it in ip6_rcv_finish_core(). Otherwise, we'd need to rely on ipv6_chk_addr_ret(). Maybe something like (not tested):

net/ipv6/exthdrs.c +26 -2
index a23eb8734e15..0351b7fc58ee 100644
@@ -119,6 +119,7 @@ static bool ip6_parse_tlv(bool hopbyhop,
         const unsigned char *nh = skb_network_header(skb);
         int off = skb_network_header_len(skb);
         bool disallow_unknowns = false;
+       int ipv6_chk_addr_ret = -1;
         int tlv_count = 0;
         int padlen = 0;
 
@@ -166,8 +167,30 @@ static bool ip6_parse_tlv(bool hopbyhop,
                         }
                 } else {
                         tlv_count++;
-                       if (tlv_count > max_count)
-                               goto bad;
+                       if (tlv_count > max_count) {
+                               /* Drop a Destination Options header when its
+                                * number of options exceeds the configured
+                                * limit.
+                                */
+                               if (!hopbyhop)
+                                       goto bad;
+
+                               /* Drop a Hop-by-Hop Options header when its
+                                * number of options exceeds the configured
+                                * limit IF we're the destination. Otherwise,
+                                * just skip it.
+                                */
+                               if (ipv6_chk_addr_ret == -1)
+                                       ipv6_chk_addr_ret = ipv6_chk_addr(
+                                                       dev_net(skb->dev),
+                                                       &ipv6_hdr(skb)->daddr,
+                                                       skb->dev, 0);
+
+                               if (ipv6_chk_addr_ret)
+                                       goto bad;
+
+                               goto skip;
+                       }
 
                         if (hopbyhop) {
                                 switch (nh[off]) {
@@ -210,6 +233,7 @@ static bool ip6_parse_tlv(bool hopbyhop,
                                         break;
                                 }
                         }
+skip:
                         padlen = 0;
                 }
                 off += optlen;
Quoted 4 lines

it simple and drop whenever a limit is exceeded. RFC9673 does allow a host to skip over HBH options, but IMO it's too risky to blindly accept a packet without verifying all the headers.

For a host, I agree. But as a router, I really don't think we should drop packets if the limit is exceeded. In that case, we just don't care, we're routers, it's not our job to decide if we drop a packet because of EHs. Otherwise, we'd be doing the same as operators' policies and hardware limitation in transit ASs, and we'd be exacerbating the ossification.

Justin

Quoted 1 line

Tom

#11 lore raw

RFC 3/3 ipv6: Document defauit of zero for max_dst_opts_number

In reply to Tom Herbert

Add a note and rationalization for setting the default maximum number of Destination options to zero. This means by default Destination Options extension headers are not processed on receive and packets with Destination Options extension headers are dropped

---
 Documentation/networking/ip-sysctl.rst | 38 ++++++++++++++++++--------
 1 file changed, 27 insertions(+), 11 deletions(-)
Documentation/networking/ip-sysctl.rst +27 -11
index 7cd35bfd39e6..2acaad94c475 100644
@@ -2454,20 +2454,36 @@ mld_qrv - INTEGER
 	Minimum: 1 (as specified by RFC6636 4.5)
 
 max_dst_opts_number - INTEGER
-	Maximum number of non-padding TLVs allowed in a Destination
-	options extension header. If this value is less than zero
-	then unknown options are disallowed and the number of known
-	TLVs allowed is the absolute value of this number.
-
-	Default: 8
+        Maximum number of non-padding TLVs allowed in a Destination
+        options extension header. If this value is zero then receive
+        Destination Options processing is disabled in which case packets
+        with the Destination Options extension header are dropped. If
+        this value is less than zero then unknown options are disallowed
+        and the number of known TLVs allowed is the absolute value of
+        this number.
+
+        The default is zero which means the all received packets with
+        Destination Options extension header are dropped. The rationale is that
+        for the vast majority of hosts, Destination Options serve no purpose.
+        In the thirty years of IPv6 no broadly useful IPv6 Destination options
+        have been defined, they have no security or even checksum protection,
+        latest data shows the Destination have drop rates on the Internet
+        from ten percent to more than thirty percent (depending on the size of
+        the extension header). They also have the potential to be used as a
+        Denial of Service attack.
+
+        Default: 0
 
 max_hbh_opts_number - INTEGER
 	Maximum number of non-padding TLVs allowed in a Hop-by-Hop
-	options extension header. If this value is less than zero
-	then unknown options are disallowed and the number of known
-	TLVs allowed is the absolute value of this number.
-
-	Default: 8
+	options extension header. If this value is zero then receive
+        Hop-by-Hop Options processing is disabled in which case packets
+        with the Hop-by-Hop Options extension header are dropped.
+        If this value is less than zero then unknown options are disallowed
+        and the number of known TLVs allowed is the absolute value of this
+        number.
+
+        Default: 8
 
 max_dst_opts_length - INTEGER
 	Maximum length allowed for a Destination options extension
Signature · 1 line
2.43.0
#12 lore raw
In reply to Tom Herbert
Quoted 43 lines · Tom Herbert

Set IP6_DEFAULT_MAX_DST_OPTS_CNT to zero. This disables processing of Destinations Options extension headers by default. Processing can be enabled by setting the net.ipv6.max_dst_opts_number to a non-zero value.

The rationale for this is that Destination Options pose a serious risk of Denial off Service attack. The problem is that even if the default limit is set to a small number (previously it was eight) there is still the possibility of a DoS attack. All an attacker needs to do is create and MTU size packet filled with 8 bytes Destination Options Extension Headers. Each Destination EH simply contains a single padding option with six bytes of zeroes.

In a 1500 byte MTU size packet, 182 of these dummy Destination Options headers can be placed in a packet. Per RFC8200, a host must accept and process a packet with any number of Destination Options extension headers. So when the stack processes such a packet it is a lot of work and CPU cycles that provide zero benefit. The packet can be designed such that every byte after the IP header requires a conditional check and branch prediction can be rendered useless for that. This also may mean over twenty cache misses per packet. In other words, these packets filled with dummy Destination Options extension headers are the basis for what would be an effective DoS attack.

Disabling Destination Options is not a major issue for the following reasons:

* Linux kernel only supports one Destination Option (Home Address Option). There is no evidence this has seen any real world use
* On the Internet packets with Destination Options are dropped with a high enough rate such that use of Destination Options is not feasible
* It is unknown however quite possible that no one anywhere is using Destination Options for anything but experiments, class projects, or DoS. If someone is using them in their private network then it's easy enough to configure a non-zero limit for their use case

Tom Herbert (3):
ipv6: Check of max HBH or DestOp sysctl is zero and drop if it is
ipv6: Disable IPv6 Destination Options RX processing by default
ipv6: Document defauit of zero for max_dst_opts_number

Quoted 5 lines
  Documentation/networking/ip-sysctl.rst | 38 ++++++++++++++++++--------
  include/net/ipv6.h                     |  7 +++--
  net/ipv6/exthdrs.c                     |  6 ++--
  3 files changed, 36 insertions(+), 15 deletions(-)

Adding the two IETF 6man related threads ([1,2]) to bring context and to highlight what has been discussed so far.

[1]
https://mailarchive.ietf.org/arch/msg/ipv6/J_9vPNzyllNAudXwJdqdHwgzT8A/
[2]
https://mailarchive.ietf.org/arch/msg/ipv6/jMTQJz5bAVmLyBhtgh-pmJR3MMM/