From patchwork Wed Jan 18 15:08:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 45324 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2390539wrn; Wed, 18 Jan 2023 07:11:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXsms0THlVhnZOW6RmM3Jyst1ONdTExn5ir3wAcxbDVtaLEqV/qjDXdoDa+LtlJiovrlJnF1 X-Received: by 2002:a05:6a00:4c85:b0:58d:dfb1:8023 with SMTP id eb5-20020a056a004c8500b0058ddfb18023mr4835714pfb.15.1674054700560; Wed, 18 Jan 2023 07:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674054700; cv=none; d=google.com; s=arc-20160816; b=CuLGT6GyCaJ2h3OdZrE7vIsdjb8FU1kZZ1mCV1ehCXSNZN7qE9bVbJAvEkBXXAfYjL you1pMSgxrGgdBtXKltCwuH8+l3Mfq4HpkkV6SY5q+/De9iyXkRgbuiXtYqStX7H+L2Y G9fRsIDIT76ei1i/6IBwt+gt4eMLCRAsJ60QwD64WTlFQWQGRPgfoXTYLiVNW8BEgxkU 1mlE1IesD+OJ3vV1WXKcBeQbUsFlB+ttOhLpWK7YWTuQirGPRaaXMrcqYw2K2PSdBVfl RmaTa+Q85N1gUY9Amwq5MNHMPWcTxtdnSzKcB7h1DmZnpB0SfCcI1n6fPYBLa0XW3wrz Jpqw== 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=9g1r2YkbrCTL06JBn8TcdxJnLCnZpZqC+qdq6jkkxOk=; b=VUYgZIDrGF1gvMHd3NzWNe4SrmmQ4e6aE9rQWT6BmhZlXdDzQ95WeZAo/hcxGGFOxt F60XZg+C3+9jPDhR3xeKxNDF+AOzqlxC84zjxAeiNkj9EJ0nHzbXXjZlHVE8yyyKSLNT tdi57ZG5jjq8NsHbUdtihb4Bwa6KaSkGBi02dnLipuJftWJr2ECROR7qy6O6v2iLHD+Q ZNe/RBf8ef3c6zwu7HFVoL0K/5HSFiW9J95YziXEL1+KXIhZvYLXNTZdSeP8CWKXNf6/ vFNJaK1ucDHIYZ+w6ZO6EqSScUsNCZShQk2IoI+6pEPMnGL9VzVVKYPnQK7JaTF//yVf x67Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rmGHhTlj; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u18-20020a056a00125200b00572f3be59f6si35580731pfi.136.2023.01.18.07.11.28; Wed, 18 Jan 2023 07:11:40 -0800 (PST) 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=@linaro.org header.s=google header.b=rmGHhTlj; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231686AbjARPKb (ORCPT + 99 others); Wed, 18 Jan 2023 10:10:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231582AbjARPJb (ORCPT ); Wed, 18 Jan 2023 10:09:31 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F351A23333 for ; Wed, 18 Jan 2023 07:09:30 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id s3so23880459pfd.12 for ; Wed, 18 Jan 2023 07:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9g1r2YkbrCTL06JBn8TcdxJnLCnZpZqC+qdq6jkkxOk=; b=rmGHhTlj8O6W1yPAhd3uk2Ho8WDQV2ls8DgNFrQvHO8xa5RrlA6ALv/tHMw3UtegjW uqKI8SSb5ozUimyYj7w3LSV61Kuk7og8suQrm1s2/uBYGWx1E8e8+UTZWwXFYUkb9eEL lo4+CJxoKxTh9NmrYfhJ8cQFpyT9/yvaUSXXInOg50ZEnzW3wCzXGWjkf/N2pSJxrcnx O2lXZ3BPh1lMOkLCDCqNEQTA5yPe7iKk5Q2QO7A1+syXPfPEX9xHDqByGpjF2QPNeACx NJKYI778puEQkLpRby0cQlida5hNSZRwwTyoxlUd4xBBmwuL+76wvu9c/ou2wdGNsAkc q7vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9g1r2YkbrCTL06JBn8TcdxJnLCnZpZqC+qdq6jkkxOk=; b=KVFdVkk+9JCi0wwdPQ8DW3Pkwn6O8D3lRndwuL0LKPF6Sk1LIzOJUoto2dhoOyYtlk BV0rBY6rgpQP9f8lId4EQvRdJEiqCooi4YkPs33efLwF+Ln797ngtOGPQjAZM/VXLkJK Gwjs0B+Vyjm7e+KqitS4/emSDwkVzDynfaY26BU3UT/H2fLDzGqtNVUFo5iDNTeVLFQm erOM3df1+H4lZV0u6g/gPmTSplrImMVJzHc6VRIt52g2Z/dvuN0vo64YfaJ43eMKloph b1J0exe76BH0jUc8chC7b8azC97UDW77R7kvXskjlUl9hqZoGlHPNpBjAEu4LFotmIMU nkuA== X-Gm-Message-State: AFqh2kpWGZ3vOniCRq8K69Ns3vjGXArOby0hyOHADATDYAxbC+LMeAZt LUv8uab04V13eC0cXZpcGwP8 X-Received: by 2002:aa7:9a50:0:b0:589:b85:1e32 with SMTP id x16-20020aa79a50000000b005890b851e32mr7763285pfj.16.1674054570482; Wed, 18 Jan 2023 07:09:30 -0800 (PST) Received: from localhost.localdomain ([27.111.75.61]) by smtp.gmail.com with ESMTPSA id i15-20020aa796ef000000b0058d9623e7f1sm6721544pfq.73.2023.01.18.07.09.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 07:09:29 -0800 (PST) From: Manivannan Sadhasivam To: andersson@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, bp@alien8.de, tony.luck@intel.com Cc: quic_saipraka@quicinc.com, konrad.dybcio@linaro.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, james.morse@arm.com, mchehab@kernel.org, rric@kernel.org, linux-edac@vger.kernel.org, quic_ppareek@quicinc.com, luca.weiss@fairphone.com, ahalaney@redhat.com, steev@kali.org, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH v6 03/17] EDAC/qcom: Do not pass llcc_driv_data as edac_device_ctl_info's pvt_info Date: Wed, 18 Jan 2023 20:38:50 +0530 Message-Id: <20230118150904.26913-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118150904.26913-1-manivannan.sadhasivam@linaro.org> References: <20230118150904.26913-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755373581812338039?= X-GMAIL-MSGID: =?utf-8?q?1755373581812338039?= The memory for "llcc_driv_data" is allocated by the LLCC driver. But when it is passed as "pvt_info" to the EDAC core, it will get freed during the qcom_edac driver release. So when the qcom_edac driver gets probed again, it will try to use the freed data leading to the use-after-free bug. Hence, do not pass "llcc_driv_data" as pvt_info but rather reference it using the "platform_data" in the qcom_edac driver. Cc: # 4.20 Fixes: 27450653f1db ("drivers: edac: Add EDAC driver support for QCOM SoCs") Tested-by: Steev Klimaszewski # Thinkpad X13s Tested-by: Andrew Halaney # sa8540p-ride Reported-by: Steev Klimaszewski Reviewed-by: Borislav Petkov (AMD) Signed-off-by: Manivannan Sadhasivam --- drivers/edac/qcom_edac.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/edac/qcom_edac.c b/drivers/edac/qcom_edac.c index 9e77fa84e84f..3256254c3722 100644 --- a/drivers/edac/qcom_edac.c +++ b/drivers/edac/qcom_edac.c @@ -252,7 +252,7 @@ dump_syn_reg_values(struct llcc_drv_data *drv, u32 bank, int err_type) static int dump_syn_reg(struct edac_device_ctl_info *edev_ctl, int err_type, u32 bank) { - struct llcc_drv_data *drv = edev_ctl->pvt_info; + struct llcc_drv_data *drv = edev_ctl->dev->platform_data; int ret; ret = dump_syn_reg_values(drv, bank, err_type); @@ -289,7 +289,7 @@ static irqreturn_t llcc_ecc_irq_handler(int irq, void *edev_ctl) { struct edac_device_ctl_info *edac_dev_ctl = edev_ctl; - struct llcc_drv_data *drv = edac_dev_ctl->pvt_info; + struct llcc_drv_data *drv = edac_dev_ctl->dev->platform_data; irqreturn_t irq_rc = IRQ_NONE; u32 drp_error, trp_error, i; int ret; @@ -358,7 +358,6 @@ static int qcom_llcc_edac_probe(struct platform_device *pdev) edev_ctl->dev_name = dev_name(dev); edev_ctl->ctl_name = "llcc"; edev_ctl->panic_on_ue = LLCC_ERP_PANIC_ON_UE; - edev_ctl->pvt_info = llcc_driv_data; rc = edac_device_add_device(edev_ctl); if (rc)