Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ixgbe: avoid sleeping allocation in ixgbe_ipsec_vf_add_sa()

Change kzalloc() flags used in ixgbe_ipsec_vf_add_sa() to GFP_ATOMIC, to
avoid sleeping in IRQ context.

Dan Carpenter, with the help of Smatch, has found following issue:
The patch eda0333ac293: "ixgbe: add VF IPsec management" from Aug 13,
2018 (linux-next), leads to the following Smatch static checker
warning: drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c:917 ixgbe_ipsec_vf_add_sa()
warn: sleeping in IRQ context

The call tree that Smatch is worried about is:
ixgbe_msix_other() <- IRQ handler
-> ixgbe_msg_task()
-> ixgbe_rcv_msg_from_vf()
-> ixgbe_ipsec_vf_add_sa()

Fixes: eda0333ac293 ("ixgbe: add VF IPsec management")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/intel-wired-lan/db31a0b0-4d9f-4e6b-aed8-88266eb5665c@moroto.mountain
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>

authored by

Przemek Kitszel and committed by
Tony Nguyen
aec806fb 1cb7fdb1

+8 -8
+8 -8
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
··· 914 914 goto err_out; 915 915 } 916 916 917 - xs = kzalloc(sizeof(*xs), GFP_KERNEL); 917 + algo = xfrm_aead_get_byname(aes_gcm_name, IXGBE_IPSEC_AUTH_BITS, 1); 918 + if (unlikely(!algo)) { 919 + err = -ENOENT; 920 + goto err_out; 921 + } 922 + 923 + xs = kzalloc(sizeof(*xs), GFP_ATOMIC); 918 924 if (unlikely(!xs)) { 919 925 err = -ENOMEM; 920 926 goto err_out; ··· 936 930 memcpy(&xs->id.daddr.a4, sam->addr, sizeof(xs->id.daddr.a4)); 937 931 xs->xso.dev = adapter->netdev; 938 932 939 - algo = xfrm_aead_get_byname(aes_gcm_name, IXGBE_IPSEC_AUTH_BITS, 1); 940 - if (unlikely(!algo)) { 941 - err = -ENOENT; 942 - goto err_xs; 943 - } 944 - 945 933 aead_len = sizeof(*xs->aead) + IXGBE_IPSEC_KEY_BITS / 8; 946 - xs->aead = kzalloc(aead_len, GFP_KERNEL); 934 + xs->aead = kzalloc(aead_len, GFP_ATOMIC); 947 935 if (unlikely(!xs->aead)) { 948 936 err = -ENOMEM; 949 937 goto err_xs;