public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: robert.moore@intel.com
Cc: linux-acpi@vger.kernel.org, devel@acpica.org
Subject: re: ACPICA: Resource Mgr: Prevent infinite loops in resource walks
Date: Thu, 17 Oct 2013 15:28:50 +0300	[thread overview]
Message-ID: <20131017122850.GA24755@longonot.mountain> (raw)

Hello Bob Moore,

The patch c13085e519e8: "ACPICA: Resource Mgr: Prevent infinite loops 
in resource walks" from Mar 8, 2013 is not beautiful.  My static checker
complains about the loop because:
"drivers/acpi/acpica/rscalc.c:197 acpi_rs_get_aml_length()
	 warn: 'resource' can't be NULL."

drivers/acpi/acpica/rscalc.c
   195          /* Traverse entire list of internal resource descriptors */
   196  
   197          while (resource) {
                       ^^^^^^^^

My static checker is wrong because we use the -fno-strict-overflow to
prevent GCC from optimizing this check away.  But we are looping over
a list of pointers until our pointer wraps to NULL.  In other words we
loop over all the 2**64 - 1 addresses until we wrap to NULL or we find
something with an invalid type or something with ->length zero.

I assume the last element in the list always has length zero?  If so
then we could replace "while (resource)" with "while (resource->length)"

   198  
   199                  /* Validate the descriptor type */
   200  
   201                  if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
   202                          return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
   203                  }
   204  
   205                  /* Sanity check the length. It must not be zero, or we loop forever */
   206  
   207                  if (!resource->length) {
   208                          return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
   209                  }
   210  
   211                  /* Get the base size of the (external stream) resource descriptor */
   212  

regards,
dan carpenter


             reply	other threads:[~2013-10-17 12:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-17 12:28 Dan Carpenter [this message]
2013-10-22 21:36 ` ACPICA: Resource Mgr: Prevent infinite loops in resource walks Moore, Robert
2013-10-23  6:06   ` [Devel] " Zheng, Lv
2013-10-23  9:25     ` Dan Carpenter

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=20131017122850.GA24755@longonot.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=devel@acpica.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=robert.moore@intel.com \
    /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