HomeFreeBSD

gpioc: fix race in ioctl(GPIOCONFIGEVENTS)

Description

gpioc: fix race in ioctl(GPIOCONFIGEVENTS)

A race can occur in gpioc_ioctl when it is called with GPIOCONFIGEVENTS
closely followed by GPIOSETCONFIG. GPIOSETCONFIG can alter the
priv->pins list, making it no longer empty and opening the door for
access to priv->events while we are reallocating it. Fix this by holding
priv->mtx while handling GPIOCONFIGEVENTS.

Reported by: Qiu-ji Chen
PR: 289120
Reviewed by: mmel
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D52783

(cherry picked from commit d000adfe41e6f2fe8f3dbe92d8fc2d34ae882086)

Details

Provenance
vexeduxrAuthored on Tue, Sep 30, 11:09 AM
Reviewer
mmel
Differential Revision
D52783: gpioc: fix race in ioctl(GPIOCONFIGEVENTS)
Parents
rGd8ee81cb8a86: gpioc: allocate priv->events with the correct size
Branches
Unknown
Tags
Unknown