Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2951701rwb; Thu, 29 Sep 2022 18:08:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6kdxGbaIbT2uEKOkUWXUoBwbOt+9hjQEIF5n3ArhGLQz3GenqetGXBwccmnliQ+AzW8ZKx X-Received: by 2002:a17:907:7b9e:b0:783:10cb:2826 with SMTP id ne30-20020a1709077b9e00b0078310cb2826mr4847646ejc.208.1664500093643; Thu, 29 Sep 2022 18:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664500093; cv=none; d=google.com; s=arc-20160816; b=w+u5Lgr4qDGzc7jOmJhkSSR1vJ9pJxBuqplMEoocYxjJFEvS89hSBSbCO8qRD1W7DK mCGX7duKFckAo3xhvawov68EP4j2PcqUO0qMnyPrDFwZmpPwriUEW8iqyM++bufOD0XC NMo0GlwGbFY89AGNpzJKb56sEZTcGOfig9YNI40sCL9iTrmAnSZyEOGs3vhOwpv78f5L mibYP0oBaCnr5v16mmC/d/ZMZkTuvxocuHSArtt2VTX/98JjqMP9eVRMSQjkpbLXQCME esNX+umoa4WkBffs2rS19Rh+tDux7ewKY4ELe+9xeCudOE1m+egRpF2niPHtjYZWunT7 RhfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ezZ2A21aPy8KRV1pw48rFPwXGoXb5ysXeydFkJjvXU0=; b=pFuz64Bdfd1w3R2zUzyXumfugrPg+CsC+egm8Fe1vMSOuTyn4M3Q9GE5xWdDbkz1pg TZcD3U7lSkhI+Q0ORyYCaVvtXaJMR4J39Zhm88SylCffXYSWwr2QQAyWuFx0z8iVqVwM gyjlBvC2RoUpG1Jjmgyp1PGRg1r0U93jYgdsEDQqebUvLghF3bN6NdBlVGU5wO/Dp0Ke BQe5MMPeMJin859E77VN6b40qoPFiFzwy1zOI2h8dwnSWtK3cvN/SVQFZdddHgTRFKQ9 jV2qEDgRSMKxrppgouE0aSMVB+l4aYIZHBFoEJmRGO9peIGLts6B5StCr/H053ENkXWN DEAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E0uxHNa6; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x10-20020a05640225ca00b0044f441d2372si979799edb.88.2022.09.29.18.07.48; Thu, 29 Sep 2022 18:08:13 -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=@kernel.org header.s=k20201202 header.b=E0uxHNa6; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230055AbiI3AvK (ORCPT + 99 others); Thu, 29 Sep 2022 20:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbiI3Au3 (ORCPT ); Thu, 29 Sep 2022 20:50:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6EE25AA29 for ; Thu, 29 Sep 2022 17:50:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 863F7621FD for ; Fri, 30 Sep 2022 00:50:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34A5BC43140; Fri, 30 Sep 2022 00:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664499022; bh=oDmFdti2cyUR9jedMqIwc5dR+zlMJeHAAAri4fHdknQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E0uxHNa6VksjexCPd+S/8v/xU2CGnp2MW4FLz1zKR9D6fxbQ1CR7m6qd8zroWGm66 2CCCoKB3ZkuKmfmMQdjBlR2R2NhZvFJo0ApVuVp8fE4vWh0MKIkLnFxmQM/bYI7Mbg DxGVZbremckemw8j/DuV1szvsrl1KyOkvGMTEDHOQ+/vjmsX13ThrpDrV+4xCzGkgH GVrl9rhQnMdAr8NEwsuQKX5hwVZFer4/2beNKmpBRpCmI0hEai6bUwaJWaICXO4Xmq DfBsuRCdzsR1DN/PEkhl57BA4HnnrZW5LQXaNiyMqRe5Oi8qtFo8Q2KLTAX7spXcrC Kq5zEL7nx28jw== From: Stephen Boyd To: Greg Kroah-Hartman Cc: David Collins , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Fenglin Wu Subject: [PATCH 8/9] spmi: pmic-arb: block access for invalid PMIC arbiter v5 SPMI writes Date: Thu, 29 Sep 2022 17:50:17 -0700 Message-Id: <20220930005019.2663064-9-sboyd@kernel.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20220930005019.2663064-1-sboyd@kernel.org> References: <20220930005019.2663064-1-sboyd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Link: https://lore.kernel.org/r/1655004286-11493-8-git-send-email-quic_fenglinw@quicinc.com Signed-off-by: Stephen Boyd --- 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 cf92abc51689..39f25bc26233 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; } -- https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/ https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git