Commit Graph

168 Commits

Author SHA1 Message Date
Rado Vrbovsky 4804cf73cf Merge: CVE-2024-50261: macsec: Fix use-after-free while sending the offloading packet
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5752

JIRA: https://issues.redhat.com/browse/RHEL-66910
CVE: CVE-2024-50261

```
macsec: Fix use-after-free while sending the offloading packet

KASAN reports the following UAF. The metadata_dst, which is used to
store the SCI value for macsec offload, is already freed by
metadata_dst_free() in macsec_free_netdev(), while driver still use it
for sending the packet.

To fix this issue, dst_release() is used instead to release
metadata_dst. So it is not freed instantly in macsec_free_netdev() if
still referenced by skb.

 BUG: KASAN: slab-use-after-free in mlx5e_xmit+0x1e8f/0x4190 [mlx5_core]
 Read of size 2 at addr ffff88813e42e038 by task kworker/7:2/714
 [...]
 Workqueue: mld mld_ifc_work
 Call Trace:
  <TASK>
  dump_stack_lvl+0x51/0x60
  print_report+0xc1/0x600
  kasan_report+0xab/0xe0
  mlx5e_xmit+0x1e8f/0x4190 [mlx5_core]
  dev_hard_start_xmit+0x120/0x530
  sch_direct_xmit+0x149/0x11e0
  __qdisc_run+0x3ad/0x1730
  __dev_queue_xmit+0x1196/0x2ed0
  vlan_dev_hard_start_xmit+0x32e/0x510 [8021q]
  dev_hard_start_xmit+0x120/0x530
  __dev_queue_xmit+0x14a7/0x2ed0
  macsec_start_xmit+0x13e9/0x2340
  dev_hard_start_xmit+0x120/0x530
  __dev_queue_xmit+0x14a7/0x2ed0
  ip6_finish_output2+0x923/0x1a70
  ip6_finish_output+0x2d7/0x970
  ip6_output+0x1ce/0x3a0
  NF_HOOK.constprop.0+0x15f/0x190
  mld_sendpack+0x59a/0xbd0
  mld_ifc_work+0x48a/0xa80
  process_one_work+0x5aa/0xe50
  worker_thread+0x79c/0x1290
  kthread+0x28f/0x350
  ret_from_fork+0x2d/0x70
  ret_from_fork_asm+0x11/0x20
  </TASK>

 Allocated by task 3922:
  kasan_save_stack+0x20/0x40
  kasan_save_track+0x10/0x30
  __kasan_kmalloc+0x77/0x90
  __kmalloc_noprof+0x188/0x400
  metadata_dst_alloc+0x1f/0x4e0
  macsec_newlink+0x914/0x1410
  __rtnl_newlink+0xe08/0x15b0
  rtnl_newlink+0x5f/0x90
  rtnetlink_rcv_msg+0x667/0xa80
  netlink_rcv_skb+0x12c/0x360
  netlink_unicast+0x551/0x770
  netlink_sendmsg+0x72d/0xbd0
  __sock_sendmsg+0xc5/0x190
  ____sys_sendmsg+0x52e/0x6a0
  ___sys_sendmsg+0xeb/0x170
  __sys_sendmsg+0xb5/0x140
  do_syscall_64+0x4c/0x100
  entry_SYSCALL_64_after_hwframe+0x4b/0x53

 Freed by task 4011:
  kasan_save_stack+0x20/0x40
  kasan_save_track+0x10/0x30
  kasan_save_free_info+0x37/0x50
  poison_slab_object+0x10c/0x190
  __kasan_slab_free+0x11/0x30
  kfree+0xe0/0x290
  macsec_free_netdev+0x3f/0x140
  netdev_run_todo+0x450/0xc70
  rtnetlink_rcv_msg+0x66f/0xa80
  netlink_rcv_skb+0x12c/0x360
  netlink_unicast+0x551/0x770
  netlink_sendmsg+0x72d/0xbd0
  __sock_sendmsg+0xc5/0x190
  ____sys_sendmsg+0x52e/0x6a0
  ___sys_sendmsg+0xeb/0x170
  __sys_sendmsg+0xb5/0x140
  do_syscall_64+0x4c/0x100
  entry_SYSCALL_64_after_hwframe+0x4b/0x53

Fixes: 0a28bfd4971f ("net/macsec: Add MACsec skb_metadata_dst Tx Data path support")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Patrisious Haddad <phaddad@nvidia.com>
Reviewed-by: Chris Mi <cmi@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://patch.msgid.link/20241021100309.234125-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit f1e54d11b210b53d418ff1476c6b58a2f434dfc0)
```

Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>

---

<small>Created 2024-11-11 07:25 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://gitlab.com/cki-project/kernel-workflow/-/issues/new?issue%5Btitle%5D=backporter%20webhook%20issue)</small>

Approved-by: Antoine Tenart <atenart@redhat.com>
Approved-by: Hangbin Liu <haliu@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>

Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2024-12-12 13:55:10 +00:00
CKI Backport Bot 8b2925c64f macsec: Fix use-after-free while sending the offloading packet
JIRA: https://issues.redhat.com/browse/RHEL-66910
CVE: CVE-2024-50261

