Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4921779pxv; Tue, 27 Jul 2021 21:35:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk5Z0bdyMXVkdbv/GYc1OU3yVoMyBgbgYmNhUnn5AGosEhwO5KfYE0U6WoSHjpBPOzU2Br X-Received: by 2002:a17:906:d147:: with SMTP id br7mr11130349ejb.126.1627446936495; Tue, 27 Jul 2021 21:35:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627446936; cv=none; d=google.com; s=arc-20160816; b=U18HlFlbMfgjRtz4wbh5OI3GFwkfnPE+6vzGqDFiTNUs/fX02XADg0FtkQ9nr9RaYY YSUTsQlQFcQsFpCOtvkG55K8s7f1Qh2Xqvhy+m4UOwl3O51YkhCufVcY/6M58YBZwCm3 fxrNkdBvgi0PbDUbP7sbrQH1wehFhxsrYiq3OS7QwUrD8vGm4V986P/u6xCxLI7H9Xin PavdZZq7nX3ar4QVfUsOHCqRoLELNOKIq9aAA5BlfHsShyb52QEo6YsKIQit55Td9mgD Hvy4R4evyMn0ZQnRIW/dBaGpv1F+WjO0AQ2yZ59/gJWNRd6jfwQOOFQmo32W9QHT1kJS Kb3Q== 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=7MIzMALkBLURKL0IAru/NF0VboGr+wQyQ64M7tg3eRA=; b=lCgn6Y6QwQQesbZYdJYf9YNFxOMXAkdqG5grel2ph09vYKjZmyOJxr19rmarjIcHVd ZojoJUAEqX9bI12keGW7/wB+WxGnnUZOl8Eea0klaGQB/3asRk8FXXY/lLLkdKZG7lrb 0PhHEOCNx9mbGlSrG/lqxgXO/6D/SGZNvEPHdn3CYWIGbWZ+AxSHoXu2Zh6idbZErW08 FX3aDjfSm2H94Q4hcBEt+t50pmOciml04zW78GIPkUb1Zh7/H3qYnrAY8WxhK55RtXeT 71oaN3Fi/jPFsMdFLJdqS3Bz6i0IedKbR2HQ1SGy15dr609anFpwOd0bUQ7kQDs/UE3T qimQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b=plk8wap3; 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=fail (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 k21si2407263ejq.644.2021.07.27.21.35.13; Tue, 27 Jul 2021 21:35:36 -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=fail header.i=@quicinc.com header.s=qcdkim header.b=plk8wap3; 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=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234551AbhG1EbA (ORCPT + 99 others); Wed, 28 Jul 2021 00:31:00 -0400 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:35713 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234507AbhG1Eay (ORCPT ); Wed, 28 Jul 2021 00:30:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1627446653; x=1658982653; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=xMDIxzoEbq0aPJ2fBtVchMgpbiMzY/BXvnlgZEBdY1I=; b=plk8wap3M+QxePtjLSKZ1dqBtYp6y+sGh7/KB5I7nCZLLs18VbM2yB6W 6l7ooWlDkNcHn2zWwhSHhatBg2kLQualQgSVj28PcCuxVDHxyEWFz/nqe LR3rdoCTWGaDouKfrtkOLSHqIp6D4DmCloCby3ZhPC9uj0povNbSQ02Tc 4=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-01.qualcomm.com with ESMTP; 27 Jul 2021 21:30:53 -0700 X-QCInternal: smtphost Received: from nasanexm03e.na.qualcomm.com ([10.85.0.48]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/AES256-SHA; 27 Jul 2021 21:30:53 -0700 Received: from fenglinw-gv.qualcomm.com (10.80.80.8) by nasanexm03e.na.qualcomm.com (10.85.0.48) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 27 Jul 2021 21:30:51 -0700 From: Fenglin Wu To: , , "Stephen Boyd" CC: , , Subject: [spmi-pmic-arb fixes and optimization patches V1 6/9] spmi: pmic-arb: block access for invalid PMIC arbiter v5 SPMI writes Date: Wed, 28 Jul 2021 12:30:06 +0800 Message-ID: <1627446609-9064-7-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1627446609-9064-1-git-send-email-quic_fenglinw@quicinc.com> References: <1627446609-9064-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: nasanexm03g.na.qualcomm.com (10.85.0.49) To nasanexm03e.na.qualcomm.com (10.85.0.48) 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 --- 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; } -- Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.