public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexey Starikovskiy <astarikovskiy@suse.de>
To: LenBrown <lenb@kernel.org>
Cc: Linux-acpi@vger.kernel.org
Subject: [PATCH] ACPICA: Add hard limit to while loop
Date: Thu, 09 Oct 2008 14:35:39 +0400	[thread overview]
Message-ID: <20081009103539.1238.81357.stgit@thinkpad> (raw)

We need to prevent infinite loops and lockups

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
---

 drivers/acpi/dispatcher/dsopcode.c |    9 +++++++--
 include/acpi/acstruct.h            |    1 +
 2 files changed, 8 insertions(+), 2 deletions(-)


diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c
index 6a81c44..e2a3535 100644
--- a/drivers/acpi/dispatcher/dsopcode.c
+++ b/drivers/acpi/dispatcher/dsopcode.c
@@ -1246,8 +1246,13 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
 		if (walk_state->control_state->common.value) {
 
 			/* Predicate was true, go back and evaluate it again! */
-
-			status = AE_CTRL_PENDING;
+			/* Use hard limit to prevent infinite loops and lockups */
+			if (++walk_state->cycle_count > 0xFFFF) {
+				status = AE_LIMIT;
+				ACPI_ERROR ((AE_INFO, "Infinite loop detected"));
+			} else {
+				status = AE_CTRL_PENDING;
+			}
 		}
 
 		ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h
index 7980a26..fb4405e 100644
--- a/include/acpi/acstruct.h
+++ b/include/acpi/acstruct.h
@@ -94,6 +94,7 @@ struct acpi_walk_state {
 	u32 method_breakpoint;	/* For single stepping */
 	u32 user_breakpoint;	/* User AML breakpoint */
 	u32 parse_flags;
+	u32 cycle_count;	/* While loop cycle count */
 
 	struct acpi_parse_state parser_state;	/* Current state of parser */
 	u32 prev_arg_types;


             reply	other threads:[~2008-10-09 10:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-09 10:35 Alexey Starikovskiy [this message]
2008-10-09 12:28 ` [PATCH] ACPICA: Add hard limit to while loop Moore, Robert
2008-10-09 14:55 ` Moore, Robert
2008-10-09 16:15   ` Moore, Robert
2008-10-09 16:32     ` Len Brown
2008-10-09 16:49       ` Moore, Robert
2008-10-09 17:42         ` Alexey Starikovskiy
2008-10-09 17:38     ` Alexey Starikovskiy

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=20081009103539.1238.81357.stgit@thinkpad \
    --to=astarikovskiy@suse.de \
    --cc=Linux-acpi@vger.kernel.org \
    --cc=lenb@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