From: Kent Yoder <key@linux.vnet.ibm.com>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org, tpmdd-devel@lists.sourceforge.net,
Sirrix AG <tpmdd@sirrix.com>,
Marcel Selhorst <tpmdd@selhorst.net>,
Rajiv Andrade <mail@srajiv.net>,
Seiji Munetoh <munetoh@jp.ibm.com>,
Stefan Berger <stefanb@us.ibm.com>,
Reiner Sailer <sailer@watson.ibm.com>,
Kylene Hall <kjhall@us.ibm.com>
Subject: Re: [PATCH] tpm: Do not dereference NULL pointer if acpi_os_map_memory() fails.
Date: Thu, 16 Aug 2012 10:45:07 -0500 [thread overview]
Message-ID: <20120816154507.GA3850@linux.vnet.ibm.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1208160011160.7818@swampdragon.chaosbits.net>
On Thu, Aug 16, 2012 at 12:16:33AM +0200, Jesper Juhl wrote:
> In drivers/char/tpm/tpm_acpi.c::read_log() we call
> acpi_os_map_memory(). That call may fail for a number of reasons
> (invalid address, out of memory etc). If the call fails it returns
> NULL and we just pass that to memcpy() unconditionally, which will go
> bad when it tries to dereference the pointer.
>
> Unfortunately we just get NULL back, so we can't really tell the user
> exactely what went wrong, but we can at least avoid crashing and
> return an error (-EIO seemed more generic and more suitable here than
> -ENOMEM or something else, so I picked that).
Thanks Jesper, applied here:
git://github.com/shpedoikal/linux.git v3.6-rc1-tpmdd-staging
Kent
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> drivers/char/tpm/tpm_acpi.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> note: this patch is against git://github.com/shpedoikal/linux.git v3.6-rc1-tpmdd-staging
>
> diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
> index a1bb5a18..fe3fa94 100644
> --- a/drivers/char/tpm/tpm_acpi.c
> +++ b/drivers/char/tpm/tpm_acpi.c
> @@ -96,6 +96,11 @@ int read_log(struct tpm_bios_log *log)
> log->bios_event_log_end = log->bios_event_log + len;
>
> virt = acpi_os_map_memory(start, len);
> + if (!virt) {
> + kfree(log->bios_event_log);
> + printk("%s: ERROR - Unable to map memory\n", __func__);
> + return -EIO;
> + }
>
> memcpy(log->bios_event_log, virt, len);
>
> --
> 1.7.11.4
>
>
> --
> Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
> Don't top-post http://www.catb.org/jargon/html/T/top-post.html
> Plain text mails only, please.
>
prev parent reply other threads:[~2012-08-16 15:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-07 20:50 [PATCH] tpm: Do not dereference NULL pointer if acpi_os_map_memory() fails Jesper Juhl
2012-08-08 18:07 ` Kent Yoder
2012-08-15 20:15 ` Kent Yoder
2012-08-15 22:02 ` Jesper Juhl
2012-08-15 22:16 ` Jesper Juhl
2012-08-16 15:45 ` Kent Yoder [this message]
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=20120816154507.GA3850@linux.vnet.ibm.com \
--to=key@linux.vnet.ibm.com \
--cc=jj@chaosbits.net \
--cc=kjhall@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mail@srajiv.net \
--cc=munetoh@jp.ibm.com \
--cc=sailer@watson.ibm.com \
--cc=stefanb@us.ibm.com \
--cc=tpmdd-devel@lists.sourceforge.net \
--cc=tpmdd@selhorst.net \
--cc=tpmdd@sirrix.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.