From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Kangjie Lu <kjlu@umn.edu>
Cc: Len Brown <lenb@kernel.org>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] acpi: fix potential race conditions bypassing checks
Date: Mon, 28 Oct 2019 21:51:22 +0100 [thread overview]
Message-ID: <3605712.hsAW26GfSv@kreacher> (raw)
In-Reply-To: <20191028183114.15709-1-kjlu@umn.edu>
On Monday, October 28, 2019 7:31:14 PM CET Kangjie Lu wrote:
> "obj" is a local variable. Elements are deep-copied from external
> package to obj and security-checked. The original code is
> seemingly fine; however, compilers optimize the deep copies into
> shallow copies, introducing potential race conditions. For
> example, the checks for type and length may be bypassed.
How exactly?
What compiler(s) do such optimizations in this particular case?
> The fix tells compilers to not optimize the deep copy by inserting
> "volatile".
Have you actually analyzed the object code produced by the compiler with and
without the volatile to determine whether or not it has an effect as expected
on code generation?
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/acpi/processor_throttling.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
> index 532a1ae3595a..6f4d86f8a9ce 100644
> --- a/drivers/acpi/processor_throttling.c
> +++ b/drivers/acpi/processor_throttling.c
> @@ -413,7 +413,7 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
> acpi_status status = 0;
> struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
> union acpi_object *ptc = NULL;
> - union acpi_object obj = { 0 };
> + volatile union acpi_object obj = { 0 };
> struct acpi_processor_throttling *throttling;
>
> status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer);
>
next prev parent reply other threads:[~2019-10-28 20:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-28 18:31 [PATCH] acpi: fix potential race conditions bypassing checks Kangjie Lu
2019-10-28 20:51 ` Rafael J. Wysocki [this message]
2019-10-28 21:32 ` Kangjie Lu
2019-11-13 22:43 ` Rafael J. Wysocki
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=3605712.hsAW26GfSv@kreacher \
--to=rjw@rjwysocki.net \
--cc=kjlu@umn.edu \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.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).