Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5709702pxv; Wed, 28 Jul 2021 18:15:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMYllL0Wx8QkFMgKYWDdeU0lZPq/Vd+hLlAhn75mCTzqOVQJjJqnoS9NYZJxLl/2Er/Ryu X-Received: by 2002:a5d:93d3:: with SMTP id j19mr1883252ioo.184.1627521342257; Wed, 28 Jul 2021 18:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627521342; cv=none; d=google.com; s=arc-20160816; b=kKf/kk++8azSMLA2AQPAV1Tx6qQuhCb5RS9Jm9CTMAX+cJHvFVtfbzDrOR0CqMuIcb 2JluA4sUr/aGwVaoCJtgAW+YwGQ9VgHaBw+FOdZ7vrrhPiDTaCNKnJNOLWDJ1P/2pbKQ h4RdIksYy88mX3bwkxacILgWsb3TDn4IYnfCeqOl5C6Breu6u/FdMQMfa79TUmLyk+qL 1EWV5uw+pzqUimDylg1+8IzGWvAXtrlykXFIB65ayqUAVPdB0zQwPifl/EK4TXYs6mjh 4VxDZkNz/Q4BaBXvKkO1n8z8irifhTEWQWNInYtHZsAyT10R9/WZo4kCdimGzTNi7kxY /6tg== 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=ulR4/RoTArDx07uUdY0ZZXriSJFRIyQb6Imam8hX47YThIbns3ZU+7OPMd83WSbhah GXW1AjQd1nDQeBAbSJ0gGO2ha8YHQ8BIiqworTSnA4egthFqZ1pfMUi992zttmkXWpLm 0FN00NtxJNJwohmWhmftK7ydjTCeLzifDXLqKYojPdECti/Q6s+UOwgu2yiJeZcR7XGX 0AOwxmlTUzqf0RGTiwIunV3XwH7n5a/do0uKbBgqbviM9KO4Z2yI59aNGtpSsrA/2fGQ 2hqKQYROL8eu4HD83A31ZzJ1PQIwmMAs3EJnQcMxPdQTruEWrk9S3BdnU+snqq63UCA5 L7Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b="mdZhzn/H"; 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 t2si1607342iop.79.2021.07.28.18.15.31; Wed, 28 Jul 2021 18:15:42 -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="mdZhzn/H"; 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 S233384AbhG2BOF (ORCPT + 99 others); Wed, 28 Jul 2021 21:14:05 -0400 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:64145 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233311AbhG2BN5 (ORCPT ); Wed, 28 Jul 2021 21:13:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1627521235; x=1659057235; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=xMDIxzoEbq0aPJ2fBtVchMgpbiMzY/BXvnlgZEBdY1I=; b=mdZhzn/HDRc0bhhfpPBInLQpOU79fFWh1W/HMEOFQ+EbYB6UU5pVhUiV ajsa07Qpxfgy/nSWQRAwwVFxYQACQmS3oAPuteNWSeMIHei+d4cEwucn0 fxBrLJBgH1wSF4jhJCvQhYH5CFcj6BSZUalxRpPnEI9SwxjjRMmKvSIZD Y=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-01.qualcomm.com with ESMTP; 28 Jul 2021 18:13:54 -0700 X-QCInternal: smtphost Received: from nasanexm03e.na.qualcomm.com ([10.85.0.48]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/AES256-SHA; 28 Jul 2021 18:13:54 -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; Wed, 28 Jul 2021 18:13:53 -0700 From: Fenglin Wu To: , , CC: , , Subject: [PATCH V1 6/9] spmi: pmic-arb: block access for invalid PMIC arbiter v5 SPMI writes Date: Thu, 29 Jul 2021 09:12:44 +0800 Message-ID: <1627521167-18848-7-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1627521167-18848-1-git-send-email-quic_fenglinw@quicinc.com> References: <1627521167-18848-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: nasanex01b.na.qualcomm.com (10.46.141.250) 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.