]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nfp: fix incorrect pointer deference when offloading IPsec with bonding
authorHuanhuan Wang <huanhuan.wang@corigine.com>
Thu, 20 Apr 2023 14:01:25 +0000 (16:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:11:34 +0000 (23:11 +0900)
commit 63cfd210034c772fad047afa13dd5a4664b0a72e upstream.

There are two pointers in struct xfrm_dev_offload, *dev, *real_dev.
The *dev points whether bonding interface or real interface, if
bonding IPsec offload is used, it points bonding interface; if not,
it points real interface. And *real_dev always points real interface.
So nfp should always use real_dev instead of dev.

Prior to this change the system becomes unresponsive when offloading
IPsec for a device which is a lower device to a bonding device.

Fixes: 859a497fe80c ("nfp: implement xfrm callbacks and expose ipsec offload feature to upper layer")
CC: stable@vger.kernel.org
Signed-off-by: Huanhuan Wang <huanhuan.wang@corigine.com>
Acked-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Louis Peens <louis.peens@corigine.com>
Link: https://lore.kernel.org/r/20230420140125.38521-1-louis.peens@corigine.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/netronome/nfp/crypto/ipsec.c

index 063cd371033a8824a5527db6caf06d35611d7ee0..b7cf18fcb946177a0e69f0524b7b7202d4f6242b 100644 (file)
@@ -267,7 +267,7 @@ static void set_sha2_512hmac(struct nfp_ipsec_cfg_add_sa *cfg, int *trunc_len)
 
 static int nfp_net_xfrm_add_state(struct xfrm_state *x)
 {
-       struct net_device *netdev = x->xso.dev;
+       struct net_device *netdev = x->xso.real_dev;
        struct nfp_ipsec_cfg_mssg msg = {};
        int i, key_len, trunc_len, err = 0;
        struct nfp_ipsec_cfg_add_sa *cfg;
@@ -503,7 +503,7 @@ static void nfp_net_xfrm_del_state(struct xfrm_state *x)
                .cmd = NFP_IPSEC_CFG_MSSG_INV_SA,
                .sa_idx = x->xso.offload_handle - 1,
        };
-       struct net_device *netdev = x->xso.dev;
+       struct net_device *netdev = x->xso.real_dev;
        struct nfp_net *nn;
        int err;