Repository navigation
Conversation
abinayaddhandapani
left a comment
There was a problem hiding this comment.
Google has provided 2 different patches for the issue. Please submit 2 separate commits as provided by google with the same commit message.
Also please add signed-off by Jake Chiang along with your signed-off message.
|
Split into the two Google commits, in order:
Signed-off-by for Jake Chiang and Eugene Huang are included with mine. One difference from Google's first patch: this tree still uses in_progress/misc_fops_done and the trace buffer, so those are not removed and the commit message does not claim they are. The combined code is the same tree that passed the unbind/bind cycles and the apml_tool checks on the Congo platform. |
The SBRMI mailbox transfer (rmi_mailbox_xfer) can block for up to 2 seconds waiting for firmware response. If the driver is unbound while a hwmon read/write (sbrmi_read/sbrmi_write), ioctl or sbrmi_open is in progress, the devm-managed rmi_dev structure is freed while the transaction thread still holds a reference to it, causing a Use-After-Free kernel panic. Additionally, the original in_progress/misc_fops_done completion mechanism only protected the ioctl path and had a race window between the no_new_trans check and the in_progress atomic set. Fix this by: - Replacing devm_hwmon_device_register_with_info with hwmon_device_register_with_info so the hwmon device can be explicitly unregistered early in the remove path. - Setting no_new_trans=1 at the start of remove to signal shutdown to new requests. - Calling misc_deregister() and hwmon_device_unregister() before acquiring the mutex, to close both entry points without holding the lock (avoids deadlock). - Acquiring rmi_dev->lock in remove to wait for any in-flight critical section to complete, then setting regmap=NULL as a fail-safe to prevent stale hardware accesses. - Acquiring rmi_dev->lock in sbrmi_open() to protect configure_regmap() from concurrent driver unbinds, since it can trigger SBRMI mailbox transfers. - Checking no_new_trans under lock in sbrmi_read, sbrmi_write, and sbrmi_ioctl to reject new transactions during shutdown. This port keeps in_progress and misc_fops_done, and it keeps the existing DIMM temperature conversion. The trace buffer allocation is unchanged. Apply the same fix to apml_sbtsi.c, which had an identical vulnerability with no synchronization in its remove path. Change-Id: I27d2c52724a52df40ec9c9517d17c02ae9b83a30 Signed-off-by: Eugene Huang <eugene.ty.huang@fii-na.corp-partner.google.com> Signed-off-by: Jake Chiang <hung-tse.chiang@fii-na.corp-partner.google.com> Signed-off-by: Pradeep Navalagi <pnavalag@amd.com>
Existing file descriptors may remain open after misc_deregister(), causing ioctl to access freed driver data after unbind. Manage the driver data lifetime with kref and hold a reference for each open file. During remove, mark the device unavailable and drop the driver reference, allowing unbind to complete while existing ioctls fail safely. Apply the same fix to the sbtsi driver, which is affected by the same lifetime issue. Change-Id: I76c65f005efa3501e27f9d5337fea01534d77848 Signed-off-by: Jake Chiang <hung-tse.chiang@fii-na.corp-partner.google.com> Signed-off-by: Eugene Huang <eugene.ty.huang@fii-na.corp-partner.google.com> Signed-off-by: Pradeep Navalagi <pnavalag@amd.com>
mahkurap
left a comment
There was a problem hiding this comment.
I would like the DCSM team to take the ownership of these changes.
Summary
Testing