Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp127295pxb; Mon, 18 Oct 2021 22:32:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJb64zwOAZesZdsa4LAH6yq4CQAfPsZ3BJbYLvB2o0rGK2Q3wuXtmtLC/gf+XoOXYPj16q X-Received: by 2002:a17:906:789:: with SMTP id l9mr35370271ejc.61.1634621561761; Mon, 18 Oct 2021 22:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634621561; cv=none; d=google.com; s=arc-20160816; b=HkAgAv8m4Xjeb3QNR4OfEzAIag9/KEiOlaNE2tpHQIzyKwJxDApqovtIu6HZXKkhIT oBWnb+D6/K1LCx3rWdl+6E90d00yefQX5crbot4EZz0+pftGFHVBCBxJsK92YA7h71OX 8vsf1TSWF8YNAnX3pyQzrnmCKvCw3I+40kYoUQsNTMn24rUsTuOpF41s10yYxrQGfFrv 3hj4FeCHa8jF63JLnajcUcPQwn1hZBgUufVFMN05S2zkT3eFuFtGo0D6mshGGIiREIaI zOrWvLasxA+2F7t425mq5ExT3fQX0B1h3ilgp0/auqrzKJy5wNakrlSr5nrInwMgiqh8 7f1w== 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=2IhHWawDAYdH6lOcFna7YgAD3zdF+l6ddoaFvmouqmY=; b=rgBCgjiItTacm5lccBX6nVf4iaksFNArdPcA1NpmActjQcps1uXEsP00Ua8ODMQi5E AD4tTvW9+CttZWs2aay5EzsxGHT/t+Ewq0SYwYfCzCufMi6ranfod0eK0ZFDMKiCMNkM bmPIcv+ZZDU3nTGPGyx8TXAOB+rs0lrz6SKY+WdWAVcaW8jfoA5TbCszCGybeKccfXH0 n9coLFzrWuABpDuoeZ/pldYz8nA32VPAFXlDjULHI8R/E/y+xZudgg4tLXT1YZ2ZzA42 QX3QhmOu3NQr3Tm+mi5sVYAUOsoBVSVdz2NyfeFNhaBg+S46ksV0r4G2oBe6WrXu1XYG 5/tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=qszHDjlL; 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 g20si27325710ejz.342.2021.10.18.22.32.17; Mon, 18 Oct 2021 22:32:41 -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=qszHDjlL; 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 S233819AbhJSFc2 (ORCPT + 99 others); Tue, 19 Oct 2021 01:32:28 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:20543 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233499AbhJSFcX (ORCPT ); Tue, 19 Oct 2021 01:32:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1634621411; x=1666157411; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=2IhHWawDAYdH6lOcFna7YgAD3zdF+l6ddoaFvmouqmY=; b=qszHDjlLdaNPfAv7wUtB96Jw9mIC3ETVzcpYcBO2dL9Sd25HyxUHjj4K RadSgUzpcNY92E755gh171PfZez3XTo2Q33Slbh73HhnxD3tL/WLQzMDo wlhP9qR+NH5O0jMscyLC/coxEFfJ7PuSo7BD2KxAslWY+U1cDio6TBeoJ I=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 18 Oct 2021 22:30:11 -0700 X-QCInternal: smtphost Received: from nalasex01c.na.qualcomm.com ([10.47.97.35]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2021 22:30:11 -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_GCM_SHA384) id 15.2.922.7; Mon, 18 Oct 2021 22:30:09 -0700 From: Fenglin Wu To: , , CC: , , , , Subject: [PATCH v2 06/10] spmi: pmic-arb: block access for invalid PMIC arbiter v5 SPMI writes Date: Tue, 19 Oct 2021 13:29:17 +0800 Message-ID: <1634621361-17155-7-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634621361-17155-1-git-send-email-quic_fenglinw@quicinc.com> References: <1634621361-17155-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 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 011044e..e83342a 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -1027,6 +1027,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