From: Dan Carpenter <dan.carpenter@oracle.com>
To: Vegard Nossum <vegard.nossum@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
LKML <linux-kernel@vger.kernel.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] isdnloop: NUL-terminate strings from userspace
Date: Mon, 31 Mar 2014 16:36:37 +0300 [thread overview]
Message-ID: <20140331133637.GA24528@mwanda> (raw)
In-Reply-To: <CAOMGZ=FmOPcL=d3POVM=VEA1Wu-ojUFqJuQ5KxgKB-iPfk1aiA@mail.gmail.com>
On Mon, Mar 31, 2014 at 02:56:07PM +0200, Vegard Nossum wrote:
> Ping, Dave? Just making sure this doesn't fall through the cracks. I
> don't see the patch applied anywhere yet and without this patch we
> still have a valid security concern IMO.
Gar. No... To recap:
> On 7 March 2014 11:56, Vegard Nossum <vegard.nossum@oracle.com> wrote:
> > Both the in-kernel and BSD strlcpy() require that the source string is
> > NUL terminated.
The *whole point* of strlcpy() is that the source string doesn't have to
be NUL terminated. The BSD man pages are trying to say that strlcpy()
only works on C-strings as opposed to Vstr or other safer string
implementions.
There is a potential problem in the kernel implementation of strlcpy()
because it does:
lib/string.c
149 size_t strlcpy(char *dest, const char *src, size_t size)
150 {
151 size_t ret = strlen(src);
152
153 if (size) {
154 size_t len = (ret >= size) ? size - 1 : ret;
155 memcpy(dest, src, len);
156 dest[len] = '\0';
157 }
158 return ret;
159 }
The strlen() on line 151 could read beyond the end of the source buffer
and if the memory wasn't mapped, it could Oops.
That concern doesn't apply here because the source string is on stack
memory and we will hit a NUL character before we hit unmapped memory.
regards,
dan carpenter
next prev parent reply other threads:[~2014-03-31 13:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-07 10:56 [PATCH] isdnloop: NUL-terminate strings from userspace Vegard Nossum
2014-03-07 11:26 ` Dan Carpenter
2014-03-07 11:42 ` Vegard Nossum
2014-03-07 11:52 ` Dan Carpenter
2014-03-07 12:44 ` Vegard Nossum
2014-03-07 13:05 ` Dan Carpenter
2014-03-31 12:56 ` Vegard Nossum
2014-03-31 13:36 ` Dan Carpenter [this message]
2014-03-31 13:44 ` Vegard Nossum
2014-03-31 16:48 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2014-04-01 10:08 Vegard Nossum
2014-04-01 10:30 ` Hannes Frederic Sowa
2014-04-01 10:46 ` Vegard Nossum
2014-04-01 11:02 ` Hannes Frederic Sowa
2014-04-01 12:35 ` Dan Carpenter
2014-04-01 20:18 ` David Miller
2014-04-01 11:23 ` YOSHIFUJI Hideaki
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=20140331133637.GA24528@mwanda \
--to=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=vegard.nossum@gmail.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