From: Dan Carpenter <dan.carpenter@oracle.com>
To: Kees Cook <keescook@chromium.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
linux-acpi@vger.kernel.org, devel@acpica.org,
"kernel-hardening@lists.openwall.com"
<kernel-hardening@lists.openwall.com>,
Dave Jones <davej@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [patch] lib: check for strcpy() overflows to fixed length buffers
Date: Wed, 30 Apr 2014 19:19:27 +0300 [thread overview]
Message-ID: <20140430161927.GW4963@mwanda> (raw)
In-Reply-To: <CAGXu5jL+VLb_+ZJd6-L5P+Bdxmw+i7j2cLyPOT4rwfE6iqHuRA@mail.gmail.com>
On Wed, Apr 30, 2014 at 08:33:21AM -0700, Kees Cook wrote:
> On Wed, Apr 30, 2014 at 8:08 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > +#if CONFIG_DEBUG_STRICT_SLOW_STRCPY_CHECKS
> > +#define strcpy(dest, src) do { \
> > + int len = __compiletime_size(dest); \
> > + if (len > 1 && strlen(src) >= len) \
> > + WARN_ONCE(1, "strcpy() overflow copying \"%s\"\n", src); \
>
> This should probably BUG. An overflowing strcpy shouldn't be allowed
> to continue.
I was worried about false positives.
Speaking of false positives the STRICT checks on copy_from_user() have
been disabled for a year now because of a three year old GCC bug. I
wonder if the GCC people realize the security impact it has. See
commit 2fb0815c9ee6 ('gcc4: disable __compiletime_object_size for GCC
4.6+') and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48880
> > +config DEBUG_STRICT_SLOW_STRCPY_CHECKS
> > + bool "Strict checks for strcpy() overflows"
> > + depends on DEBUG_KERNEL
> > + help
> > + Enabling this option adds some extra sanity checks when strcpy() is
> > + called(). This will slow down the kernel a bit.
>
> Isn't this an entirely compile-time check? I would expect it to be
> entirely optimized by the compiler. In fact, could this be turned into
> a build failure instead?
No. The problem is when we don't know the size of the src string. Also
if GCC is able to find the compile time size of both the src and
dest string then Smatch and other static checkers are able to as well so
I'm not very concerned about that case because we already catch them.
regards,
dan carpenter
next prev parent reply other threads:[~2014-04-30 16:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-30 15:08 [patch] lib: check for strcpy() overflows to fixed length buffers Dan Carpenter
2014-04-30 15:33 ` Kees Cook
2014-04-30 16:19 ` Dan Carpenter [this message]
2014-04-30 16:44 ` Kees Cook
2014-04-30 19:49 ` Rafael J. Wysocki
2014-04-30 20:15 ` Dan Carpenter
2014-05-05 0:19 ` Zheng, Lv
2014-05-06 12:41 ` Dan Carpenter
2014-05-01 4:06 ` Solar Designer
2014-05-01 7:45 ` Dan Carpenter
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=20140430161927.GW4963@mwanda \
--to=dan.carpenter@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=davej@redhat.com \
--cc=devel@acpica.org \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 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).