]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ip: fib_rules: Fetch net from fib_rule in fib[46]_rule_configure().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Fri, 7 Feb 2025 07:24:58 +0000 (16:24 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jun 2025 12:40:15 +0000 (14:40 +0200)
[ Upstream commit 5a1ccffd30a08f5a2428cd5fbb3ab03e8eb6c66d ]

The following patch will not set skb->sk from VRF path.

Let's fetch net from fib_rule->fr_net instead of sock_net(skb->sk)
in fib[46]_rule_configure().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Tested-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20250207072502.87775-5-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/fib_rules.c
net/ipv6/fib6_rules.c

index 513f475c6a534e0fb406b93525476ac9c03f3bc8..298a9944a3d1e8b5601419f507d31e3b8c78c20c 100644 (file)
@@ -222,9 +222,9 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
                               struct nlattr **tb,
                               struct netlink_ext_ack *extack)
 {
-       struct net *net = sock_net(skb->sk);
+       struct fib4_rule *rule4 = (struct fib4_rule *)rule;
+       struct net *net = rule->fr_net;
        int err = -EINVAL;
-       struct fib4_rule *rule4 = (struct fib4_rule *) rule;
 
        if (!inet_validate_dscp(frh->tos)) {
                NL_SET_ERR_MSG(extack,
index 6eeab21512ba98721fbd54da2b3dfabdd7553862..e0f0c5f8cccdaaf74775f4fe023ae23e32e6357e 100644 (file)
@@ -350,9 +350,9 @@ static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
                               struct nlattr **tb,
                               struct netlink_ext_ack *extack)
 {
+       struct fib6_rule *rule6 = (struct fib6_rule *)rule;
+       struct net *net = rule->fr_net;
        int err = -EINVAL;
-       struct net *net = sock_net(skb->sk);
-       struct fib6_rule *rule6 = (struct fib6_rule *) rule;
 
        if (!inet_validate_dscp(frh->tos)) {
                NL_SET_ERR_MSG(extack,