commit f1e54d11b210b53d418ff1476c6b58a2f434dfc0
Author: Jianbo Liu <jianbol@nvidia.com>
Date:   Mon Oct 21 13:03:09 2024 +0300

    macsec: Fix use-after-free while sending the offloading packet

    KASAN reports the following UAF. The metadata_dst, which is used to
    store the SCI value for macsec offload, is already freed by
    metadata_dst_free() in macsec_free_netdev(), while driver still use it
    for sending the packet.

    To fix this issue, dst_release() is used instead to release
    metadata_dst. So it is not freed instantly in macsec_free_netdev() if
    still referenced by skb.

     BUG: KASAN: slab-use-after-free in mlx5e_xmit+0x1e8f/0x4190 [mlx5_core]
     Read of size 2 at addr ffff88813e42e038 by task kworker/7:2/714
     [...]
     Workqueue: mld mld_ifc_work
     Call Trace:
      <TASK>
      dump_stack_lvl+0x51/0x60
      print_report+0xc1/0x600
      kasan_report+0xab/0xe0
      mlx5e_xmit+0x1e8f/0x4190 [mlx5_core]
      dev_hard_start_xmit+0x120/0x530
      sch_direct_xmit+0x149/0x11e0
      __qdisc_run+0x3ad/0x1730
      __dev_queue_xmit+0x1196/0x2ed0
      vlan_dev_hard_start_xmit+0x32e/0x510 [8021q]
      dev_hard_start_xmit+0x120/0x530
      __dev_queue_xmit+0x14a7/0x2ed0
      macsec_start_xmit+0x13e9/0x2340
      dev_hard_start_xmit+0x120/0x530
      __dev_queue_xmit+0x14a7/0x2ed0
      ip6_finish_output2+0x923/0x1a70
      ip6_finish_output+0x2d7/0x970
      ip6_output+0x1ce/0x3a0
      NF_HOOK.constprop.0+0x15f/0x190
      mld_sendpack+0x59a/0xbd0
      mld_ifc_work+0x48a/0xa80
      process_one_work+0x5aa/0xe50
      worker_thread+0x79c/0x1290
      kthread+0x28f/0x350
      ret_from_fork+0x2d/0x70
      ret_from_fork_asm+0x11/0x20
      </TASK>

     Allocated by task 3922:
      kasan_save_stack+0x20/0x40
      kasan_save_track+0x10/0x30
      __kasan_kmalloc+0x77/0x90
      __kmalloc_noprof+0x188/0x400
      metadata_dst_alloc+0x1f/0x4e0
      macsec_newlink+0x914/0x1410
      __rtnl_newlink+0xe08/0x15b0
      rtnl_newlink+0x5f/0x90
      rtnetlink_rcv_msg+0x667/0xa80
      netlink_rcv_skb+0x12c/0x360
      netlink_unicast+0x551/0x770
      netlink_sendmsg+0x72d/0xbd0
      __sock_sendmsg+0xc5/0x190
      ____sys_sendmsg+0x52e/0x6a0
      ___sys_sendmsg+0xeb/0x170
      __sys_sendmsg+0xb5/0x140
      do_syscall_64+0x4c/0x100
      entry_SYSCALL_64_after_hwframe+0x4b/0x53

     Freed by task 4011:
      kasan_save_stack+0x20/0x40
      kasan_save_track+0x10/0x30
      kasan_save_free_info+0x37/0x50
      poison_slab_object+0x10c/0x190
      __kasan_slab_free+0x11/0x30
      kfree+0xe0/0x290
      macsec_free_netdev+0x3f/0x140
      netdev_run_todo+0x450/0xc70
      rtnetlink_rcv_msg+0x66f/0xa80
      netlink_rcv_skb+0x12c/0x360
      netlink_unicast+0x551/0x770
      netlink_sendmsg+0x72d/0xbd0
      __sock_sendmsg+0xc5/0x190
      ____sys_sendmsg+0x52e/0x6a0
      ___sys_sendmsg+0xeb/0x170
      __sys_sendmsg+0xb5/0x140
      do_syscall_64+0x4c/0x100
      entry_SYSCALL_64_after_hwframe+0x4b/0x53

    Fixes: 0a28bfd4971f ("net/macsec: Add MACsec skb_metadata_dst Tx Data path support")
    Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
    Reviewed-by: Patrisious Haddad <phaddad@nvidia.com>
    Reviewed-by: Chris Mi <cmi@nvidia.com>
    Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
    Link: https://patch.msgid.link/20241021100309.234125-1-tariqt@nvidia.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
2024-11-11 07:25:30 +00:00
Ivan Vecera f183fb3c8a rtnetlink: prepare nla_put_iflink() to run under RCU
JIRA: https://issues.redhat.com/browse/RHEL-62123

Conflicts:
* drivers/net/netkit.c
  - hunk omitted as the driver is not present in RHEL
* net/dsa/user.c
  - the hunk applied in dsa/slave.c due to absence of DSA deps

commit e353ea9ce471331c13edffd5977eadd602d1bb80
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Feb 22 10:50:08 2024 +0000

    rtnetlink: prepare nla_put_iflink() to run under RCU

    We want to be able to run rtnl_fill_ifinfo() under RCU protection
    instead of RTNL in the future.

    This patch prepares dev_get_iflink() and nla_put_iflink()
    to run either with RTNL or RCU held.

    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-10-24 16:14:43 +02:00
Michal Schmidt 555cb3d84d netdev_features: convert NETIF_F_LLTX to dev->lltx
JIRA: https://issues.redhat.com/browse/RHEL-59091

commit 00d066a4d4edbe559ba6c35153da71d4b2b8a383
Author: Alexander Lobakin <aleksander.lobakin@intel.com>
Date:   Thu Aug 29 14:33:37 2024 +0200

    netdev_features: convert NETIF_F_LLTX to dev->lltx

    NETIF_F_LLTX can't be changed via Ethtool and is not a feature,
    rather an attribute, very similar to IFF_NO_QUEUE (and hot).
    Free one netdev_features_t bit and make it a "hot" private flag.

    Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Conflicts:
	drivers/net/macsec.c
	drivers/net/veth.c
	net/ipv6/ip6_tunnel.c
	- Context.

	drivers/net/amt.c
	drivers/net/netkit.c
	- Non-existent in RHEL 9.

	drivers/net/ethernet/chelsio/cxgb/cxgb2.c
	drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
	- Drivers disabled in RHEL 9. Skipped.

	net/dsa/user.c
	- This is slave.c in RHEL 9, but CONFIG_NET_DSA is disabled,
	  so skipped the hunk.

	net/core/net-sysfs.c
	- Code not present because of missing commit 74293ea1c4db
	  ("net: sysfs: Do not create sysfs for non BQL device")

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-03 17:59:44 +02:00
Lucas Zampieri a14ac2400e Merge: CNB95: net: annotate writes on dev->mtu from ndo_change_mtu()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4387

JIRA: https://issues.redhat.com/browse/RHEL-39583  
Tested: Just built... no way to test  

Commit(s):
```
1eb2cded45b3 ("net: annotate writes on dev->mtu from ndo_change_mtu()")
```

Signed-off-by: Ivan Vecera <ivecera@redhat.com>

Approved-by: Tony Camuso <tcamuso@redhat.com>
Approved-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Approved-by: Antoine Tenart <atenart@redhat.com>
Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>

Merged-by: Lucas Zampieri <lzampier@redhat.com>
2024-06-19 18:24:31 +00:00
Ivan Vecera 24ef7349da net: annotate writes on dev->mtu from ndo_change_mtu()
JIRA: https://issues.redhat.com/browse/RHEL-39583

Conflicts:
- hunks for non-existing files and non-applicable hunks for unsupported
  drivers, batman-adv and DSA were skipped

