Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FB4040 MAC address improvements #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

neocturne
Copy link
Contributor

This PR contains:

  • A fix for a buffer overflow caused by MAC address extraction on all devices with CONFIG_AVM_EVA_MAC_EXTRACT. I looks like the overflow doesn't cause any harm currently, but that might easily change depending on compiler optimizations with newer GCC versions.
  • A new implementation of the MAC address extraction to allow using all 7 addresses from the FB4040. The new code is not used on other hardware so far, as I can only test on the FB4040.

The vendor firmware of the FB4040 assigns the first 5 MAC addresses to the 5 Ethernet ports, and I intend to update OpenWrt to match (on the current OpenWrt main branch, the ethernet0 alias got lost for most ipq40xx devices unfortunately, so even the assignment of the first address is not working as intended - going to fix that together with the U-Boot update)

The code assumes that no_of_macs is always at least 2 when
CONFIG_AVM_EVA_MAC_EXTRACT is set, writing 2*6 bytes into enetaddr.

This is not always the case however: get_eth_mac_address() is not only
called by the board code, but also by ipq40xx_edma_init(). The latter
passes IPQ40XX_EDMA_DEV == 1 as no_of_macs, and its buffer is
only 6 bytes long.

Check no_of_macs and return early to avoid the buffer overflow.

Signed-off-by: Matthias Schiffer <[email protected]>
get_eth_mac_address() may set fewer addresses than CONFIG_IPQ_NO_MACS.
Make sure that we don't read uninitialized memory in this case.

Signed-off-by: Matthias Schiffer <[email protected]>
Implement a new version that can extract an arbitrary number of MAC
addresses from the urconfig partition. The new implementation is
ifdef'ed for now, as it makes a few more assumption about the format of
the data, and should be verified on each supported device before it is
used.

Signed-off-by: Matthias Schiffer <[email protected]>
The urconfig partition of the FritzBox 4040 contains 7 MAC addresses in
total:

- maca
- macb
- macwlan
- macwlan2
- macdsl
- usb_board_mac
- usb_rndis_mac

In the vendor firmware, the first 5 addresses are assigned to the 5
Ethernet ports (so macdsl is used for the WAN port); the individual MAC
addresses of the LAN ports are usually not visible, as all 4 ports are
bridged, but the assignment can be extracted using a serial console.

Make all 7 addresses available to the OS.

Signed-off-by: Matthias Schiffer <[email protected]>
@neocturne
Copy link
Contributor Author

Also cc @robimarko @Ansuel as current OpenWrt maintainers of the target.

It's unfortunate that we don't update U-Boot during sysupgrade even though U-Boot is initially installed as part of OpenWrt for these devices, but that will be annoying to change without increasing the image compat version...

@neocturne
Copy link
Contributor Author

ping @chunkeey - can I get a review for this?

Also, do you think it would make sense to move this repo into the OpenWrt org (if that's okay with the other maintainers who are more active than me)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant