[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1638403212-29265-7-git-send-email-quic_fenglinw@quicinc.com>
Date: Thu, 2 Dec 2021 08:00:08 +0800
From: Fenglin Wu <quic_fenglinw@...cinc.com>
To: <linux-arm-msm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<sboyd@...nel.org>
CC: <collinsd@...eaurora.org>, <subbaram@...eaurora.org>,
<quic_fenglinw@...cinc.com>, <tglx@...utronix.de>, <maz@...nel.org>
Subject: [RESEND PATCH v3 06/10] spmi: pmic-arb: block access for invalid PMIC arbiter v5 SPMI writes
From: David Collins <collinsd@...eaurora.org>
The system crashes due to an access permission violation when
writing to a PMIC peripheral which is not owned by the current
ee. Add a check for PMIC arbiter version 5 for such invalid
write requests and return an error instead of crashing the
system.
Signed-off-by: David Collins <collinsd@...eaurora.org>
Signed-off-by: Fenglin Wu <quic_fenglinw@...cinc.com>
---
drivers/spmi/spmi-pmic-arb.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
index 011044e..e83342a 100644
--- a/drivers/spmi/spmi-pmic-arb.c
+++ b/drivers/spmi/spmi-pmic-arb.c
@@ -1027,6 +1027,11 @@ static int pmic_arb_offset_v5(struct spmi_pmic_arb *pmic_arb, u8 sid, u16 addr,
offset = 0x10000 * pmic_arb->ee + 0x80 * apid;
break;
case PMIC_ARB_CHANNEL_RW:
+ if (pmic_arb->apid_data[apid].write_ee != pmic_arb->ee) {
+ dev_err(&pmic_arb->spmic->dev, "disallowed SPMI write to sid=%u, addr=0x%04X\n",
+ sid, addr);
+ return -EPERM;
+ }
offset = 0x10000 * apid;
break;
}
--
2.7.4
Powered by blists - more mailing lists