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: Wed, 8 Aug 2012 13:07:51 -0500 [thread overview]
Message-ID: <20120808180750.GA24016@linux.vnet.ibm.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1208072247490.3227@swampdragon.chaosbits.net>
On Tue, Aug 07, 2012 at 10:50:56PM +0200, Jesper Juhl wrote:
> In drivers/char/tpm/tpm_bios.c::read_log() we call
> acpi_os_map_memory(). That call may fail for a number of reasons
> (invallid 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. I'd made some updates to tpm_bios.c recently but this
should still apply. I'll let you know if not.
Kent
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> drivers/char/tpm/tpm_bios.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> Compile tested only.
>
> diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
> index 0636520..0c5c274 100644
> --- a/drivers/char/tpm/tpm_bios.c
> +++ b/drivers/char/tpm/tpm_bios.c
> @@ -410,6 +410,11 @@ static 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) {
> + 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.
>
next prev parent reply other threads:[~2012-08-08 18:13 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 [this message]
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
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=20120808180750.GA24016@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox