Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp272820iob; Thu, 28 Apr 2022 01:56:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwm3PtIHvCUPLaAhVA9PNQeQXjgwzPDTs2M+Fdr/DOZglMUYadXnJEa/rCQU+0UNmX94Mi2 X-Received: by 2002:a17:90b:38c8:b0:1d2:9a8f:e92 with SMTP id nn8-20020a17090b38c800b001d29a8f0e92mr48157548pjb.55.1651136200201; Thu, 28 Apr 2022 01:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651136200; cv=none; d=google.com; s=arc-20160816; b=UkZ3ojLvxkZbl3eiPzgoQadfBGmNPTBDheIavT0eqzWQ4GsB6sZsXjUi6NhbSe7AlS b5HZaiOmoXsRNMrn6PcZdYhHSBIIwxQtJNdGhRS0fsR9x+/50eNlLgq8jB8cdplL8duv aL7L83Vs5a+0OAtgICk48iLCwHS47/mmK/c3qI2f+rpZxQ1yWfs4KdWbRDATcim8/5ka 7nhZLHXICUcxjui4MM4IPsy2UaXTxv1gj4kZGSysscNdx6t8yHdK2kI5WeUVITmUwKcj P6QvvABEh8ivqH9jntZO1BrLiwVy1EBjSmXCAaFhpsWcIQa79+b/eKOe2p3J+aSo28m3 HsHA== 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=C/nKcvGohh66HEoXJpfjN/wkXoY3VldhRoiyN4/ZYtg=; b=gF+y6R9Ll6i6YOo8w2eEm1gZy8Dl+aTniJ8pESA1feWf2IN5tsNjzjOPvGQSBQAW4O 30ON0cAax21wT94xLRBIdPm6yFC3Sa2npUIaC1pRx43cjZSEErBEFIVX2XCZnJGo6fEP xn74qAEm4vl/hR7oDhLmBgsuPWZQHWAOKm+HIsPXFl5wZX8zsBCGFLckxhz33i6k+E9m VZqyW182RGNJRwcZ7NWxi0p7TbHdh86YJw9TjdSEAmCluc+wuckRUMcB6Kc79ONJY4dd OZmqGu3/9BlLYHjOQPGC7ClTtIiQikWtDip0mxRh1Hy5cFwdT7cbZZE2XXcS7qAjNpah vxHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=wftbr7sE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r123-20020a632b81000000b0039dd76b58e0si3925029pgr.687.2022.04.28.01.56.25; Thu, 28 Apr 2022 01:56:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=wftbr7sE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S240669AbiD1BQv (ORCPT + 99 others); Wed, 27 Apr 2022 21:16:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240523AbiD1BQi (ORCPT ); Wed, 27 Apr 2022 21:16:38 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F4E37E1FD; Wed, 27 Apr 2022 18:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1651108402; x=1682644402; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=C/nKcvGohh66HEoXJpfjN/wkXoY3VldhRoiyN4/ZYtg=; b=wftbr7sEBMYcGpocgo1FoMOijnA+sbl2hwECx+diC+dOM3zqNnbztqKB X4z5lniBL+hDtQf7jQ/f18c7Q1GdPUSwsCjt1elw2OGBI/pKfGsL/LkQX m4xM9ieK4lmRy23odEfZkqAwNWki+cTFuRPiRRxRfH2z0JOKB6s/tC2LH 8=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 27 Apr 2022 18:13:21 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2022 18:13:21 -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.986.22; Wed, 27 Apr 2022 18:13:21 -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.986.22; Wed, 27 Apr 2022 18:13:18 -0700 From: Fenglin Wu To: , , CC: , , , , , "David Collins" Subject: [RESEND PATCH V6 07/10] spmi: pmic-arb: block access for invalid PMIC arbiter v5 SPMI writes Date: Thu, 28 Apr 2022 09:12:46 +0800 Message-ID: <1651108369-11059-8-git-send-email-quic_fenglinw@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1651108369-11059-1-git-send-email-quic_fenglinw@quicinc.com> References: <1651108369-11059-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 nalasex01c.na.qualcomm.com (10.47.97.35) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 cf92abc..39f25bc 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -1133,6 +1133,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