Page MenuHomeFreeBSD

ena: Initialize statistics before the interface is available
Needs ReviewPublic

Authored by akiyano_amazon.com on Jun 27 2023, 8:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 5, 10:16 PM
Unknown Object (File)
Fri, Nov 8, 6:54 AM
Unknown Object (File)
Oct 22 2024, 4:17 PM
Unknown Object (File)
Oct 4 2024, 8:24 PM
Unknown Object (File)
Oct 2 2024, 8:59 AM
Unknown Object (File)
Oct 2 2024, 4:51 AM
Unknown Object (File)
Sep 30 2024, 10:40 PM
Unknown Object (File)
Sep 28 2024, 4:08 AM
Subscribers

Details

Reviewers
mw
Summary

In [1], the FBSD community exposed a bug in the fbsd/ena driver.

Bug description:

Current function call order is as follows:

  1. ena_attach()

1.1. ena_setup_ifnet()
1.1.1. Registration of ena_get_counter()
1.1.2. ether_ifattach(ifp, adapter->mac_addr);
1.2. Statistics allocation and initialization.

At point 1.1.2, when ether_ifattach() returns, the interface is available,
and stats can be read before they are allocated, leading to kernel panic.

Also fixed a potential memory leak by freeing the stats since they were
not freed in case the following calls failed.

Fix:

This commit moves the statistics allocation and initialization to happen
before ena_setup_ifnet()

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268934

Fixes: 9b8d05b8ac78 ("Add support for Amazon Elastic Network Adapter (ENA) NIC")
Fixes: 30217e2dff10 ("Rework counting of hardware statistics in ENA driver")
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped