]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.6/ixgbe-avoid-sleeping-allocation-in-ixgbe_ipsec_vf_ad.patch
Linux 6.1.85
[thirdparty/kernel/stable-queue.git] / queue-6.6 / ixgbe-avoid-sleeping-allocation-in-ixgbe_ipsec_vf_ad.patch
1 From 25286375df818206a77c1444b54560bec25c6292 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Tue, 5 Mar 2024 17:02:02 +0100
4 Subject: ixgbe: avoid sleeping allocation in ixgbe_ipsec_vf_add_sa()
5
6 From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
7
8 [ Upstream commit aec806fb4afba5fe80b09e29351379a4292baa43 ]
9
10 Change kzalloc() flags used in ixgbe_ipsec_vf_add_sa() to GFP_ATOMIC, to
11 avoid sleeping in IRQ context.
12
13 Dan Carpenter, with the help of Smatch, has found following issue:
14 The patch eda0333ac293: "ixgbe: add VF IPsec management" from Aug 13,
15 2018 (linux-next), leads to the following Smatch static checker
16 warning: drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c:917 ixgbe_ipsec_vf_add_sa()
17 warn: sleeping in IRQ context
18
19 The call tree that Smatch is worried about is:
20 ixgbe_msix_other() <- IRQ handler
21 -> ixgbe_msg_task()
22 -> ixgbe_rcv_msg_from_vf()
23 -> ixgbe_ipsec_vf_add_sa()
24
25 Fixes: eda0333ac293 ("ixgbe: add VF IPsec management")
26 Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
27 Link: https://lore.kernel.org/intel-wired-lan/db31a0b0-4d9f-4e6b-aed8-88266eb5665c@moroto.mountain
28 Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
29 Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
30 Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
31 Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
32 Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
33 Signed-off-by: Sasha Levin <sashal@kernel.org>
34 ---
35 drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 16 ++++++++--------
36 1 file changed, 8 insertions(+), 8 deletions(-)
37
38 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
39 index 13a6fca31004a..866024f2b9eeb 100644
40 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
41 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
42 @@ -914,7 +914,13 @@ int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf)
43 goto err_out;
44 }
45
46 - xs = kzalloc(sizeof(*xs), GFP_KERNEL);
47 + algo = xfrm_aead_get_byname(aes_gcm_name, IXGBE_IPSEC_AUTH_BITS, 1);
48 + if (unlikely(!algo)) {
49 + err = -ENOENT;
50 + goto err_out;
51 + }
52 +
53 + xs = kzalloc(sizeof(*xs), GFP_ATOMIC);
54 if (unlikely(!xs)) {
55 err = -ENOMEM;
56 goto err_out;
57 @@ -930,14 +936,8 @@ int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf)
58 memcpy(&xs->id.daddr.a4, sam->addr, sizeof(xs->id.daddr.a4));
59 xs->xso.dev = adapter->netdev;
60
61 - algo = xfrm_aead_get_byname(aes_gcm_name, IXGBE_IPSEC_AUTH_BITS, 1);
62 - if (unlikely(!algo)) {
63 - err = -ENOENT;
64 - goto err_xs;
65 - }
66 -
67 aead_len = sizeof(*xs->aead) + IXGBE_IPSEC_KEY_BITS / 8;
68 - xs->aead = kzalloc(aead_len, GFP_KERNEL);
69 + xs->aead = kzalloc(aead_len, GFP_ATOMIC);
70 if (unlikely(!xs->aead)) {
71 err = -ENOMEM;
72 goto err_xs;
73 --
74 2.43.0
75