commit 1eb2cded45b35816085c1f962933c187d970f9dc
Author: Eric Dumazet <edumazet@google.com>
Date:   Mon May 6 10:28:12 2024 +0000

    net: annotate writes on dev->mtu from ndo_change_mtu()

    Simon reported that ndo_change_mtu() methods were never
    updated to use WRITE_ONCE(dev->mtu, new_mtu) as hinted
    in commit 501a90c945 ("inet: protect against too small
    mtu values.")

    We read dev->mtu without holding RTNL in many places,
    with READ_ONCE() annotations.

    It is time to take care of ndo_change_mtu() methods
    to use corresponding WRITE_ONCE()

    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Simon Horman <horms@kernel.org>
    Closes: https://lore.kernel.org/netdev/20240505144608.GB67882@kernel.org/
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Acked-by: Shannon Nelson <shannon.nelson@amd.com>
    Link: https://lore.kernel.org/r/20240506102812.3025432-1-edumazet@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-05-31 21:00:33 +02:00
Sabrina Dubroca d836453ded macsec: Detect if Rx skb is macsec-related for offloading devices that update md_dst
JIRA: https://issues.redhat.com/browse/RHEL-31748

commit 642c984dd0e37dbaec9f87bd1211e5fac1f142bf
Author: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Date:   Tue Apr 23 11:13:04 2024 -0700

    macsec: Detect if Rx skb is macsec-related for offloading devices that update md_dst

    Can now correctly identify where the packets should be delivered by using
    md_dst or its absence on devices that provide it.

    This detection is not possible without device drivers that update md_dst. A
    fallback pattern should be used for supporting such device drivers. This
    fallback mode causes multicast messages to be cloned to both the non-macsec
    and macsec ports, independent of whether the multicast message received was
    encrypted over MACsec or not. Other non-macsec traffic may also fail to be
    handled correctly for devices in promiscuous mode.

    Link: https://lore.kernel.org/netdev/ZULRxX9eIbFiVi7v@hog/
    Cc: Sabrina Dubroca <sd@queasysnail.net>
    Cc: stable@vger.kernel.org
    Fixes: 860ead89b851 ("net/macsec: Add MACsec skb_metadata_dst Rx Data path support")
    Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
    Reviewed-by: Benjamin Poirier <bpoirier@nvidia.com>
    Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
    Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
    Link: https://lore.kernel.org/r/20240423181319.115860-4-rrameshbabu@nvidia.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2024-05-03 15:41:43 +02:00
Sabrina Dubroca ee92a8b0e0 net: macsec: revert the MAC address if mdo_upd_secy fails
JIRA: https://issues.redhat.com/browse/RHEL-31748

commit 25a00d0cd691562f43a0a4b008214405e76d067f
Author: Radu Pirea (NXP OSS) <radu-nicolae.pirea@oss.nxp.com>
Date:   Tue Dec 19 16:53:29 2023 +0200

    net: macsec: revert the MAC address if mdo_upd_secy fails

    Revert the MAC address if mdo_upd_secy fails. Offloaded MACsec device
    might be left in an inconsistent state.

    Signed-off-by: Radu Pirea (NXP OSS) <radu-nicolae.pirea@oss.nxp.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2024-05-03 15:41:43 +02:00
Sabrina Dubroca f8cdd8426c net: add DEV_STATS_READ() helper
JIRA: https://issues.redhat.com/browse/RHEL-31748

Conflict: include a change that got dropped from ipvlan when
  backporting ff672b9ffeb3 because this patch was missing

commit 0b068c714ca9479d2783cc333fff5bc2d4a6d45c
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Sep 21 08:52:16 2023 +0000

    net: add DEV_STATS_READ() helper

    Companion of DEV_STATS_INC() & DEV_STATS_ADD().

    This is going to be used in the series.

    Use it in macsec_get_stats64().

    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2024-05-03 15:41:35 +02:00
Sabrina Dubroca ac57fe7bab net: macsec: Use helper functions to update stats
JIRA: https://issues.redhat.com/browse/RHEL-31748

commit bf98bbe985539ffb61898bd4d855df727b1a80c7
Author: Li Zetao <lizetao1@huawei.com>
Date:   Thu Aug 10 16:56:41 2023 +0800

    net: macsec: Use helper functions to update stats

    Use the helper functions dev_sw_netstats_rx_add() and
    dev_sw_netstats_tx_add() to update stats, which helps to
    provide code readability.

    Signed-off-by: Li Zetao <lizetao1@huawei.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2024-05-03 15:40:49 +02:00
Sabrina Dubroca 8816786ef9 macsec: use DEV_STATS_INC()
JIRA: https://issues.redhat.com/browse/RHEL-31748

commit 32d0a49d36a2a306c2e47fe5659361e424f0ed3f
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Aug 4 17:26:52 2023 +0000

    macsec: use DEV_STATS_INC()

    syzbot/KCSAN reported data-races in macsec whenever dev->stats fields
    are updated.

    It appears all of these updates can happen from multiple cpus.

    Adopt SMP safe DEV_STATS_INC() to update dev->stats fields.

    Fixes: c09440f7dc ("macsec: introduce IEEE 802.1AE driver")
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Cc: Sabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2024-05-03 15:40:49 +02:00
Sabrina Dubroca 6bc522e28b net: macsec: remove the prepare flag from the MACsec offloading context
JIRA: https://issues.redhat.com/browse/RHEL-31748

commit 99383f1298ee25901b1f6a665bdcc3344acb2382
Author: Antoine Tenart <atenart@kernel.org>
Date:   Wed Sep 21 15:51:18 2022 +0200

    net: macsec: remove the prepare flag from the MACsec offloading context

    Now that the MACsec offloading preparation phase was removed from the
    MACsec core implementation as well as from drivers implementing it, we
    can safely remove the flag representing it.

    Signed-off-by: Antoine Tenart <atenart@kernel.org>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2024-05-03 15:40:49 +02:00
Izabela Bakollari 6f221e8461 net: macsec: indicate next pn update when offloading
JIRA: https://issues.redhat.com/browse/RHEL-30143

Indicate next PN update using update_pn flag in macsec_context.
Offloaded MACsec implementations does not know whether or not the
MACSEC_SA_ATTR_PN attribute was passed for an SA update and assume
that next PN should always updated, but this is not always true.

The PN can be reset to its initial value using the following command:
$ ip macsec set macsec0 tx sa 0 off #octeontx2-pf case

Or, the update PN command will succeed even if the driver does not support
PN updates.
$ ip macsec set macsec0 tx sa 0 pn 1 on #mscc phy driver case

Comparing the initial PN with the new PN value is not a solution. When
the user updates the PN using its initial value the command will
succeed, even if the driver does not support it. Like this:
$ ip macsec add macsec0 tx sa 0 pn 1 on key 00 \
ead3664f508eb06c40ac7104cdae4ce5
$ ip macsec set macsec0 tx sa 0 pn 1 on #mlx5 case

Signed-off-by: Radu Pirea (NXP OSS) <radu-nicolae.pirea@oss.nxp.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 0412cc846a1ef38697c3f321f9b174da91ecd3b5)
Signed-off-by: Izabela Bakollari <ibakolla@redhat.com>
2024-04-02 09:37:31 +02:00
Ivan Vecera 286f55d20f macsec: add functions to get macsec real netdevice and check offload
JIRA: https://issues.redhat.com/browse/RHEL-22386

commit f132fdd9dc81e045bcf95005d418a31fbe9d942f
Author: Patrisious Haddad <phaddad@nvidia.com>
Date:   Mon May 2 14:40:56 2022 +0300

    macsec: add functions to get macsec real netdevice and check offload

    Given a macsec net_device add two functions to return the real net_device
    for that device, and check if that macsec device is offloaded or not.

    This is needed for auxiliary drivers that implement MACsec offload, but
    have flows which are triggered over the macsec net_device, this allows
    the drivers in such cases to verify if the device is offloaded or not,
    and to access the real device of that macsec device, which would
    belong to the driver, and would be needed for the offload procedure.

    Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
    Reviewed-by: Raed Salem <raeds@nvidia.com>
    Reviewed-by: Mark Zhang <markzhang@nvidia.com>
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-01-23 10:54:44 +01:00
Sabrina Dubroca c4e3a6324e macsec: Don't rely solely on the dst MAC address to identify destination MACsec device
JIRA: https://issues.redhat.com/browse/RHEL-14698
Tested: basic macsec tests

commit 7661351a54ec9a6a20203f94fd459a9360049045
Author: Emeel Hakim <ehakim@nvidia.com>
Date:   Wed Apr 19 17:21:26 2023 +0300

    macsec: Don't rely solely on the dst MAC address to identify destination MACsec device

    Offloading device drivers will mark offloaded MACsec SKBs with the
    corresponding SCI in the skb_metadata_dst so the macsec rx handler will
    know to which interface to divert those skbs, in case of a marked skb
    and a mismatch on the dst MAC address, divert the skb to the macsec
    net_device where the macsec rx_handler will be called to consider cases
    where relying solely on the dst MAC address is insufficient.

    One such instance is when using MACsec with a VLAN as an inner
    header, where the packet structure is ETHERNET | SECTAG | VLAN.
    In such a scenario, the dst MAC address in the ethernet header
    will correspond to the VLAN MAC address, resulting in a mismatch.

    Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
    Reviewed-by: Subbaraya Sundeep <sbhatta@marvell.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-10-25 22:44:07 +02:00
Sabrina Dubroca 14638c4f0d Revert "net: macsec: preserve ingress frame ordering"
JIRA: https://issues.redhat.com/browse/RHEL-2248
Upstream Status: d3287e4038ca in netdev/net
Tested: macsec stress test

commit d3287e4038ca4f81e02067ab72d087af7224c68b
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Mon Sep 4 10:56:04 2023 +0200

    Revert "net: macsec: preserve ingress frame ordering"

    This reverts commit ab046a5d4b.

    It was trying to work around an issue at the crypto layer by excluding
    ASYNC implementations of gcm(aes), because a bug in the AESNI version
    caused reordering when some requests bypassed the cryptd queue while
    older requests were still pending on the queue.

    This was fixed by commit 38b2f68b42 ("crypto: aesni - Fix cryptd
    reordering problem on gcm"), which pre-dates ab046a5d4b.

    Herbert Xu confirmed that all ASYNC implementations are expected to
    maintain the ordering of completions wrt requests, so we can use them
    in MACsec.

    On my test machine, this restores the performance of a single netperf
    instance, from 1.4Gbps to 4.4Gbps.

    Link: https://lore.kernel.org/netdev/9328d206c5d9f9239cae27e62e74de40b258471d.1692279161.git.sd@queasysnail.net/T/
    Link: https://lore.kernel.org/netdev/1b0cec71-d084-8153-2ba4-72ce71abeb65@byu.edu/
    Link: https://lore.kernel.org/netdev/d335ddaa-18dc-f9f0-17ee-9783d3b2ca29@mailbox.tu-dresden.de/
    Fixes: ab046a5d4b ("net: macsec: preserve ingress frame ordering")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Link: https://lore.kernel.org/r/11c952469d114db6fb29242e1d9545e61f52f512.1693757159.git.sd@queasysnail.net
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-09-05 16:08:34 +02:00
Sabrina Dubroca 7d2a21ca32 net: macsec: fix double free of percpu stats
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2218898
Tested: macsec tests

commit 0c0cf3db83f8c7c9bb141c2771a34043bcf952ef
Author: Fedor Pchelkin <pchelkin@ispras.ru>
Date:   Tue Jun 13 22:22:20 2023 +0300

    net: macsec: fix double free of percpu stats

    Inside macsec_add_dev() we free percpu macsec->secy.tx_sc.stats and
    macsec->stats on some of the memory allocation failure paths. However, the
    net_device is already registered to that moment: in macsec_newlink(), just
    before calling macsec_add_dev(). This means that during unregister process
    its priv_destructor - macsec_free_netdev() - will be called and will free
    the stats again.

    Remove freeing percpu stats inside macsec_add_dev() because
    macsec_free_netdev() will correctly free the already allocated ones. The
    pointers to unallocated stats stay NULL, and free_percpu() treats that
    correctly.

    Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

    Fixes: 0a28bfd4971f ("net/macsec: Add MACsec skb_metadata_dst Tx Data path support")
    Fixes: c09440f7dc ("macsec: introduce IEEE 802.1AE driver")
    Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
    Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-06-30 15:42:03 +02:00
Ivan Vecera 59591f9868 net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers).
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2193170

Conflicts:
- small context conflict around required change
- hunks for missing files were skipped
- several hunks for existing files were skipped as they are not
  applicable (missing get_stats callback etc.)
- hunks for aquantia, i40e, iavf, igb were skipped as they are already applied

commit 068c38ad88ccb09e5e966d4db5cedab0e02b3b95
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Oct 26 15:22:14 2022 +0200

    net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers).

    Now that the 32bit UP oddity is gone and 32bit uses always a sequence
    count, there is no need for the fetch_irq() variants anymore.

    Convert to the regular interface.

    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2023-06-08 13:37:52 +02:00
Ivan Vecera 41bf85273b net: adopt u64_stats_t in struct pcpu_sw_netstats
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2193170

commit 9962acefbcb92736c268aafe5f52200948f60f3e
Author: Eric Dumazet <edumazet@google.com>
Date:   Wed Jun 8 08:46:37 2022 -0700

    net: adopt u64_stats_t in struct pcpu_sw_netstats

    As explained in commit 316580b69d ("u64_stats: provide u64_stats_t type")
    we should use u64_stats_t and related accessors to avoid load/store tearing.

    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2023-06-08 13:37:00 +02:00
Jan Stancek 40b8580c4a Merge: CNB: net: rename reference+tracking helpers
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2231

Bugzilla: https://bugzilla.redhat.com/2175258
Tested: not needed, this is a function rename only

Depends: !2219

commit d62607c3fe45911b2331fac073355a8c914bbde2
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Tue Jun 7 21:39:55 2022 -0700

    net: rename reference+tracking helpers

    Netdev reference helpers have a dev_ prefix for historic
    reasons. Renaming the old helpers would be too much churn
    but we can rename the tracking ones which are relatively
    recent and should be the default for new code.

    Rename:
     dev_hold_track()    -> netdev_hold()
     dev_put_track()     -> netdev_put()
     dev_replace_track() -> netdev_ref_replace()

    Link: https://lore.kernel.org/r/20220608043955.919359-1-kuba@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>

Approved-by: Hangbin Liu <haliu@redhat.com>
Approved-by: Ivan Vecera <ivecera@redhat.com>

Signed-off-by: Jan Stancek <jstancek@redhat.com>
2023-04-06 14:03:53 +02:00
Jan Stancek dd1bb7040c Merge: macsec: rebase to upstream
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2198

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>

Approved-by: Antoine Tenart <atenart@redhat.com>
Approved-by: Corinna Vinschen <vinschen@redhat.com>

Signed-off-by: Jan Stancek <jstancek@redhat.com>
2023-04-06 14:03:53 +02:00
Jan Stancek f73d77d418 Merge: net: allow out-of-order netdev unregistration
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2219

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2180612
Tested: compile only

Patch 1-4 are the dependences commit c002496babfd ("Merge branch
'ipv6-loopback'") mentioned in Patch 7, and Patch 5 is a follow-up
for this dependence.

Patch 6-7 are the real fixes, and Patch 8-11 are the follow-ups
of them.

Note that I didn't backport commit 8a4fc54b07d7 ("net: get rid of
rtnl_lock_unregistering()"), as it's just a cleanup and depends on
commit ee403248fa6d ("net: remove default_device_exit()"), which is
from a big patchset. I will just leave it to the backport of
(struct pernet_operations)->exit() replacement for some devices.

Signed-off-by: Xin Long <lxin@redhat.com>

Approved-by: Florian Westphal <fwestpha@redhat.com>
Approved-by: Ivan Vecera <ivecera@redhat.com>

Signed-off-by: Jan Stancek <jstancek@redhat.com>
2023-04-04 11:53:01 +02:00
Íñigo Huguet 3a91b473a8 net: rename reference+tracking helpers
Bugzilla: https://bugzilla.redhat.com/2175258

Conflicts:
 - Removed chunks of unsupported protocol AX.25
 - Renamed the funtions also in ipvlan. Commit 40b9d1ab63f5 ("ipvlan: hold lower
   dev to avoid possible use-after-free") was backported out of order so it had
   to use the old functions names.

commit d62607c3fe45911b2331fac073355a8c914bbde2
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Tue Jun 7 21:39:55 2022 -0700

    net: rename reference+tracking helpers

    Netdev reference helpers have a dev_ prefix for historic
    reasons. Renaming the old helpers would be too much churn
    but we can rename the tracking ones which are relatively
    recent and should be the default for new code.

    Rename:
     dev_hold_track()    -> netdev_hold()
     dev_put_track()     -> netdev_put()
     dev_replace_track() -> netdev_ref_replace()

    Link: https://lore.kernel.org/r/20220608043955.919359-1-kuba@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2023-03-23 16:19:21 +01:00
Xin Long 667963a354 macsec: fix UAF bug for real_dev
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2180612
Tested: compile only

commit 196a888ca6571deb344468e1d7138e3273206335
Author: Ziyang Xuan <william.xuanziyang@huawei.com>
Date:   Tue May 31 15:45:00 2022 +0800

    macsec: fix UAF bug for real_dev

    Create a new macsec device but not get reference to real_dev. That can
    not ensure that real_dev is freed after macsec. That will trigger the
    UAF bug for real_dev as following:

    ==================================================================
    BUG: KASAN: use-after-free in macsec_get_iflink+0x5f/0x70 drivers/net/macsec.c:3662
    Call Trace:
     ...
     macsec_get_iflink+0x5f/0x70 drivers/net/macsec.c:3662
     dev_get_iflink+0x73/0xe0 net/core/dev.c:637
     default_operstate net/core/link_watch.c:42 [inline]
     rfc2863_policy+0x233/0x2d0 net/core/link_watch.c:54
     linkwatch_do_dev+0x2a/0x150 net/core/link_watch.c:161

    Allocated by task 22209:
     ...
     alloc_netdev_mqs+0x98/0x1100 net/core/dev.c:10549
     rtnl_create_link+0x9d7/0xc00 net/core/rtnetlink.c:3235
     veth_newlink+0x20e/0xa90 drivers/net/veth.c:1748

    Freed by task 8:
     ...
     kfree+0xd6/0x4d0 mm/slub.c:4552
     kvfree+0x42/0x50 mm/util.c:615
     device_release+0x9f/0x240 drivers/base/core.c:2229
     kobject_cleanup lib/kobject.c:673 [inline]
     kobject_release lib/kobject.c:704 [inline]
     kref_put include/linux/kref.h:65 [inline]
     kobject_put+0x1c8/0x540 lib/kobject.c:721
     netdev_run_todo+0x72e/0x10b0 net/core/dev.c:10327

    After commit faab39f63c1f ("net: allow out-of-order netdev unregistration")
    and commit e5f80fcf869a ("ipv6: give an IPv6 dev to blackhole_netdev"), we
    can add dev_hold_track() in macsec_dev_init() and dev_put_track() in
    macsec_free_netdev() to fix the problem.

    Fixes: 2bce1ebed1 ("macsec: fix refcnt leak in module exit routine")
    Reported-by: syzbot+d0e94b65ac259c29ce7a@syzkaller.appspotmail.com
    Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
    Link: https://lore.kernel.org/r/20220531074500.1272846-1-william.xuanziyang@huawei.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Signed-off-by: Xin Long <lxin@redhat.com>
2023-03-21 17:40:13 -04:00
Sabrina Dubroca 88ae961f25 macsec: dump IFLA_MACSEC_OFFLOAD attribute as part of macsec dump
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 723e8a48c9935b0d7a2826a12d03324daf6f900b
Author: Emeel Hakim <ehakim@nvidia.com>
Date:   Wed Jan 11 17:02:10 2023 +0200

    macsec: dump IFLA_MACSEC_OFFLOAD attribute as part of macsec dump

    Support dumping offload netlink attribute in macsec's device
    attributes dump.
    Change macsec_get_size to consider the offload attribute in
    the calculations of the required room for dumping the device
    netlink attributes.

    Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
    Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:30 +01:00
Sabrina Dubroca 93d9c51c3c macsec: add support for IFLA_MACSEC_OFFLOAD in macsec_changelink
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 15f1735520f929ea7ed7ef7902abe2ffe66486a6
Author: Emeel Hakim <ehakim@nvidia.com>
Date:   Wed Jan 11 17:02:09 2023 +0200

    macsec: add support for IFLA_MACSEC_OFFLOAD in macsec_changelink

    Add support for changing Macsec offload selection through the
    netlink layer by implementing the relevant changes in
    macsec_changelink.

    Since the handling in macsec_changelink is similar to macsec_upd_offload,
    update macsec_upd_offload to use a common helper function to avoid
    duplication.

    Example for setting offload for a macsec device:
        ip link set macsec0 type macsec offload mac

    Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
    Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:30 +01:00
Sabrina Dubroca 549e3f55fe net: macsec: fix net device access prior to holding a lock
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit f3b4a00f0f62da252c598310698dfc82ef2f2e2e
Author: Emeel Hakim <ehakim@nvidia.com>
Date:   Sun Dec 11 09:55:32 2022 +0200

    net: macsec: fix net device access prior to holding a lock

    Currently macsec offload selection update routine accesses
    the net device prior to holding the relevant lock.
    Fix by holding the lock prior to the device access.

    Fixes: dcb780fb27 ("net: macsec: add nla support for changing the offloading selection")
    Reviewed-by: Raed Salem <raeds@nvidia.com>
    Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
    Link: https://lore.kernel.org/r/20221211075532.28099-1-ehakim@nvidia.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:30 +01:00
Sabrina Dubroca 8e9cde5fbc macsec: add missing attribute validation for offload
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 38099024e51ee37dee5f0f577ca37175c932e3f7
Author: Emeel Hakim <ehakim@nvidia.com>
Date:   Wed Dec 7 12:16:18 2022 +0200

    macsec: add missing attribute validation for offload

    Add missing attribute validation for IFLA_MACSEC_OFFLOAD
    to the netlink policy.

    Fixes: 791bb3fcaf ("net: macsec: add support for specifying offload upon link creation")
    Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
    Link: https://lore.kernel.org/r/20221207101618.989-1-ehakim@nvidia.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:30 +01:00
Sabrina Dubroca 9e9e133728 macsec: Fix invalid error code set
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 7cef6b73fba96abef731a53501924fc3c4a0f947
Author: YueHaibing <yuehaibing@huawei.com>
Date:   Fri Nov 18 09:12:49 2022 +0800

    macsec: Fix invalid error code set

    'ret' is defined twice in macsec_changelink(), when it is set in macsec_is_offloaded
    case, it will be invalid before return.

    Fixes: 3cf3227a21 ("net: macsec: hardware offloading infrastructure")
    Signed-off-by: YueHaibing <yuehaibing@huawei.com>
    Reviewed-by: Saeed Mahameed <saeed@kernel.org>
    Reviewed-by: Antoine Tenart <atenart@kernel.org>
    Link: https://lore.kernel.org/r/20221118011249.48112-1-yuehaibing@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:30 +01:00
Sabrina Dubroca 6e6812594f macsec: clear encryption keys from the stack after setting up offload
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit aaab73f8fba4fd38f4d2617440d541a1c334e819
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Wed Nov 2 22:33:16 2022 +0100

    macsec: clear encryption keys from the stack after setting up offload

    macsec_add_rxsa and macsec_add_txsa copy the key to an on-stack
    offloading context to pass it to the drivers, but leaves it there when
    it's done. Clear it with memzero_explicit as soon as it's not needed
    anymore.

    Fixes: 3cf3227a21 ("net: macsec: hardware offloading infrastructure")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Reviewed-by: Antoine Tenart <atenart@kernel.org>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:29 +01:00
Sabrina Dubroca 4d5cd0712a macsec: fix detection of RXSCs when toggling offloading
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 80df4706357a5a06bbbc70273bf2611df1ceee04
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Wed Nov 2 22:33:15 2022 +0100

    macsec: fix detection of RXSCs when toggling offloading

    macsec_is_configured incorrectly uses secy->n_rx_sc to check if some
    RXSCs exist. secy->n_rx_sc only counts the number of active RXSCs, but
    there can also be inactive SCs as well, which may be stored in the
    driver (in case we're disabling offloading), or would have to be
    pushed to the device (in case we're trying to enable offloading).

    As long as RXSCs active on creation and never turned off, the issue is
    not visible.

    Fixes: dcb780fb27 ("net: macsec: add nla support for changing the offloading selection")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Reviewed-by: Antoine Tenart <atenart@kernel.org>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:29 +01:00
Sabrina Dubroca f8193e6433 macsec: fix secy->n_rx_sc accounting
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 73a4b31c9d11f98ae3bc5286d5382930adb0e9c7
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Wed Nov 2 22:33:14 2022 +0100

    macsec: fix secy->n_rx_sc accounting

    secy->n_rx_sc is supposed to be the number of _active_ rxsc's within a
    secy. This is then used by macsec_send_sci to help decide if we should
    add the SCI to the header or not.

    This logic is currently broken when we create a new RXSC and turn it
    off at creation, as create_rx_sc always sets ->active to true (and
    immediately uses that to increment n_rx_sc), and only later
    macsec_add_rxsc sets rx_sc->active.

    Fixes: c09440f7dc ("macsec: introduce IEEE 802.1AE driver")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Reviewed-by: Antoine Tenart <atenart@kernel.org>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:29 +01:00
Sabrina Dubroca 3481e487db macsec: delete new rxsc when offload fails
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 93a30947821c203d08865c4e17ea181c9668ce52
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Wed Nov 2 22:33:13 2022 +0100

    macsec: delete new rxsc when offload fails

    Currently we get an inconsistent state:
     - netlink returns the error to userspace
     - the RXSC is installed but not offloaded

    Then the device could get confused when we try to add an RXSA, because
    the RXSC isn't supposed to exist.

    Fixes: 3cf3227a21 ("net: macsec: hardware offloading infrastructure")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Reviewed-by: Antoine Tenart <atenart@kernel.org>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:29 +01:00
Sabrina Dubroca bde46184e4 Revert "net: macsec: report real_dev features when HW offloading is enabled"
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 8bcd560ae8784da57c610d857118c5d6576b1a8f
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Wed Nov 2 22:33:12 2022 +0100

    Revert "net: macsec: report real_dev features when HW offloading is enabled"

    This reverts commit c850240b6c.

    That commit tried to improve the performance of macsec offload by
    taking advantage of some of the NIC's features, but in doing so, broke
    macsec offload when the lower device supports both macsec and ipsec
    offload, as the ipsec offload feature flags (mainly NETIF_F_HW_ESP)
    were copied from the real device. Since the macsec device doesn't
    provide xdo_* ops, the XFRM core rejects the registration of the new
    macsec device in xfrm_api_check.

    Example perf trace when running
      ip link add link eni1np1 type macsec port 4 offload mac

        ip   737 [003]   795.477676: probe:xfrm_dev_event__REGISTER      name="macsec0" features=0x1c000080014869
                  xfrm_dev_event+0x3a
                  notifier_call_chain+0x47
                  register_netdevice+0x846
                  macsec_newlink+0x25a

        ip   737 [003]   795.477687:   probe:xfrm_dev_event__return      ret=0x8002 (NOTIFY_BAD)
                 notifier_call_chain+0x47
                 register_netdevice+0x846
                 macsec_newlink+0x25a

    dev->features includes NETIF_F_HW_ESP (0x04000000000000), so
    xfrm_api_check returns NOTIFY_BAD because we don't have
    dev->xfrmdev_ops on the macsec device.

    We could probably propagate GSO and a few other features from the
    lower device, similar to macvlan. This will be done in a future patch.

    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Reviewed-by: Antoine Tenart <atenart@kernel.org>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:29 +01:00
Sabrina Dubroca 53ac4a1f24 macsec: don't free NULL metadata_dst
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit c52add61c27ea23501be82a34854edd98e10e061
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Fri Sep 23 11:07:09 2022 +0200

    macsec: don't free NULL metadata_dst

    Commit 0a28bfd4971f added a metadata_dst to each tx_sc, but that's
    only allocated when macsec_add_dev has run, which happens after device
    registration. If the requested or computed SCI already exists, or if
    linking to the lower device fails, we will panic because
    metadata_dst_free can't handle NULL.

    Reproducer:
        ip link add link $lower type macsec
        ip link add link $lower type macsec

    Fixes: 0a28bfd4971f ("net/macsec: Add MACsec skb_metadata_dst Tx Data path support")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Acked-by: Raed Salem <raeds@nvidia.com>
    Link: https://lore.kernel.org/r/60f2a1965fe553e2cade9472407d0fafff8de8ce.1663923580.git.sd@queasysnail.net
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:28 +01:00
Sabrina Dubroca adabd0f3b6 net: macsec: remove the prepare phase when offloading
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 854c9181738f4f38a406f3941e6797e44c3b42d6
Author: Antoine Tenart <atenart@kernel.org>
Date:   Wed Sep 21 15:51:14 2022 +0200

    net: macsec: remove the prepare phase when offloading

    The hardware offloading in MACsec was initially supported using 2 phases.
    This was proposed in the RFC as this could have allowed easier fallback
    to the software implementation if the hardware did not support a feature
    or had enough entries already. But this fallback wasn't implemented and
    might not be a good idea after all. In addition it turned out this logic
    didn't mapped well the hardware logic and device drivers were mostly
    ignoring the preparation phase.

    Let's remove this as it does not offer any advantage and is ignored by
    drivers.

    Signed-off-by: Antoine Tenart <atenart@kernel.org>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:28 +01:00
Sabrina Dubroca b9a61fa7b3 net: macsec: Expose extended packet number (EPN) properties to macsec offload
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 0a6e9b718dbbdeb6e9f56f2f79e789f6833ea804
Author: Emeel Hakim <ehakim@nvidia.com>
Date:   Wed Sep 21 11:10:45 2022 -0700

    net: macsec: Expose extended packet number (EPN) properties to macsec offload

    Currently macsec invokes HW offload path before reading extended packet
    number (EPN) related user properties i.e. salt and short secure channel
    identifier (ssci), hence preventing macsec EPN HW offload.
    Expose those by moving macsec EPN properties reading prior to HW offload
    path.

    Signed-off-by: Emeel Hakim <ehakim@nvidia.com>
    Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:27 +01:00
Sabrina Dubroca 23d3fe6caf net/macsec: Move some code for sharing with various drivers that implements offload
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit b1671253c6015841f6cabd39730fa42fb6d3d407
Author: Lior Nahmanson <liorna@nvidia.com>
Date:   Mon Sep 5 22:21:15 2022 -0700

    net/macsec: Move some code for sharing with various drivers that implements offload

    Move some MACsec infrastructure like defines and functions,
    in order to avoid code duplication for future drivers which
    implements MACsec offload.

    Signed-off-by: Lior Nahmanson <liorna@nvidia.com>
    Reviewed-by: Raed Salem <raeds@nvidia.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Ben Ben-Ishay <benishay@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:27 +01:00
Sabrina Dubroca 3d3a741ab7 net: drivers: get ready for const netdev->dev_addr
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 8bc7823ed3bd5b87765e1b3d6f72c69624680921
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Fri Oct 22 16:21:02 2021 -0700

    net: drivers: get ready for const netdev->dev_addr

    Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
    of VLANs...") introduced a rbtree for faster Ethernet address look
    up. To maintain netdev->dev_addr in this tree we need to make all
    the writes to it go through appropriate helpers. We will make
    netdev->dev_addr a const.

    Make sure local references to netdev->dev_addr are constant.

    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:27 +01:00
Sabrina Dubroca 7e99dc17fe net/macsec: Add MACsec skb_metadata_dst Rx Data path support
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 860ead89b8517c57d34e5d0658443b461d628ab4
Author: Lior Nahmanson <liorna@nvidia.com>
Date:   Mon Sep 5 22:21:14 2022 -0700

    net/macsec: Add MACsec skb_metadata_dst Rx Data path support

    Like in the Tx changes, if there are more than one MACsec device with
    the same MAC address as in the packet's destination MAC, the packet will
    be forward only to this device and not neccessarly to the desired one.

    Offloading device drivers will mark offloaded MACsec SKBs with the
    corresponding SCI in the skb_metadata_dst so the macsec rx handler will
    know to which port to divert those skbs, instead of wrongly solely
    relaying on dst MAC address comparison.

    Signed-off-by: Lior Nahmanson <liorna@nvidia.com>
    Reviewed-by: Raed Salem <raeds@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:27 +01:00
Sabrina Dubroca cb9cc49f7a net/macsec: Add MACsec skb_metadata_dst Tx Data path support
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173895
Tested: basic macsec test

commit 0a28bfd4971fd570d1f3e4653b21415becefc92c
Author: Lior Nahmanson <liorna@nvidia.com>
Date:   Mon Sep 5 22:21:13 2022 -0700

    net/macsec: Add MACsec skb_metadata_dst Tx Data path support

    In the current MACsec offload implementation, MACsec interfaces shares
    the same MAC address by default.
    Therefore, HW can't distinguish from which MACsec interface the traffic
    originated from.

    MACsec stack will use skb_metadata_dst to store the SCI value, which is
    unique per Macsec interface, skb_metadat_dst will be used by the
    offloading device driver to associate the SKB with the corresponding
    offloaded interface (SCI).

    Signed-off-by: Lior Nahmanson <liorna@nvidia.com>
    Reviewed-by: Raed Salem <raeds@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2023-03-17 17:19:19 +01:00
Ivan Vecera 6fb59586eb genetlink: start to validate reserved header bytes
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2175249

Conflicts:
* kernel/taskstats.c
  context conflict due to missing edc73c7261ca ("kernel: make taskstats
  available from all net namespaces")
* fs/ksmbd/transport_ipc.c
* net/ipv6/ioam6.c
  hunks skipped as the files are not present in RHEL kernel

commit 9c5d03d362519f36cd551aec596388f895c93d2d
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Wed Aug 24 17:18:30 2022 -0700

    genetlink: start to validate reserved header bytes

    We had historically not checked that genlmsghdr.reserved
    is 0 on input which prevents us from using those precious
    bytes in the future.

    One use case would be to extend the cmd field, which is
    currently just 8 bits wide and 256 is not a lot of commands
    for some core families.

    To make sure that new families do the right thing by default
    put the onus of opting out of validation on existing families.

    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Acked-by: Paul Moore <paul@paul-moore.com> (NetLabel)
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2023-03-06 15:42:45 +01:00
Sabrina Dubroca 293718a239 macsec: Fix traffic counters/statistics
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2136170
Tested: basic macsec tests

commit 91ec9bd57f3524ff3d86bfb7c9ee5a315019733c
Author: Clayton Yager <Clayton_Yager@selinc.com>
Date:   Mon Aug 8 15:38:23 2022 -0700

    macsec: Fix traffic counters/statistics

    OutOctetsProtected, OutOctetsEncrypted, InOctetsValidated, and
    InOctetsDecrypted were incrementing by the total number of octets in frames
    instead of by the number of octets of User Data in frames.

    The Controlled Port statistics ifOutOctets and ifInOctets were incrementing
    by the total number of octets instead of the number of octets of the MSDUs
    plus octets of the destination and source MAC addresses.

    The Controlled Port statistics ifInDiscards and ifInErrors were not
    incrementing each time the counters they aggregate were.

    The Controlled Port statistic ifInErrors was not included in the output of
    macsec_get_stats64 so the value was not present in ip commands output.

    The ReceiveSA counters InPktsNotValid, InPktsNotUsingSA, and InPktsUnusedSA
    were not incrementing.

    Signed-off-by: Clayton Yager <Clayton_Yager@selinc.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2022-11-09 11:45:36 +01:00
Sabrina Dubroca 6e8ec562fd net: macsec: fix potential resource leak in macsec_add_rxsa() and macsec_add_txsa()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2136170
Tested: basic macsec tests

commit c7b205fbbf3cffa374721bb7623f7aa8c46074f1
Author: Jianglei Nie <niejianglei2021@163.com>
Date:   Fri Jul 22 17:29:02 2022 +0800

    net: macsec: fix potential resource leak in macsec_add_rxsa() and macsec_add_txsa()

    init_rx_sa() allocates relevant resource for rx_sa->stats and rx_sa->
    key.tfm with alloc_percpu() and macsec_alloc_tfm(). When some error
    occurs after init_rx_sa() is called in macsec_add_rxsa(), the function
    released rx_sa with kfree() without releasing rx_sa->stats and rx_sa->
    key.tfm, which will lead to a resource leak.

    We should call macsec_rxsa_put() instead of kfree() to decrease the ref
    count of rx_sa and release the relevant resource if the refcount is 0.
    The same bug exists in macsec_add_txsa() for tx_sa as well. This patch
    fixes the above two bugs.

    Fixes: 3cf3227a21 ("net: macsec: hardware offloading infrastructure")
    Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2022-11-09 11:45:36 +01:00
Sabrina Dubroca 6defea18f9 macsec: always read MACSEC_SA_ATTR_PN as a u64
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2136170
Tested: basic macsec tests

commit c630d1fe6219769049c87d1a6a0e9a6de55328a1
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Fri Jul 22 11:16:30 2022 +0200

    macsec: always read MACSEC_SA_ATTR_PN as a u64

    Currently, MACSEC_SA_ATTR_PN is handled inconsistently, sometimes as a
    u32, sometimes forced into a u64 without checking the actual length of
    the attribute. Instead, we can use nla_get_u64 everywhere, which will
    read up to 64 bits into a u64, capped by the actual length of the
    attribute coming from userspace.

    This fixes several issues:
     - the check in validate_add_rxsa doesn't work with 32-bit attributes
     - the checks in validate_add_txsa and validate_upd_sa incorrectly
       reject X << 32 (with X != 0)

    Fixes: 48ef50fa86 ("macsec: Netlink support of XPN cipher suites (IEEE 802.1AEbw)")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2022-11-09 11:45:36 +01:00
Sabrina Dubroca 93d78a6e59 macsec: limit replay window size with XPN
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2136170
Tested: basic macsec tests

commit b07a0e2044057f201d694ab474f5c42a02b6465b
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Fri Jul 22 11:16:29 2022 +0200

    macsec: limit replay window size with XPN

    IEEE 802.1AEbw-2013 (section 10.7.8) specifies that the maximum value
    of the replay window is 2^30-1, to help with recovery of the upper
    bits of the PN.

    To avoid leaving the existing macsec device in an inconsistent state
    if this test fails during changelink, reuse the cleanup mechanism
    introduced for HW offload. This wasn't needed until now because
    macsec_changelink_common could not fail during changelink, as
    modifying the cipher suite was not allowed.

    Finally, this must happen after handling IFLA_MACSEC_CIPHER_SUITE so
    that secy->xpn is set.

    Fixes: 48ef50fa86 ("macsec: Netlink support of XPN cipher suites (IEEE 802.1AEbw)")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2022-11-09 11:45:35 +01:00
Sabrina Dubroca 869c543086 macsec: fix error message in macsec_add_rxsa and _txsa
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2136170
Tested: basic macsec tests

commit 3240eac4ff20e51b87600dbd586ed814daf313db
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Fri Jul 22 11:16:28 2022 +0200

    macsec: fix error message in macsec_add_rxsa and _txsa

    The expected length is MACSEC_SALT_LEN, not MACSEC_SA_ATTR_SALT.

    Fixes: 48ef50fa86 ("macsec: Netlink support of XPN cipher suites (IEEE 802.1AEbw)")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2022-11-09 11:45:35 +01:00
Sabrina Dubroca b4506db9d5 macsec: fix NULL deref in macsec_add_rxsa
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2136170
Tested: basic macsec tests

commit f46040eeaf2e523a4096199fd93a11e794818009
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Fri Jul 22 11:16:27 2022 +0200

    macsec: fix NULL deref in macsec_add_rxsa

    Commit 48ef50fa86 added a test on tb_sa[MACSEC_SA_ATTR_PN], but
    nothing guarantees that it's not NULL at this point. The same code was
    added to macsec_add_txsa, but there it's not a problem because
    validate_add_txsa checks that the MACSEC_SA_ATTR_PN attribute is
    present.

    Note: it's not possible to reproduce with iproute, because iproute
    doesn't allow creating an SA without specifying the PN.

    Fixes: 48ef50fa86 ("macsec: Netlink support of XPN cipher suites (IEEE 802.1AEbw)")
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=208315
    Reported-by: Frantisek Sumsal <fsumsal@redhat.com>
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2022-11-09 11:45:35 +01:00
Sabrina Dubroca e17fa9f489 Revert "net: macsec: update SCI upon MAC address change."
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2118139
Tested: reproducer on bugzilla

commit e82c649e851c9c25367fb7a2a6cf3479187de467
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Wed Aug 17 14:54:36 2022 +0200

    Revert "net: macsec: update SCI upon MAC address change."

    This reverts commit 6fc498bc82.

    Commit 6fc498bc82 states:

        SCI should be updated, because it contains MAC in its first 6
        octets.

    That's not entirely correct. The SCI can be based on the MAC address,
    but doesn't have to be. We can also use any 64-bit number as the
    SCI. When the SCI based on the MAC address, it uses a 16-bit "port
    number" provided by userspace, which commit 6fc498bc82 overwrites
    with 1.

    In addition, changing the SCI after macsec has been setup can just
    confuse the receiver. If we configure the RXSC on the peer based on
    the original SCI, we should keep the same SCI on TX.

    When the macsec device is being managed by a userspace key negotiation
    daemon such as wpa_supplicant, commit 6fc498bc82 would also
    overwrite the SCI defined by userspace.

    Fixes: 6fc498bc82 ("net: macsec: update SCI upon MAC address change.")
    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Link: https://lore.kernel.org/r/9b1a9d28327e7eb54550a92eebda45d25e54dd0d.1660667033.git.sd@queasysnail.net
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2022-08-24 15:57:31 +02:00
Petr Oros 56766d1469 net: dev: Makes sure netif_rx() can be invoked in any context.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2089703

Conflicts:
- drivers/net/amt.c Unmerged because file missing in rhel

Upstream commit(s):
commit baebdf48c360080710f80699eea3affbb13d6c65
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date:   Sat Feb 12 00:38:38 2022 +0100

    net: dev: Makes sure netif_rx() can be invoked in any context.

    Dave suggested a while ago (eleven years by now) "Let's make netif_rx()
    work in all contexts and get rid of netif_rx_ni()". Eric agreed and
    pointed out that modern devices should use netif_receive_skb() to avoid
    the overhead.
    In the meantime someone added another variant, netif_rx_any_context(),
    which behaves as suggested.

    netif_rx() must be invoked with disabled bottom halves to ensure that
    pending softirqs, which were raised within the function, are handled.
    netif_rx_ni() can be invoked only from process context (bottom halves
    must be enabled) because the function handles pending softirqs without
    checking if bottom halves were disabled or not.
    netif_rx_any_context() invokes on the former functions by checking
    in_interrupts().

    netif_rx() could be taught to handle both cases (disabled and enabled
    bottom halves) by simply disabling bottom halves while invoking
    netif_rx_internal(). The local_bh_enable() invocation will then invoke
    pending softirqs only if the BH-disable counter drops to zero.

    Eric is concerned about the overhead of BH-disable+enable especially in
    regard to the loopback driver. As critical as this driver is, it will
    receive a shortcut to avoid the additional overhead which is not needed.

    Add a local_bh_disable() section in netif_rx() to ensure softirqs are
    handled if needed.
    Provide __netif_rx() which does not disable BH and has a lockdep assert
    to ensure that interrupts are disabled. Use this shortcut in the
    loopback driver and in drivers/net/*.c.
    Make netif_rx_ni() and netif_rx_any_context() invoke netif_rx() so they
    can be removed once they are no more users left.

    Link: https://lkml.kernel.org/r/20100415.020246.218622820.davem@davemloft.net
    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2022-06-06 11:25:37 +02:00