RaspberryPi3+: can't set mac address from device tree

Bug #1798578 reported by Paolo Pisati
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux-raspi2 (Ubuntu)
Invalid
Undecided
Unassigned
Xenial
Fix Released
Undecided
Unassigned

Bug Description

Impact:

The RaspberryPi3+ board came with an usb's to ethernet lan78xx nic adapter - thhis chip has no external eeprom, nor internal preprogrammed mac address and as such, after every reboot, it generates a random new ethernet mac address.

Supposedly, the lan78xx driver is able to read its mac address from the device tree passed to the kernel (see d093067 "lan78xx: Read MAC address from DT if present"), making it possible to have reproducible/fixed mac addresses, but unfortunately this feature isn't working in our Xenial/raspi2 kernel (while it's working fine in Bionc/raspi2).

After some debugging i found that the usb_net struct backing the lan78xx driver, had no clue about the dt node it was associated, making this piece of code constantly evaluates to NULL:

static void lan78xx_init_mac_address(struct lan78xx_net *dev)
...
mac_addr = of_get_mac_address(dev->udev->dev.of_node);
...

There "of_node" was always NULL.

After more debugging, i found that the feature to bind usb_net devices and device tree nodes was introduced in the Linux 4.6 cycle, and as such Xenial didn't have it.

Fix:

Apply the patch and recompile

How to test:

Upon boot of the RaspberryPi3+ board (and after the dtb has been loaded into memory), stop at the uboot prompt and check the usbeether device node:

U-Boot> fdt print /soc/usb/usb1@1/usb1_1@1/usbether@1
usbether@1 {
        local-mac-address = [b8 27 eb ce 07 ba];
        compatible = "usb424,7800";
        reg = <0x00000001>;
        microchip,eee-enabled;
        microchip,tx-lpi-timer = <0x00000258>;
        phandle = <0x00000024>;
};

the "local-mac-address" has been filled by the Broadcom bootloader, and contains the lan78xx's mac address.

Then proceed with the boot routine, readh the user prompt, and check eth0's mac address:

$ ifconfig eth0 | grep HWaddr
eth0 Link encap:Ethernet HWaddr b8:27:eb:ce:07:ba

If it's the same as above, then the fix worked.

Regression:

The patch itself has been upstream since v4.6-rc1, and it changes a very small portion of code, so i'll say it's regression potential is very low / none.

CVE References

Paolo Pisati (p-pisati)
summary: - rpi3b+: can't set mac addrss from device tree
+ RaspberryPi3+: can't set mac address from device tree
Revision history for this message
Paolo Pisati (p-pisati) wrote :
Changed in linux-raspi2 (Ubuntu):
status: New → Invalid
Revision history for this message
Viktor Petersson (vpetersson) wrote :

@p-pisati what's the ETA on this? We're desperate for this feature. See https://bugs.launchpad.net/ubuntu/+source/linux-raspi2/+bug/1798578

Changed in linux-raspi2 (Ubuntu Xenial):
status: New → In Progress
Changed in linux-raspi2 (Ubuntu Xenial):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (21.2 KiB)

This bug was fixed in the package linux-raspi2 - 4.4.0-1100.108

---------------
linux-raspi2 (4.4.0-1100.108) xenial; urgency=medium

  * linux-raspi2: 4.4.0-1100.108 -proposed tracker (LP: #1799409)

  * RaspberryPi3+: can't set mac address from device tree (LP: #1798578)
    - USB: core: let USB device know device node

  [ Ubuntu: 4.4.0-139.165 ]

  * linux: 4.4.0-139.165 -proposed tracker (LP: #1799401)
  * Kernel panic after the ubuntu_nbd_smoke_test on Xenial kernel (LP: #1793464)
    - nbd: Remove signal usage
    - nbd: Timeouts are not user requested disconnects
    - nbd: Cleanup reset of nbd and bdev after a disconnect
    - nbd: don't shutdown sock with irq's disabled
    - nbd: fix race in ioctl
  * fscache: bad refcounting in fscache_op_complete leads to OOPS (LP: #1797314)
    - SAUCE: fscache: Fix race in decrementing refcount of op->npages
  * xenial: virtio-scsi: CPU soft lockup due to loop in
    virtscsi_target_destroy() (LP: #1798110)
    - SAUCE: (no-up) virtio-scsi: Decrement reqs counter before SCSI command
      requeue
  * Error reported when creating ZFS pool with "-t" option, despite successful
    pool creation (LP: #1769937)
    - SAUCE: (noup) Update zfs to 0.6.5.6-0ubuntu26
  * Xenial update: 4.4.160 upstream stable release (LP: #1798770)
    - crypto: skcipher - Fix -Wstringop-truncation warnings
    - tsl2550: fix lux1_input error in low light
    - vmci: type promotion bug in qp_host_get_user_memory()
    - x86/numa_emulation: Fix emulated-to-physical node mapping
    - staging: rts5208: fix missing error check on call to rtsx_write_register
    - uwb: hwa-rc: fix memory leak at probe
    - power: vexpress: fix corruption in notifier registration
    - Bluetooth: Add a new Realtek 8723DE ID 0bda:b009
    - USB: serial: kobil_sct: fix modem-status error handling
    - 6lowpan: iphc: reset mac_header after decompress to fix panic
    - md-cluster: clear another node's suspend_area after the copy is finished
    - media: exynos4-is: Prevent NULL pointer dereference in __isp_video_try_fmt()
    - powerpc/kdump: Handle crashkernel memory reservation failure
    - media: fsl-viu: fix error handling in viu_of_probe()
    - x86/tsc: Add missing header to tsc_msr.c
    - x86/entry/64: Add two more instruction suffixes
    - scsi: target/iscsi: Make iscsit_ta_authentication() respect the output
      buffer size
    - scsi: klist: Make it safe to use klists in atomic context
    - scsi: ibmvscsi: Improve strings handling
    - usb: wusbcore: security: cast sizeof to int for comparison
    - powerpc/powernv/ioda2: Reduce upper limit for DMA window size
    - alarmtimer: Prevent overflow for relative nanosleep
    - s390/extmem: fix gcc 8 stringop-overflow warning
    - ALSA: snd-aoa: add of_node_put() in error path
    - media: s3c-camif: ignore -ENOIOCTLCMD from v4l2_subdev_call for s_power
    - media: soc_camera: ov772x: correct setting of banding filter
    - media: omap3isp: zero-initialize the isp cam_xclk{a,b} initial data
    - staging: android: ashmem: Fix mmap size validation
    - drivers/tty: add error handling for pcmcia_loop_config
    - media: tm6000: add error handling for dvb_register_adapter
    - AL...

Changed in linux-raspi2 (Ubuntu Xenial):
status: Fix Committed → Fix Released
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.