Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2428172pxb; Fri, 17 Sep 2021 09:31:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNA82zb8+0zvZJlfD5jw3avNUIe/gINnAJcHHPJRx+moxuIL6dB1UcH1YSrOUoyyw2qnE3 X-Received: by 2002:a05:6402:5252:: with SMTP id t18mr13325158edd.13.1631896292861; Fri, 17 Sep 2021 09:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631896292; cv=none; d=google.com; s=arc-20160816; b=ynPbPo3/w1yrViBA8EaTlpX5wp49xA60neHt5/p1IkhNGmHcBCu4+ZcZ88wV8kqf29 m1p2LaQDSPnJ2q9pXG8h59eFobHdIO+U5haCznmmOJ7hqmjnF2gxL4Rau+8G79PLzteB HgScgqydo9pFmlHW47b8ZvnB4ykpDavGU5QgdXxxIQ/7apqE9r1Fotx4nwOnfOOPQrlB qnYUiZ+5jd6I6t6eHEQqBxeFn0Hv110NBfeG4RdsuYQ17haIWxYSdoMsYsmsIpH6H7iw RMkoAj6R4QUohG6k2OCWfgIFrdo6OrsBWVY0OJWW7BROilB9BP1Sm31Erqn2SlVwPZ6B 6Yuw== 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=OtSq+ort8B4nCsCM1w2vsb0LnoZeXWiSQQkCUckld2I=; b=mIM8JQquAsXDJb0ChTboKIp7/xkQ8Zrq0eHW8Gnc03IogWnaz9QQrYvToqcN+e6hfa m8Pu4tN2krMfypbFDlPyyAab4gMJnbSv+goz7PftgbXf0puNAq6izOTo5RhMe5NqwhiO r4WKkKH+WM/a97VZJ23NT1czHBR+O+vi54DoiKiiF+9ZKsSuTsDJZeQR/jKb7XkI3Uex T5v+yCrvksezzm0+FifUlsW4Vl/pLKKr9E8g2lyv4ioRkJ7MfGXDFh93UmuNgiLGYOZ3 IFeVPIIR/515frbqaw++HUI0GHrbB0ZXd6YdvlBwmnAdkNHhbM+S5T8WH+3Hqntt34c2 +Bbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b="vF/j250O"; 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 m12si7126302edd.470.2021.09.17.09.30.51; Fri, 17 Sep 2021 09:31:32 -0700 (PDT) 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="vF/j250O"; 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 S234834AbhIQGfA (ORCPT + 99 others); Fri, 17 Sep 2021 02:35:00 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:56066 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235541AbhIQGes (ORCPT ); Fri, 17 Sep 2021 02:34:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1631860407; x=1663396407; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=OtSq+ort8B4nCsCM1w2vsb0LnoZeXWiSQQkCUckld2I=; b=vF/j250OwGzm9ZrGhC+UMnRewwnD3lN0fTplO5pr0VkcKeF3fP9eofJ+ /QCaXfhKBnkdMgsr07gdifvHURoNYA9XdoS195TVRLAzZPxHHlMybmvwn aR5SwXoQlOwMDP+lQuaYSkMT9dAzbusYihR1SfLv+r0VjyFXCBcOTMi64 M=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 16 Sep 2021 23:33:26 -0700 X-QCInternal: smtphost Received: from nalasex01a.na.qualcomm.com ([10.47.209.196]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2021 23:33:26 -0700 Received: from fenglinw-gv.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.7; Thu, 16 Sep 2021 23:33:24 -0700 From: Fenglin Wu To: , , CC: , , Subject: [RESEND PATCH v1 6/9] spmi: pmic-arb: block access for invalid PMIC arbiter v5 SPMI writes Date: Fri, 17 Sep 2021 14:33:01 +0800 Message-ID: <1631860384-26608-7-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631860384-26608-1-git-send-email-quic_fenglinw@quicinc.com> References: <1631860384-26608-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 nalasex01a.na.qualcomm.com (10.47.209.196) 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 f1b72d8..9239830 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -1020,6 +1020,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