Patch "mlxsw: spectrum_ipip: Fix memory leak when changing remote IPv6 address" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    mlxsw: spectrum_ipip: Fix memory leak when changing remote IPv6 address

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mlxsw-spectrum_ipip-fix-memory-leak-when-changing-re.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 7ccee51f6edb9e79bc794089909f638fcd7c5472
Author: Ido Schimmel <idosch@xxxxxxxxxx>
Date:   Fri Oct 25 16:26:28 2024 +0200

    mlxsw: spectrum_ipip: Fix memory leak when changing remote IPv6 address
    
    [ Upstream commit 12ae97c531fcd3bfd774d4dfeaeac23eafe24280 ]
    
    The device stores IPv6 addresses that are used for encapsulation in
    linear memory that is managed by the driver.
    
    Changing the remote address of an ip6gre net device never worked
    properly, but since cited commit the following reproducer [1] would
    result in a warning [2] and a memory leak [3]. The problem is that the
    new remote address is never added by the driver to its hash table (and
    therefore the device) and the old address is never removed from it.
    
    Fix by programming the new address when the configuration of the ip6gre
    net device changes and removing the old one. If the address did not
    change, then the above would result in increasing the reference count of
    the address and then decreasing it.
    
    [1]
     # ip link add name bla up type ip6gre local 2001:db8:1::1 remote 2001:db8:2::1 tos inherit ttl inherit
     # ip link set dev bla type ip6gre remote 2001:db8:3::1
     # ip link del dev bla
     # devlink dev reload pci/0000:01:00.0
    
    [2]
    WARNING: CPU: 0 PID: 1682 at drivers/net/ethernet/mellanox/mlxsw/spectrum.c:3002 mlxsw_sp_ipv6_addr_put+0x140/0x1d0
    Modules linked in:
    CPU: 0 UID: 0 PID: 1682 Comm: ip Not tainted 6.12.0-rc3-custom-g86b5b55bc835 #151
    Hardware name: Nvidia SN5600/VMOD0013, BIOS 5.13 05/31/2023
    RIP: 0010:mlxsw_sp_ipv6_addr_put+0x140/0x1d0
    [...]
    Call Trace:
     <TASK>
     mlxsw_sp_router_netdevice_event+0x55f/0x1240
     notifier_call_chain+0x5a/0xd0
     call_netdevice_notifiers_info+0x39/0x90
     unregister_netdevice_many_notify+0x63e/0x9d0
     rtnl_dellink+0x16b/0x3a0
     rtnetlink_rcv_msg+0x142/0x3f0
     netlink_rcv_skb+0x50/0x100
     netlink_unicast+0x242/0x390
     netlink_sendmsg+0x1de/0x420
     ____sys_sendmsg+0x2bd/0x320
     ___sys_sendmsg+0x9a/0xe0
     __sys_sendmsg+0x7a/0xd0
     do_syscall_64+0x9e/0x1a0
     entry_SYSCALL_64_after_hwframe+0x77/0x7f
    
    [3]
    unreferenced object 0xffff898081f597a0 (size 32):
      comm "ip", pid 1626, jiffies 4294719324
      hex dump (first 32 bytes):
        20 01 0d b8 00 02 00 00 00 00 00 00 00 00 00 01   ...............
        21 49 61 83 80 89 ff ff 00 00 00 00 01 00 00 00  !Ia.............
      backtrace (crc fd9be911):
        [<00000000df89c55d>] __kmalloc_cache_noprof+0x1da/0x260
        [<00000000ff2a1ddb>] mlxsw_sp_ipv6_addr_kvdl_index_get+0x281/0x340
        [<000000009ddd445d>] mlxsw_sp_router_netdevice_event+0x47b/0x1240
        [<00000000743e7757>] notifier_call_chain+0x5a/0xd0
        [<000000007c7b9e13>] call_netdevice_notifiers_info+0x39/0x90
        [<000000002509645d>] register_netdevice+0x5f7/0x7a0
        [<00000000c2e7d2a9>] ip6gre_newlink_common.isra.0+0x65/0x130
        [<0000000087cd6d8d>] ip6gre_newlink+0x72/0x120
        [<000000004df7c7cc>] rtnl_newlink+0x471/0xa20
        [<0000000057ed632a>] rtnetlink_rcv_msg+0x142/0x3f0
        [<0000000032e0d5b5>] netlink_rcv_skb+0x50/0x100
        [<00000000908bca63>] netlink_unicast+0x242/0x390
        [<00000000cdbe1c87>] netlink_sendmsg+0x1de/0x420
        [<0000000011db153e>] ____sys_sendmsg+0x2bd/0x320
        [<000000003b6d53eb>] ___sys_sendmsg+0x9a/0xe0
        [<00000000cae27c62>] __sys_sendmsg+0x7a/0xd0
    
    Fixes: cf42911523e0 ("mlxsw: spectrum_ipip: Use common hash table for IPv6 address mapping")
    Reported-by: Maksym Yaremchuk <maksymy@xxxxxxxxxx>
    Signed-off-by: Ido Schimmel <idosch@xxxxxxxxxx>
    Reviewed-by: Petr Machata <petrm@xxxxxxxxxx>
    Signed-off-by: Petr Machata <petrm@xxxxxxxxxx>
    Link: https://patch.msgid.link/e91012edc5a6cb9df37b78fd377f669381facfcb.1729866134.git.petrm@xxxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c
index 3340b4a694c3e..cbded3ed64505 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c
@@ -471,11 +471,33 @@ mlxsw_sp_ipip_ol_netdev_change_gre6(struct mlxsw_sp *mlxsw_sp,
 				    struct mlxsw_sp_ipip_entry *ipip_entry,
 				    struct netlink_ext_ack *extack)
 {
+	u32 new_kvdl_index, old_kvdl_index = ipip_entry->dip_kvdl_index;
+	struct in6_addr old_addr6 = ipip_entry->parms.daddr.addr6;
 	struct mlxsw_sp_ipip_parms new_parms;
+	int err;
 
 	new_parms = mlxsw_sp_ipip_netdev_parms_init_gre6(ipip_entry->ol_dev);
-	return mlxsw_sp_ipip_ol_netdev_change_gre(mlxsw_sp, ipip_entry,
-						  &new_parms, extack);
+
+	err = mlxsw_sp_ipv6_addr_kvdl_index_get(mlxsw_sp,
+						&new_parms.daddr.addr6,
+						&new_kvdl_index);
+	if (err)
+		return err;
+	ipip_entry->dip_kvdl_index = new_kvdl_index;
+
+	err = mlxsw_sp_ipip_ol_netdev_change_gre(mlxsw_sp, ipip_entry,
+						 &new_parms, extack);
+	if (err)
+		goto err_change_gre;
+
+	mlxsw_sp_ipv6_addr_put(mlxsw_sp, &old_addr6);
+
+	return 0;
+
+err_change_gre:
+	ipip_entry->dip_kvdl_index = old_kvdl_index;
+	mlxsw_sp_ipv6_addr_put(mlxsw_sp, &new_parms.daddr.addr6);
+	return err;
 }
 
 static int




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux