In the Linux kernel, the following vulnerability has been resolved:
pinmux: Use sequential access to access desc->pinmux data
When two client of the same gpio call pinctrlselectstate() for the same functionality, we are seeing NULL pointer issue while accessing desc->mux_owner.
Let's say two processes A, B executing in pinrequest() for the same pin and process A updates the desc->muxusecount but not yet updated the desc->muxowner while process B see the desc->muxusecount which got updated by A path and further executes strcmp and while accessing desc->mux_owner it crashes with NULL pointer.
Serialize the access to mux related setting with a mutex lock.
cpu0 (process A) cpu1(process B)
pinctrlselectstate() { pinctrlselectstate() { pinrequest() { pinrequest() { ... .... } else { desc->muxusecount++; desc->muxusecount && strcmp(desc->mux_owner, owner)) {
if (desc->mux_usecount > 1)
return 0;
desc->mux_owner = owner;
} }