Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1146305pxb; Thu, 19 Aug 2021 22:01:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHExWc+qIrX5oXEDgmCX52XSpN2Cq14z7jx+IDjetWRAodgCW0v5FazFFe0FYVC99bVt3m X-Received: by 2002:a17:906:318c:: with SMTP id 12mr19318537ejy.28.1629435692495; Thu, 19 Aug 2021 22:01:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629435692; cv=none; d=google.com; s=arc-20160816; b=P22zue8qzS97myrCfIrf/XStbWj4nE0//cKYghq7yEkf5c3SqSj25tTobqJtH9d+Hm 0xQuroNVEu+g900nj/pbKuIQp1/d7UFtVNjHVne38akZJa/lZSM1FOkilDeMy4dIreD3 oDK4ks1aqK0o5oEO5Kvoy+87aLRmXhYy/ZC3CR8V115PkuL7iGH8OMLmfc5zZP20WxM6 n++8zHjHArrxa6eXpkHimdrl2ZB+lD/OdFGr6tYcoAc69sMpGRV6M7xUW+Z3z2S93QDC iEv6IMYckIQ4UBEpxk0Qa0EltMySHAudAnPF+MY61zjdR1uM0Esn5kPIiBLymFbAQap3 e/Sg== 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=FFceLVYWPA4yEf1VmLPj5WVmhdSRpJenaxZtYI4h4oTJUxvw8U8ts4bCIjHGc09K4S gtfBQ5Q3QEiiJZ7yNDYZ0TRfOxcZVQ/nVP1ek2XsFo7uZcHJFg8vhWaEanCpwIZpoSBg WtZEHNQBAuzveRXdno2QrPidLSyQSGuXLRytlXwYDCciGZUmAj508z02jscBRu7qnMJF asBEUiLH3kJlq0k02EPgEIWJB+IEtEhJX2lYPikI47HQehEfLYOHjmpVKYlURD1novGW s69WKLy3atm7OtzMVDb22jVLswqw6s0eKfFGJO4YTCyzM7tLhI91suJQMJZ6MB/sOiUc JKDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b="wcFz/2Tz"; 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 jg17si5007278ejc.362.2021.08.19.22.01.10; Thu, 19 Aug 2021 22:01: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=fail header.i=@quicinc.com header.s=qcdkim header.b="wcFz/2Tz"; 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 S238277AbhHTE7g (ORCPT + 99 others); Fri, 20 Aug 2021 00:59:36 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:41614 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237795AbhHTE70 (ORCPT ); Fri, 20 Aug 2021 00:59:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1629435529; x=1660971529; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=xMDIxzoEbq0aPJ2fBtVchMgpbiMzY/BXvnlgZEBdY1I=; b=wcFz/2TzjpdCrEPcIvN5Z/Cic+DXi95d87+ST1Q6UnWSfXkbO5ndM3If XE7zLHn6AZkCwg9bmUewtr22QFb77qreMFd/hFA7pKYFrxGbnDBQ0DALf zfNM1eR85De93+VKpvzDVMHeV/v6M0SsV7JOKWzsjba8cva/p/q4cvLEr U=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 19 Aug 2021 21:58:49 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2021 21:58:48 -0700 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.858.15; Thu, 19 Aug 2021 21:58:48 -0700 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_CBC_SHA384) id 15.2.858.15; Thu, 19 Aug 2021 21:58:46 -0700 From: Fenglin Wu To: , , CC: , , Subject: [PATCH V1 6/9] spmi: pmic-arb: block access for invalid PMIC arbiter v5 SPMI writes Date: Fri, 20 Aug 2021 12:58:01 +0800 Message-ID: <1629435488-10228-7-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1629435488-10228-1-git-send-email-quic_fenglinw@quicinc.com> References: <1629435488-10228-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: nasanexm03h.na.qualcomm.com (10.85.0.50) 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 --- 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.