From: Vishal Verma <vishal.l.verma@intel.com>
To: linux-nvdimm@lists.01.org
Cc: linux-acpi@vger.kernel.org,
Dan Williams <dan.j.williams@intel.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Toshi Kani <toshi.kani@hpe.com>, Elliott Robert <elliott@hpe.com>,
Vishal Verma <vishal.l.verma@intel.com>
Subject: [PATCH v2 1/2] nfit: in acpi_nfit_init, break on a 0-length table
Date: Wed, 14 Oct 2015 17:04:25 -0600 [thread overview]
Message-ID: <1444863866-19173-2-git-send-email-vishal.l.verma@intel.com> (raw)
In-Reply-To: <1444863866-19173-1-git-send-email-vishal.l.verma@intel.com>
If acpi_nfit_init is called (such as from nfit_test), with an nfit table
that has more memory allocated than it needs (and a similarly large
'size' field, add_tables would happily keep adding null SPA Range tables
filling up all available memory.
Make it friendlier by breaking out if a 0-length header is found in any
of the tables.
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: <linux-acpi@vger.kernel.org>
Cc: <linux-nvdimm@lists.01.org>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
drivers/acpi/nfit.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
index c1b8d03..35b4b56 100644
--- a/drivers/acpi/nfit.c
+++ b/drivers/acpi/nfit.c
@@ -335,6 +335,12 @@ static void *add_table(struct acpi_nfit_desc *acpi_desc, void *table,
return NULL;
hdr = table;
+ if (!hdr->length) {
+ dev_warn(dev, "found a zero length table '%d' parsing nfit\n",
+ hdr->type);
+ return NULL;
+ }
+
switch (hdr->type) {
case ACPI_NFIT_TYPE_SYSTEM_ADDRESS:
if (!add_spa(acpi_desc, table))
--
2.4.3
next prev parent reply other threads:[~2015-10-14 23:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-14 23:04 [PATCH v2 0/2] Hotplug support for libnvdimm Vishal Verma
2015-10-14 23:04 ` Vishal Verma [this message]
2015-10-14 23:04 ` [PATCH v2 2/2] acpi: nfit: Add support for hot-add Vishal Verma
2015-10-16 22:23 ` Verma, Vishal L
2015-10-20 2:02 ` Dan Williams
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=1444863866-19173-2-git-send-email-vishal.l.verma@intel.com \
--to=vishal.l.verma@intel.com \
--cc=dan.j.williams@intel.com \
--cc=elliott@hpe.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=rafael.j.wysocki@intel.com \
--cc=toshi.kani@hpe.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;
as well as URLs for NNTP newsgroup(s).