Skip to content

HAL_ETH does non-atomic Test-and-Set operations on gState which is not thread-safe #70

Open
@KarstenHohmeier

Description

@KarstenHohmeier

HAL_ETH uses gState as a "poor man's mutex" to guard it's internal state and associated hardware registers against concurrent access and enforce a specific order of initialization.

When gState gets tested and set to BUSY for example, HAL_ETH does critical things to its own state or the hardware:

https://github.com/STMicroelectronics/stm32h7xx_hal_driver/blob/ceda3ceeca2ee77a76d2de2ee6b560ad87c90a48/Src/stm32h7xx_hal_eth.c#L863-L866

Yet these test and set operations are not done atomically (e.g. inside a critical section) so the HAL_ETH locking via gState is vulnerable to race conditions in situations with preemption (e.g. with lwIP + FreeRTOS)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingethEthernet MAC (Media Access Controller)halHAL-LL driver-related issue or pull-request.

Type

No type

Projects

Status

Analyzed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions