Skip to contentSkip to conversation

net: fix fragments have the disallowed options

PATCH In review [email protected] 2 participants 4 messages Jan 7, 2022 – Jan 18, 2022

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

PATCH 1/1 net: fix fragments have the disallowed options

From: caixf <[email protected]>

When in function ip_do_fragment() enter fsat path, if skb have opthons, all fragments will have the same options.

Just guarantee the second fragment not have the disallowed options.

---
 net/ipv4/ip_output.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/ipv4/ip_output.c +4 -3
index 9bca57ef8b83..ce178b5eb848 100644
@@ -826,15 +826,16 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
 		/* Everything is OK. Generate! */
 		ip_fraglist_init(skb, iph, hlen, &iter);
 
-		if (iter.frag)
-			ip_options_fragment(iter.frag);
-
 		for (;;) {
 			/* Prepare header of the next frame,
 			 * before previous one went down. */
 			if (iter.frag) {
+				bool first_frag = (iter.offset == 0);
+
 				IPCB(iter.frag)->flags = IPCB(skb)->flags;
 				ip_fraglist_prepare(skb, &iter);
+				if (first_frag)
+					ip_options_fragment(iter.frag);
 			}
 
 			skb->tstamp = tstamp;
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 3 lines · On Fri, 7 Jan 2022 16:05:59 +0800 [email protected] wrote:

From: caixf <[email protected]>

When in function ip_do_fragment() enter fsat path,

fsat -> fast

Quoted 1 line

if skb have opthons, all fragments will have the same options.

opthons -> options

Quoted 1 line

Just guarantee the second fragment not have the disallowed options.

You're right. Can you send a patch which explicitly reverts these two commits instead:

1b9fbe813016b08e08b22ddba4ddbf9cb1b04b00
faf482ca196a5b16007190529b3b2dd32ab3f761

I prefer the code the way it was before them, plus keeping the code how it was could help backports.

Thanks!

maintainer
#2 lore raw
Quoted 13 lines · On Wed, 12 Jan 2022 10:43:24 -0800 Jakub Kicinski wrote:
Quoted 3 lines · On Fri, 7 Jan 2022 16:05:59 +0800 [email protected] wrote:

From: caixf <[email protected]>

When in function ip_do_fragment() enter fsat path,

fsat -> fast

Quoted 1 line

if skb have opthons, all fragments will have the same options.

opthons -> options

Quoted 1 line

Just guarantee the second fragment not have the disallowed options.

Quoted 8 lines

You're right. Can you send a patch which explicitly reverts these two commits instead:

1b9fbe813016b08e08b22ddba4ddbf9cb1b04b00
faf482ca196a5b16007190529b3b2dd32ab3f761

I prefer the code the way it was before them, plus keeping the code how it was could help backports.

Please let us know if you're planning to send the new patch otherwise I'll do the revert myself, it's a clear bug.