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 C943FC432BE for ; Wed, 1 Sep 2021 10:59:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A598A61059 for ; Wed, 1 Sep 2021 10:59:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237050AbhIALAZ (ORCPT ); Wed, 1 Sep 2021 07:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234901AbhIALAY (ORCPT ); Wed, 1 Sep 2021 07:00:24 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D60ACC061575 for ; Wed, 1 Sep 2021 03:59:27 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id p2so3256466oif.1 for ; Wed, 01 Sep 2021 03:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kali.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=G6LAp5HJnMMBulLcTduMTFDBBN4X+d6st1y0rBkoHjI=; b=JYmnlaagx5Zk2F56Nt6fUBmVZc4PdvTqN/RjhOnP8hRH5OfLyJb9SFd4w/VrWlLIg0 n04z7nmHASMX3m7fQXNGSx8nVeC8TLx5nYrP4kJB0cEKRB2reSFXL5dIKlLNDgJo46Ze O8b+AM5K+HHjyNZqLDhp3ymGR2JtPkbzFWeERdBAtMj7FEa0AaY1/VDJ8ckZE7acB2kc Xj6PZ6+ZUnmDC81sT3XleDE0moHYrxuWRRsQeL/nPzTqi0cLOx+PI4mzvJOG7mrG4Ae/ wVe8VkRp1/l62QLZBCBJQZjDkQgslpr4klQqJGTz43VGthIgs22nUA0xNNvKkaO/q/vD VeBg== 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-transfer-encoding :content-language; bh=G6LAp5HJnMMBulLcTduMTFDBBN4X+d6st1y0rBkoHjI=; b=l6fBW8Omtkrlc1FxcZeRNIDKBPLTPNYAl4LuMqlcnZVDBLNzYFUZmyQ17i5GU5GOPh knTge4BET/FYLg2I754ekPFAiRPzG7wYmJhBtrf5HPmv5iW3axBWxQy2o54E9s2iv20C YZ9SnrSjlIkRbiFTw260WhbGhjBbqzNiBzLQNfwSS2bJUMrl3vYN8TNB1AH9icUGWq0H 7i/9th3FEq6NrX1m7QI60oIpRk3XCI4do/sAe/jr9yIYeTAJxyVLbfguVvt1TN9+zk7P benCpY9RKisQlJ8fdWlP0iES4tgyvGFDb5uLb4YBSnOQGu1f0/EePtQ27oyU/OsH7xWN zMDw== X-Gm-Message-State: AOAM5333D4Jc9LcqZEs4bS5pKoJkPAkfco46TtU4g2SHDpPm5gym040p +/elRMPgurMwV2QsjqNTWeaAVHuXQSiFJM69 X-Google-Smtp-Source: ABdhPJzy7jIT4KaxRczYWELxR5wi76ekj4LgeQ5xxVJHo2y6mlv4reu8N+VMffPQ6g7NUYfVjWvlCQ== X-Received: by 2002:a05:6808:81:: with SMTP id s1mr6809474oic.130.1630493967251; Wed, 01 Sep 2021 03:59:27 -0700 (PDT) Received: from MacBook-Pro.hackershack.net (cpe-173-173-107-246.satx.res.rr.com. [173.173.107.246]) by smtp.gmail.com with ESMTPSA id l44sm4331446otv.81.2021.09.01.03.59.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Sep 2021 03:59:26 -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: Thara Gopinath , Bjorn Andersson , Andy Gross , linux-arm-msm@vger.kernel.org References: <20210901084732.943248-1-ardb@kernel.org> From: Steev Klimaszewski Message-ID: <441ec7ff-3572-1294-e0cc-a142ff371051@kali.org> Date: Wed, 1 Sep 2021 05:59:25 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210901084732.943248-1-ardb@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On 9/1/21 3: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 > --- > 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; > } > I haven't experienced the crash here, but I also tested the patch on my C630, and still don't see the issue so, if you want: Tested-By: Steev Klimaszewski 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 EE8CDC432BE for ; Wed, 1 Sep 2021 11:30:21 +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 C189D60F6C for ; Wed, 1 Sep 2021 11:30:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C189D60F6C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kali.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-Transfer-Encoding:Content-Type: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=gcQz2TWUbnPBxzyY7JHNn0vDDk7LAEZxV/W7s4UwKpQ=; b=46v0YWEjjbglAe6xjXXohT+AWt SSR5BRSeJMBEoeTj/Jq1RQsmtGgZka/i85ImM9xHWLZsbWKLL3pkyhlkz2r6Qyn0eqG1D0X7cJvB0 eOji+YwZeypsEVGMHF6tX4uEesIDbfgbxtrZ3RVp4pArqQj5zmMKa6yWnIjhmGqvVrb6ATrzcIfar 4X76GaTl+M52ZnPtYIHY6mqKTmDFJj6aqDicTe8AMioXFqJJ+bYaAvPjoDNvPe7W+35NrOJ8J/8U1 whWyXI7RobC8VJwYYiI/uePFTZ4NFenleAQm8W4d3MAu2/gB1PTCKEQGN1ATLHjJbt6ld4mX+APPg nDkOpqOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLOP5-005Zv8-Oq; Wed, 01 Sep 2021 11:27:40 +0000 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLNxp-005OUo-C5 for linux-arm-kernel@lists.infradead.org; Wed, 01 Sep 2021 10:59:33 +0000 Received: by mail-oi1-x233.google.com with SMTP id v2so3210196oie.6 for ; Wed, 01 Sep 2021 03:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kali.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=G6LAp5HJnMMBulLcTduMTFDBBN4X+d6st1y0rBkoHjI=; b=JYmnlaagx5Zk2F56Nt6fUBmVZc4PdvTqN/RjhOnP8hRH5OfLyJb9SFd4w/VrWlLIg0 n04z7nmHASMX3m7fQXNGSx8nVeC8TLx5nYrP4kJB0cEKRB2reSFXL5dIKlLNDgJo46Ze O8b+AM5K+HHjyNZqLDhp3ymGR2JtPkbzFWeERdBAtMj7FEa0AaY1/VDJ8ckZE7acB2kc Xj6PZ6+ZUnmDC81sT3XleDE0moHYrxuWRRsQeL/nPzTqi0cLOx+PI4mzvJOG7mrG4Ae/ wVe8VkRp1/l62QLZBCBJQZjDkQgslpr4klQqJGTz43VGthIgs22nUA0xNNvKkaO/q/vD VeBg== 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-transfer-encoding :content-language; bh=G6LAp5HJnMMBulLcTduMTFDBBN4X+d6st1y0rBkoHjI=; b=qr7oBiv2YJ3sNaBWKwtlnxSzO7GJTqSVAeyeQmUqzZ1/Ef9TAIwexu73TlpS+fEpmS L0bQtfxd0URtfB6TgiuD00VkSZMqWf0zgg6lmMAUJ9/xmlEx2q6PD6saLxacvhP8lWoE uFPPWs35CVtkYRzs0KWcys4sCsXDWQz8O70tTrQREKknJGe7plisvslUXDuO+7Mf0i+X FQZd7fpI6IYrtkfOs60/X2Eznx8xuDHtVQQFJ0qzNVNSmJmOUJ+bOS8IxGwhufXHDw1E eYmpvshnZRyRNgOE7+nLhHo0wOEgcY7lrk7jqlaU89YZCdo9D3PjXcxoqUJlEshxNDme eAUw== X-Gm-Message-State: AOAM531guDk9XABXxRwDbjh1sVSnMY1xi2Tw1a2oPwx4xj7g8gFPnvz6 Aj2PpzuE+p+LOSHb4/hDosVMBg== X-Google-Smtp-Source: ABdhPJzy7jIT4KaxRczYWELxR5wi76ekj4LgeQ5xxVJHo2y6mlv4reu8N+VMffPQ6g7NUYfVjWvlCQ== X-Received: by 2002:a05:6808:81:: with SMTP id s1mr6809474oic.130.1630493967251; Wed, 01 Sep 2021 03:59:27 -0700 (PDT) Received: from MacBook-Pro.hackershack.net (cpe-173-173-107-246.satx.res.rr.com. [173.173.107.246]) by smtp.gmail.com with ESMTPSA id l44sm4331446otv.81.2021.09.01.03.59.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Sep 2021 03:59:26 -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: Thara Gopinath , Bjorn Andersson , Andy Gross , linux-arm-msm@vger.kernel.org References: <20210901084732.943248-1-ardb@kernel.org> From: Steev Klimaszewski Message-ID: <441ec7ff-3572-1294-e0cc-a142ff371051@kali.org> Date: Wed, 1 Sep 2021 05:59:25 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.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_035929_572253_DADA76F1 X-CRM114-Status: GOOD ( 24.63 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 9/1/21 3: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 > --- > 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; > } > I haven't experienced the crash here, but I also tested the patch on my C630, and still don't see the issue so, if you want: Tested-By: Steev Klimaszewski _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel