All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/ipv4: swap flow ports when validating source
@ 2021-06-21 15:17 Wang Shanker
  2021-06-22  1:23 ` David Ahern
  0 siblings, 1 reply; 6+ messages in thread
From: Wang Shanker @ 2021-06-21 15:17 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern, Roopa Prabhu

When doing source address validation, the flowi4 struct used for
fib_lookup should be in the reverse direction to the given skb.
fl4_dport and fl4_sport returned by fib4_rules_early_flow_dissect
should thus be swapped.

Fixes: 5a847a6 ("net/ipv4: Initialize proto and ports in flow struct")
Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
---
 net/ipv4/fib_frontend.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 84bb707bd88d..647bceab56c2 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -371,6 +371,8 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
 		fl4.flowi4_proto = 0;
 		fl4.fl4_sport = 0;
 		fl4.fl4_dport = 0;
+	} else {
+		swap(fl4.fl4_sport, fl4.fl4_dport);
 	}
 
 	if (fib_lookup(net, &fl4, &res, 0))
-- 
2.20.1

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

* Re: [PATCH] net/ipv4: swap flow ports when validating source
  2021-06-21 15:17 [PATCH] net/ipv4: swap flow ports when validating source Wang Shanker
@ 2021-06-22  1:23 ` David Ahern
  2021-06-22  2:39   ` Miao Wang
  0 siblings, 1 reply; 6+ messages in thread
From: David Ahern @ 2021-06-22  1:23 UTC (permalink / raw)
  To: Wang Shanker, netdev; +Cc: Roopa Prabhu

On 6/21/21 9:17 AM, Wang Shanker wrote:
> When doing source address validation, the flowi4 struct used for
> fib_lookup should be in the reverse direction to the given skb.
> fl4_dport and fl4_sport returned by fib4_rules_early_flow_dissect
> should thus be swapped.
> 
> Fixes: 5a847a6 ("net/ipv4: Initialize proto and ports in flow struct")

I believe the hash should be 12 chars: 5a847a6e1477

> Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
> ---
>  net/ipv4/fib_frontend.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
> index 84bb707bd88d..647bceab56c2 100644
> --- a/net/ipv4/fib_frontend.c
> +++ b/net/ipv4/fib_frontend.c
> @@ -371,6 +371,8 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
>  		fl4.flowi4_proto = 0;
>  		fl4.fl4_sport = 0;
>  		fl4.fl4_dport = 0;
> +	} else {
> +		swap(fl4.fl4_sport, fl4.fl4_dport);
>  	}
>  
>  	if (fib_lookup(net, &fl4, &res, 0))
> 

Reviewed-by: David Ahern <dsahern@kernel.org>

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

* Re: [PATCH] net/ipv4: swap flow ports when validating source
  2021-06-22  1:23 ` David Ahern
@ 2021-06-22  2:39   ` Miao Wang
  2021-06-22  4:21     ` David Ahern
  0 siblings, 1 reply; 6+ messages in thread
From: Miao Wang @ 2021-06-22  2:39 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev, Roopa Prabhu


> 2021年06月22日 09:23,David Ahern <dsahern@gmail.com> 写道:
> 
> On 6/21/21 9:17 AM, Wang Shanker wrote:
>> When doing source address validation, the flowi4 struct used for
>> fib_lookup should be in the reverse direction to the given skb.
>> fl4_dport and fl4_sport returned by fib4_rules_early_flow_dissect
>> should thus be swapped.
>> 
>> Fixes: 5a847a6 ("net/ipv4: Initialize proto and ports in flow struct")
> 
> I believe the hash should be 12 chars: 5a847a6e1477
> 
>> Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
>> ---
>> net/ipv4/fib_frontend.c | 2 ++
>> 1 file changed, 2 insertions(+)
>> 
>> diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
>> index 84bb707bd88d..647bceab56c2 100644
>> --- a/net/ipv4/fib_frontend.c
>> +++ b/net/ipv4/fib_frontend.c
>> @@ -371,6 +371,8 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
>> 		fl4.flowi4_proto = 0;
>> 		fl4.fl4_sport = 0;
>> 		fl4.fl4_dport = 0;
>> +	} else {
>> +		swap(fl4.fl4_sport, fl4.fl4_dport);
>> 	}
>> 
>> 	if (fib_lookup(net, &fl4, &res, 0))
>> 
> 
> Reviewed-by: David Ahern <dsahern@kernel.org>

Thanks for your suggestion. I wonder if I also CC this to 
stable?


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

* Re: [PATCH] net/ipv4: swap flow ports when validating source
  2021-06-22  2:39   ` Miao Wang
@ 2021-06-22  4:21     ` David Ahern
  2021-06-22  4:24       ` [PATCH v2] " Miao Wang
  0 siblings, 1 reply; 6+ messages in thread
From: David Ahern @ 2021-06-22  4:21 UTC (permalink / raw)
  To: Miao Wang; +Cc: netdev, Roopa Prabhu

On 6/21/21 8:39 PM, Miao Wang wrote:
> Thanks for your suggestion. I wonder if I also CC this to 
> stable?

nope. Fixes tag will take care of that.

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

* [PATCH v2] net/ipv4: swap flow ports when validating source
  2021-06-22  4:21     ` David Ahern
@ 2021-06-22  4:24       ` Miao Wang
  2021-06-22 17:40         ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 6+ messages in thread
From: Miao Wang @ 2021-06-22  4:24 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev, Roopa Prabhu

When doing source address validation, the flowi4 struct used for
fib_lookup should be in the reverse direction to the given skb.
fl4_dport and fl4_sport returned by fib4_rules_early_flow_dissect
should thus be swapped.

Fixes: 5a847a6e1477 ("net/ipv4: Initialize proto and ports in flow struct")
Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
---
 net/ipv4/fib_frontend.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 84bb707bd88d..647bceab56c2 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -371,6 +371,8 @@ static int __fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst,
 		fl4.flowi4_proto = 0;
 		fl4.fl4_sport = 0;
 		fl4.fl4_dport = 0;
+	} else {
+		swap(fl4.fl4_sport, fl4.fl4_dport);
 	}
 
 	if (fib_lookup(net, &fl4, &res, 0))
-- 
2.20.1

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

* Re: [PATCH v2] net/ipv4: swap flow ports when validating source
  2021-06-22  4:24       ` [PATCH v2] " Miao Wang
@ 2021-06-22 17:40         ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-22 17:40 UTC (permalink / raw)
  To: Miao Wang; +Cc: dsahern, netdev, roopa

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Tue, 22 Jun 2021 12:24:50 +0800 you wrote:
> When doing source address validation, the flowi4 struct used for
> fib_lookup should be in the reverse direction to the given skb.
> fl4_dport and fl4_sport returned by fib4_rules_early_flow_dissect
> should thus be swapped.
> 
> Fixes: 5a847a6e1477 ("net/ipv4: Initialize proto and ports in flow struct")
> Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
> Reviewed-by: David Ahern <dsahern@kernel.org>
> 
> [...]

Here is the summary with links:
  - [v2] net/ipv4: swap flow ports when validating source
    https://git.kernel.org/netdev/net/c/c69f114d0989

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-06-22 17:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 15:17 [PATCH] net/ipv4: swap flow ports when validating source Wang Shanker
2021-06-22  1:23 ` David Ahern
2021-06-22  2:39   ` Miao Wang
2021-06-22  4:21     ` David Ahern
2021-06-22  4:24       ` [PATCH v2] " Miao Wang
2021-06-22 17:40         ` patchwork-bot+netdevbpf

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.