From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B21DCC432BE for ; Wed, 1 Sep 2021 19:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E91D6109E for ; Wed, 1 Sep 2021 19:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344574AbhIATYA (ORCPT ); Wed, 1 Sep 2021 15:24:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344595AbhIATYA (ORCPT ); Wed, 1 Sep 2021 15:24:00 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C10BC061575 for ; Wed, 1 Sep 2021 12:23:03 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id 2so714463qtw.1 for ; Wed, 01 Sep 2021 12:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=PNSj3S3zepNDk0huxSqEYDStv1BaVNx7txAZ5A/RtYA=; b=GCe9AH6PK5n84wZn3bz8shHLZ3ncukDMdJqhJhfy6RSOkgVV+ss05++fY7xP1r3gh9 5f0g5LUtRlEIvjgnugGF2UBNOpBQp/nxnTW7PRYB11cNpMXrrfR5Elg5dTi4zdF+sm/t +2dpZeBpYcVXb6uTg9OFYB3wTZHrHA5sii7s5Y/tKeq1sXr8xHdUcCltUcVI1pKlX7bo siB8X10sAfatqGhgZzLtJlLCDB0t8CWpNHKP61aTb4sA/dGRt5QkPyZ4Y6OTCyDDJS3X 5pAhV0U+NJDIsmsheMFTW+FtcagsAUg5LwJiRmf3tJfcx/z+nvuMn5EU4sLUm3Rxjr2Q EH1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=PNSj3S3zepNDk0huxSqEYDStv1BaVNx7txAZ5A/RtYA=; b=NfiHY6szmttaNnA61WmSiuBk7/R8CdOml8ZcDPTcVq8Fo42S12uJ7mETlKCfY9+cyn JsG6uig0oYMejqzlOo+HQqilWP60rbLpYe6mZTwApooOfp+ac8xQkLqiZt9MWxtW9N0O O8Y/chZuAp80dStBMeLPf01Koy/a9+ZTtc/SeP++oairf8MO32EVe7gigT4La37smGPa f9vJJrf/f9MQqM2JD6alSOPi5reVxzOCqeuVs4Abv4/rqgltffvh+K3EvjX5mKDZc0Qn KV8iQWz4944+jsI62Gc05UTQ0aMk0sXc+Y2vV8l33fP1FgDn9H2iDIBqdT8hRuYPZeOA qosA== X-Gm-Message-State: AOAM532BbpJX9t/+u3rK+lcexgxwujmsRXoztcZKN8oA07U1IGpRj3MV 3ta/Dx1G7w8qBQgNIX8v509KaUCgZ79HKA== X-Google-Smtp-Source: ABdhPJxRfAtsOcUjsEj8j9HdsdrMVuox3ur7DiYI0dxvCYKAMtNpNVJdqHhKRPeZcOb6jD3KoLjNpw== X-Received: by 2002:ac8:1195:: with SMTP id d21mr983941qtj.267.1630524177124; Wed, 01 Sep 2021 12:22:57 -0700 (PDT) Received: from [192.168.1.93] (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.gmail.com with ESMTPSA id 102sm476652qtc.62.2021.09.01.12.22.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Sep 2021 12:22:56 -0700 (PDT) Subject: Re: [PATCH] cpufreq: qcom-cpufreq-hw: Avoid stack buffer for IRQ name To: Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Cc: Bjorn Andersson , Andy Gross , linux-arm-msm@vger.kernel.org References: <20210901084732.943248-1-ardb@kernel.org> From: Thara Gopinath Message-ID: <5bdf0bb1-150b-6b60-6f9d-86542b4d7695@linaro.org> Date: Wed, 1 Sep 2021 15:22:55 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210901084732.943248-1-ardb@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On 9/1/21 4:47 AM, Ard Biesheuvel wrote: > Registering an IRQ requires the string buffer containing the name to > remain allocated, as the name is not copied into another buffer. > > So let's add a irq_name field to the data struct instead, which is > guaranteed to have the appropriate lifetime. > > Cc: Thara Gopinath > Cc: Bjorn Andersson > Cc: Andy Gross > Cc: linux-arm-msm@vger.kernel.org > Signed-off-by: Ard Biesheuvel Thanks for the fix. Reviewed-by: Thara Gopinath -- Warm Regards Thara (She/Her/Hers) > --- > I'm not following msm development closely, so apologies if this was > already fixed, or if this is not based on the right tree. > > This fixes a crash on my Yoga C630 when reading /proc/interrupts. > > drivers/cpufreq/qcom-cpufreq-hw.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c > index 3cc27d9e2ed1..6613228fe68c 100644 > --- a/drivers/cpufreq/qcom-cpufreq-hw.c > +++ b/drivers/cpufreq/qcom-cpufreq-hw.c > @@ -44,6 +44,7 @@ struct qcom_cpufreq_data { > /* Lock to synchronize between de-init sequence and re-starting LMh polling/interrupts */ > spinlock_t throttle_lock; > int throttle_irq; > + char irq_name[15]; > bool cancel_throttle; > }; > > @@ -371,7 +372,6 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index) > { > struct qcom_cpufreq_data *data = policy->driver_data; > struct platform_device *pdev = cpufreq_get_driver_data(); > - char irq_name[15]; > int ret; > > /* > @@ -388,11 +388,11 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index) > spin_lock_init(&data->throttle_lock); > INIT_DEFERRABLE_WORK(&data->throttle_work, qcom_lmh_dcvs_poll); > > - snprintf(irq_name, sizeof(irq_name), "dcvsh-irq-%u", policy->cpu); > + snprintf(data->irq_name, sizeof(data->irq_name), "dcvsh-irq-%u", policy->cpu); > ret = request_threaded_irq(data->throttle_irq, NULL, qcom_lmh_dcvs_handle_irq, > - IRQF_ONESHOT, irq_name, data); > + IRQF_ONESHOT, data->irq_name, data); > if (ret) { > - dev_err(&pdev->dev, "Error registering %s: %d\n", irq_name, ret); > + dev_err(&pdev->dev, "Error registering %s: %d\n", data->irq_name, ret); > return 0; > } > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 612CFC432BE for ; Wed, 1 Sep 2021 19:26:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2DF9E6109E for ; Wed, 1 Sep 2021 19:26:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2DF9E6109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gwwAEN8jFrmKqCUFMCdVgmSvi/FcQNOaAVbiXiK0iNk=; b=4OXLj0bFYi4Ao/iwj6FBe5xkrR HqL07qbqboZ+2of8qrTyQxLteqpSWkCIT1p7yRNGuL25BsRtht5FX1zeul4Y7NCVwUZeqOFLJ1eCN Bun0o72bXDe8y2NRIx7uro+OG/YT0ILJkkuaLXqdopaz8qRzwI0nCHy+Nf8WSOgj5fTG1BCBint+t uFUDlxNc0XHd4sXkXMAZxIoooR/cqlcMm/xzDBqUneJMd44Ibek+mycnKa5c/vmyrnF26aHYqckqz +wsdZIb1bGeaB9oCyicovD/+5ONksoEhSQK6SKAJkO5U41cMgULnIPd53/ORjrTLU7PuejUsLrkBR uZ5BLNRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLVpB-0074zU-Qb; Wed, 01 Sep 2021 19:23:05 +0000 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLVp5-0074wX-9v for linux-arm-kernel@lists.infradead.org; Wed, 01 Sep 2021 19:23:03 +0000 Received: by mail-qt1-x835.google.com with SMTP id t35so692723qtc.6 for ; Wed, 01 Sep 2021 12:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=PNSj3S3zepNDk0huxSqEYDStv1BaVNx7txAZ5A/RtYA=; b=GCe9AH6PK5n84wZn3bz8shHLZ3ncukDMdJqhJhfy6RSOkgVV+ss05++fY7xP1r3gh9 5f0g5LUtRlEIvjgnugGF2UBNOpBQp/nxnTW7PRYB11cNpMXrrfR5Elg5dTi4zdF+sm/t +2dpZeBpYcVXb6uTg9OFYB3wTZHrHA5sii7s5Y/tKeq1sXr8xHdUcCltUcVI1pKlX7bo siB8X10sAfatqGhgZzLtJlLCDB0t8CWpNHKP61aTb4sA/dGRt5QkPyZ4Y6OTCyDDJS3X 5pAhV0U+NJDIsmsheMFTW+FtcagsAUg5LwJiRmf3tJfcx/z+nvuMn5EU4sLUm3Rxjr2Q EH1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=PNSj3S3zepNDk0huxSqEYDStv1BaVNx7txAZ5A/RtYA=; b=oc2pvIR5rl3QZOOlBjgrsMO+0EWfyydW6z0BWAB1lY8abRfasJVHP3x6OkFj/h8JZ7 84qpP+TtaqhF0UmdQ6qUqyAAHx+GK0fn5/LYZR3sP9alJ4wcTYFSqZ6HgPDnlMbLxHJT aA2KeQjIIEYXxW4n6mEQ7OOGGSSxXEYWdmyz9ERjmigIaB6Jiyesypp6HCwXPyolVCcm 0/8Wn3QDiEG3C+ZtdMIYsfhmxcRKF8D5X/XwgfXasiiEMytH1dUwWVQBUf5tIVPWtrGq PQ/+dqBxqJelrqyQ7ZLt9DNgoOQ4zH2n8Fcs/6n4v73KV5RvABsfN59TnXfagUb/M19j ZHuA== X-Gm-Message-State: AOAM533FadGpSw3lMMfjRItj8w0YgZuev8uFth2c/vU/gt1FuKNLHcQT euTpYxOrwD1FkbxA7K490vsxbw== X-Google-Smtp-Source: ABdhPJxRfAtsOcUjsEj8j9HdsdrMVuox3ur7DiYI0dxvCYKAMtNpNVJdqHhKRPeZcOb6jD3KoLjNpw== X-Received: by 2002:ac8:1195:: with SMTP id d21mr983941qtj.267.1630524177124; Wed, 01 Sep 2021 12:22:57 -0700 (PDT) Received: from [192.168.1.93] (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.gmail.com with ESMTPSA id 102sm476652qtc.62.2021.09.01.12.22.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Sep 2021 12:22:56 -0700 (PDT) Subject: Re: [PATCH] cpufreq: qcom-cpufreq-hw: Avoid stack buffer for IRQ name To: Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Cc: Bjorn Andersson , Andy Gross , linux-arm-msm@vger.kernel.org References: <20210901084732.943248-1-ardb@kernel.org> From: Thara Gopinath Message-ID: <5bdf0bb1-150b-6b60-6f9d-86542b4d7695@linaro.org> Date: Wed, 1 Sep 2021 15:22:55 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210901084732.943248-1-ardb@kernel.org> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210901_122259_433247_A95ADE34 X-CRM114-Status: GOOD ( 24.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 9/1/21 4:47 AM, Ard Biesheuvel wrote: > Registering an IRQ requires the string buffer containing the name to > remain allocated, as the name is not copied into another buffer. > > So let's add a irq_name field to the data struct instead, which is > guaranteed to have the appropriate lifetime. > > Cc: Thara Gopinath > Cc: Bjorn Andersson > Cc: Andy Gross > Cc: linux-arm-msm@vger.kernel.org > Signed-off-by: Ard Biesheuvel Thanks for the fix. Reviewed-by: Thara Gopinath -- Warm Regards Thara (She/Her/Hers) > --- > I'm not following msm development closely, so apologies if this was > already fixed, or if this is not based on the right tree. > > This fixes a crash on my Yoga C630 when reading /proc/interrupts. > > drivers/cpufreq/qcom-cpufreq-hw.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c > index 3cc27d9e2ed1..6613228fe68c 100644 > --- a/drivers/cpufreq/qcom-cpufreq-hw.c > +++ b/drivers/cpufreq/qcom-cpufreq-hw.c > @@ -44,6 +44,7 @@ struct qcom_cpufreq_data { > /* Lock to synchronize between de-init sequence and re-starting LMh polling/interrupts */ > spinlock_t throttle_lock; > int throttle_irq; > + char irq_name[15]; > bool cancel_throttle; > }; > > @@ -371,7 +372,6 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index) > { > struct qcom_cpufreq_data *data = policy->driver_data; > struct platform_device *pdev = cpufreq_get_driver_data(); > - char irq_name[15]; > int ret; > > /* > @@ -388,11 +388,11 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index) > spin_lock_init(&data->throttle_lock); > INIT_DEFERRABLE_WORK(&data->throttle_work, qcom_lmh_dcvs_poll); > > - snprintf(irq_name, sizeof(irq_name), "dcvsh-irq-%u", policy->cpu); > + snprintf(data->irq_name, sizeof(data->irq_name), "dcvsh-irq-%u", policy->cpu); > ret = request_threaded_irq(data->throttle_irq, NULL, qcom_lmh_dcvs_handle_irq, > - IRQF_ONESHOT, irq_name, data); > + IRQF_ONESHOT, data->irq_name, data); > if (ret) { > - dev_err(&pdev->dev, "Error registering %s: %d\n", irq_name, ret); > + dev_err(&pdev->dev, "Error registering %s: %d\n", data->irq_name, ret); > return 0; > } > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel