From: "Prakash, Prashanth" <pprakash@codeaurora.org>
To: Ashwin Chaugule <ashwin.chaugule@linaro.org>,
Sudeep Holla <sudeep.holla@arm.com>
Cc: linux acpi <linux-acpi@vger.kernel.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
lkml <linux-kernel@vger.kernel.org>,
linux-ia64@vger.kernel.org, x86@kernel.org,
Al Stone <al.stone@linaro.org>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Mahesh Sivasubramanian <msivasub@codeaurora.org>,
wufan@codeaurora.org
Subject: Re: [PATCH v2 5/5] ACPI / processor_idle: Add support for Low Power Idle(LPI) states
Date: Tue, 1 Dec 2015 10:23:50 -0700 [thread overview]
Message-ID: <565DD7A6.1000802@codeaurora.org> (raw)
In-Reply-To: <CAJ5Y-ebOPE1oamRk31nxL6VkgSdDd6AmEe2Fw1ku5pGt25D2Rg@mail.gmail.com>
Hi Sudeep,
>> +static void combine_lpi_states(struct acpi_processor_lpi *l_lpi,
>> + struct acpi_processor_lpi *p_lpi,
>> + struct acpi_processor_lpi *c_lpi)
>> +{
>> + c_lpi->min_residency = max(l_lpi->min_residency, p_lpi->min_residency);
>> + c_lpi->wake_latency = l_lpi->wake_latency + p_lpi->wake_latency;
>> + c_lpi->enable_parent_state = p_lpi->enable_parent_state;
>> + c_lpi->entry_method = l_lpi->entry_method;
>> + c_lpi->address = l_lpi->address + p_lpi->address;
>> + c_lpi->index = p_lpi->index;
>> + c_lpi->flags = p_lpi->flags;
>> + c_lpi->arch_flags = p_lpi->arch_flags;
>> + strncpy(c_lpi->desc, l_lpi->desc, ACPI_CX_DESC_LEN);
>> + strncat(c_lpi->desc, "+", ACPI_CX_DESC_LEN);
>> + strncat(c_lpi->desc, p_lpi->desc, ACPI_CX_DESC_LEN);
>> +}
I suppose you meant to use strl* instead of strn* operations. Below is a
simple patch to fix these. Can you please fold these changes into your next
version as well?
ACPI / Processor: fix buffer overflow caused by strncat/strncpy
The misuse of strncat in LPI code is causing buffer overflow. The fix
is to replace strncat with strlcat.
Signed-off-by: Fan Wu <wufan@codeaurora.org>
Signed-off-by: Prashanth Prakash <pprakash@codeaurora.org>
---
drivers/acpi/processor_idle.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index af851f1..4ca42a7 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -856,7 +856,7 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)
state = &drv->states[count];
snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i);
- strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
+ strlcpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
state->exit_latency = cx->latency;
state->target_residency = cx->latency * latency_factor;
state->enter = acpi_idle_enter;
@@ -1009,7 +1009,7 @@ static int acpi_processor_evaluate_lpi(acpi_handle handle,
obj = &element->package.elements[9];
if (obj->type == ACPI_TYPE_STRING)
- strncpy(lpix->desc, obj->string.pointer, ACPI_CX_DESC_LEN);
+ strlcpy(lpix->desc, obj->string.pointer, ACPI_CX_DESC_LEN);
lpix->index = state_count;
@@ -1068,9 +1068,9 @@ static void combine_lpi_states(struct acpi_processor_lpi *l_lpi,
c_lpi->index = p_lpi->index;
c_lpi->flags = p_lpi->flags;
c_lpi->arch_flags = p_lpi->arch_flags;
- strncpy(c_lpi->desc, l_lpi->desc, ACPI_CX_DESC_LEN);
- strncat(c_lpi->desc, "+", ACPI_CX_DESC_LEN);
- strncat(c_lpi->desc, p_lpi->desc, ACPI_CX_DESC_LEN);
+ strlcpy(c_lpi->desc, l_lpi->desc, ACPI_CX_DESC_LEN);
+ strlcat(c_lpi->desc, "+", ACPI_CX_DESC_LEN);
+ strlcat(c_lpi->desc, p_lpi->desc, ACPI_CX_DESC_LEN);
}
static int flatten_lpi_states(struct acpi_processor *pr,
@@ -1190,7 +1190,7 @@ static int acpi_processor_setup_lpi_states(struct acpi_processor *pr)
state = &drv->states[i];
snprintf(state->name, CPUIDLE_NAME_LEN, "LPI-%d", i);
- strncpy(state->desc, lpi->desc, CPUIDLE_DESC_LEN);
+ strlcpy(state->desc, lpi->desc, CPUIDLE_DESC_LEN);
state->exit_latency = lpi->wake_latency;
state->target_residency = lpi->min_residency;
if (lpi->arch_flags)
--
1.8.2.1
next prev parent reply other threads:[~2015-12-01 17:23 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 17:46 [PATCH 0/4] ACPI / core : few cleanups and updates for LPI Sudeep Holla
2015-08-04 17:46 ` [PATCH 1/4] ACPI / processor : add support for ACPI0010 processor container Sudeep Holla
2015-08-04 17:46 ` [PATCH 2/4] ACPI / sleep: move acpi_processor_sleep to sleep.c Sudeep Holla
2015-08-04 17:46 ` [PATCH 3/4] ACPI / processor_idle: replace PREFIX with pr_fmt Sudeep Holla
2015-08-04 17:46 ` [PATCH 4/4] ACPI / processor_idle : introduce ARCH_SUPPORTS_ACPI_PROCESSOR_CSTATE Sudeep Holla
2015-09-16 13:59 ` [PATCH v2 0/5] ACPI / processor_idle: Add ACPIv6.0 LPI support Sudeep Holla
2015-09-16 13:59 ` [PATCH v2 1/5] ACPI / processor : add support for ACPI0010 processor container Sudeep Holla
2015-09-16 13:59 ` [PATCH v2 2/5] ACPI / sleep: move acpi_processor_sleep to sleep.c Sudeep Holla
2015-09-16 13:59 ` [PATCH v2 3/5] ACPI / processor_idle: replace PREFIX with pr_fmt Sudeep Holla
2015-09-16 13:59 ` [PATCH v2 4/5] ACPI / processor_idle : introduce ARCH_SUPPORTS_ACPI_PROCESSOR_CSTATE Sudeep Holla
2015-09-24 10:31 ` Ashwin Chaugule
2015-09-24 13:05 ` Sudeep Holla
2015-09-16 13:59 ` [PATCH v2 5/5] ACPI / processor_idle: Add support for Low Power Idle(LPI) states Sudeep Holla
2015-10-02 17:07 ` Ashwin Chaugule
2015-10-26 19:13 ` Ashwin Chaugule
[not found] ` <562EC3A5.2070402@codeaurora.org>
2015-10-27 14:09 ` Sudeep Holla
2015-11-19 22:03 ` Prakash, Prashanth
2015-11-26 11:09 ` Sudeep Holla
2015-12-01 17:23 ` Prakash, Prashanth [this message]
2015-12-01 17:43 ` Sudeep Holla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=565DD7A6.1000802@codeaurora.org \
--to=pprakash@codeaurora.org \
--cc=al.stone@linaro.org \
--cc=ashwin.chaugule@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=msivasub@codeaurora.org \
--cc=rjw@rjwysocki.net \
--cc=sudeep.holla@arm.com \
--cc=wufan@codeaurora.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).