Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5443908pxb; Wed, 26 Jan 2022 12:06:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVAF4D5YGmxcCkg24gvLLO3y5wW8b4sLTFKzbnALn8jJ2ZJcLkhG6cGUlwGgVu1g97KYEB X-Received: by 2002:a17:90a:9908:: with SMTP id b8mr10213679pjp.125.1643227598255; Wed, 26 Jan 2022 12:06:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643227598; cv=none; d=google.com; s=arc-20160816; b=DkqIEryN+S/lGqmTFDy0/qc3cZFSlutShb2p/RTAPaXPbCrJa1hurKdUEsbgeS+GMt APMX1dqCnJnXy1Uu23H+SvGrfWlZzIOAFAmD+wvPcY1oNjYzDafcAV+P+ibNlJSQevnz y9RCZOLPZdO4vXBTwj4hwbr7u2+0vKrGMu+Qym1ETWzppPCe3cfWh6PRdn0IwTYKnj1L Zzc5eySg0nywMMOfocQ3PkigMLhKfKz+2HrTr7DalaHQDzRPZB8CS7wqd+HffvyqAZZG k2kTpDQvlgpTBFT6NsmDV5TTYkB9myZRmEKtjsFWHlMOWsLvduq+kC+Tk3Rh6BZaRvbV /pCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=C/nKcvGohh66HEoXJpfjN/wkXoY3VldhRoiyN4/ZYtg=; b=AVJOMYLnyt69Q7KfCpPvEzpAHEPMRewCEWdwnojNgH/LF49TUUjxdog8uoiZI6XryR mNfdGzVrQjSYmyks69xCKei0IPBldRdQpsVKT7lii2ihKvk3r3zhCk0AIyQLmPMshkU9 uf0zvDVFBmvhFQpEA8zWhznHfjXr58zzAnx1G396rKOlWLOB343TSGwa3sO2mYu4O6dN OJrahxkNS4xe6EzsaG2BDy9lX+uy8uEZEJIj79EEmG14RhIJgTlLHcvGW7baxghMl2Gm ElIrPPAHYnd7nYYTwdNgfQTrPbM93c3+f4lhE93bTjPDBQad6aSjS40T0JgfeFNQ+mgw WRwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=xmRX+7hg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g15si249263pfc.227.2022.01.26.12.06.26; Wed, 26 Jan 2022 12:06:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=xmRX+7hg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236270AbiAZGdK (ORCPT + 99 others); Wed, 26 Jan 2022 01:33:10 -0500 Received: from alexa-out.qualcomm.com ([129.46.98.28]:27721 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236389AbiAZGc4 (ORCPT ); Wed, 26 Jan 2022 01:32:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1643178776; x=1674714776; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=C/nKcvGohh66HEoXJpfjN/wkXoY3VldhRoiyN4/ZYtg=; b=xmRX+7hgMWdfHhlEK/YUNJuIxNhYx+rco3rbFt4E+rKKOKQ2DSxQ/BYC zAPgmcHvtbGZV5Zc9l2DV90oF48MdWRF0/KKzV60RPkbCTW0ASBjxn3A2 Ys+BFfnOnXNkBLwX8kT7PbM+pbWRXsjqRsZ59cu19Z7+BCxjwtViDwXE8 Y=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 25 Jan 2022 22:32:56 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2022 22:32:56 -0800 Received: from nalasex01c.na.qualcomm.com (10.47.97.35) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 25 Jan 2022 22:32:56 -0800 Received: from fenglinw-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 25 Jan 2022 22:32:53 -0800 From: Fenglin Wu To: , , CC: , , , , Subject: [PATCH v5 07/10] spmi: pmic-arb: block access for invalid PMIC arbiter v5 SPMI writes Date: Wed, 26 Jan 2022 14:31:49 +0800 Message-ID: <1643178713-17178-8-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1643178713-17178-1-git-send-email-quic_fenglinw@quicinc.com> References: <1643178713-17178-1-git-send-email-quic_fenglinw@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Collins 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 Signed-off-by: Fenglin Wu --- 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 cf92abc..39f25bc 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -1133,6 +1133,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