All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
To: "Luck, Tony" <tony.luck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Insu Yun <wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"taesoo-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.org"
	<taesoo-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.org>,
	"yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.org"
	<yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.org>,
	"insu-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.org"
	<insu-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.org>,
	"changwoo-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.org"
	<changwoo-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.org>
Subject: Re: [PATCH] efi: fix out-of-bounds null overwrite vulnerability
Date: Mon, 11 Jan 2016 14:16:05 +0000	[thread overview]
Message-ID: <20160111141605.GC2644@codeblueprint.co.uk> (raw)
In-Reply-To: <3908561D78D1C84285E8C5FCA982C28F39FA7208-8oqHQFITsIE64kNsxIetb7fspsVTdybXVpNB7YpNyf8@public.gmane.org>

On Fri, 08 Jan, at 04:47:17PM, Luck, Tony wrote:
> > But this function doesn't use snprintf(), it uses scnprintf() which
> > returns the number of characters written into buf and, because
> > scnprintf() largely follows vnsprintf(), it will never write more than
> > 'size' bytes into the buffer.
> 
>         if (bank && device)
>                 n = snprintf(msg, len, "DIMM location: %s %s ", bank, device);
> 
> That looks like "snprintf", not "scnprintf" to me :-)
 
Oops! Can you believe I looked at the wrong function?

> What about using:
> 
> 	msg[len] = '\0';
> 
> to guarantee NUL termination?

But that may leave garbage bytes in 'rcd_decode_str' in the case where
the string isn't as long as 'len'.

How about memset()'ing the buffer to zero and deleting the NUL
termination line?

WARNING: multiple messages have this Message-ID (diff)
From: Matt Fleming <matt@codeblueprint.co.uk>
To: "Luck, Tony" <tony.luck@intel.com>
Cc: Insu Yun <wuninsu@gmail.com>,
	"linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"taesoo@gatech.edu" <taesoo@gatech.edu>,
	"yeongjin.jang@gatech.edu" <yeongjin.jang@gatech.edu>,
	"insu@gatech.edu" <insu@gatech.edu>,
	"changwoo@gatech.edu" <changwoo@gatech.edu>
Subject: Re: [PATCH] efi: fix out-of-bounds null overwrite vulnerability
Date: Mon, 11 Jan 2016 14:16:05 +0000	[thread overview]
Message-ID: <20160111141605.GC2644@codeblueprint.co.uk> (raw)
In-Reply-To: <3908561D78D1C84285E8C5FCA982C28F39FA7208@ORSMSX114.amr.corp.intel.com>

On Fri, 08 Jan, at 04:47:17PM, Luck, Tony wrote:
> > But this function doesn't use snprintf(), it uses scnprintf() which
> > returns the number of characters written into buf and, because
> > scnprintf() largely follows vnsprintf(), it will never write more than
> > 'size' bytes into the buffer.
> 
>         if (bank && device)
>                 n = snprintf(msg, len, "DIMM location: %s %s ", bank, device);
> 
> That looks like "snprintf", not "scnprintf" to me :-)
 
Oops! Can you believe I looked at the wrong function?

> What about using:
> 
> 	msg[len] = '\0';
> 
> to guarantee NUL termination?

But that may leave garbage bytes in 'rcd_decode_str' in the case where
the string isn't as long as 'len'.

How about memset()'ing the buffer to zero and deleting the NUL
termination line?

  parent reply	other threads:[~2016-01-11 14:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07 19:05 [PATCH] efi: fix out-of-bounds null overwrite vulnerability Insu Yun
2016-01-07 19:05 ` Insu Yun
     [not found] ` <1452193530-76672-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-01-08 10:13   ` Matt Fleming
2016-01-08 10:13     ` Matt Fleming
     [not found]     ` <20160108101323.GA2532-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-01-08 16:47       ` Luck, Tony
2016-01-08 16:47         ` Luck, Tony
     [not found]         ` <3908561D78D1C84285E8C5FCA982C28F39FA7208-8oqHQFITsIE64kNsxIetb7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2016-01-11 14:16           ` Matt Fleming [this message]
2016-01-11 14:16             ` Matt Fleming
     [not found]             ` <20160111141605.GC2644-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-01-11 18:16               ` Luck, Tony
2016-01-11 18:16                 ` Luck, Tony
2016-01-14 11:12                 ` Matt Fleming
     [not found]                   ` <20160114111200.GA2810-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-01-15  2:06                     ` Tony Luck
2016-01-15  2:06                       ` Tony Luck

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=20160111141605.GC2644@codeblueprint.co.uk \
    --to=matt-mf/unelci9gs6ibeejttw/xrex20p6io@public.gmane.org \
    --cc=changwoo-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.org \
    --cc=insu-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=taesoo-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.org \
    --cc=tony.luck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw@public.gmane.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 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.