All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 06/12] gcc/4.9: add patch to warn about unsafe header paths
Date: Wed, 10 Sep 2014 22:24:00 +0200	[thread overview]
Message-ID: <20140910222400.5850961c@free-electrons.com> (raw)
In-Reply-To: <20140910200825.GB23947@free.fr>

Dear Yann E. MORIN,

On Wed, 10 Sep 2014 22:08:25 +0200, Yann E. MORIN wrote:

> > ++  temp = getenv("BR_COMPILER_PARANOID_UNSAFE_PATH");
> > ++  if (temp && strlen(temp) > 0)
> > ++    {
> > ++      save_switch("-Werror=poison-system-directories", 0, NULL, false, true);
> 
> Here you set the --error-poison-system-direcotries for the linker...

No, that's not what's happening here. What's happening here is that if
BR_COMPILER_PARANOID_UNSAFE_PATH is set and non-empty, then we add
-Werror=poison-system-directories to the gcc options. This makes gcc
behave as if -Werror=poison-system-directories was passed on the
command line.

The idea is that it's hard for Buildroot to guarantee that
-Werror=poison-system-directories in the CFLAGS will *always* be passed
by all packages to the build of all files. So having an environment
variable that forces gcc to add this option by itself makes sure all
files will be compiled with this behavior.


> > ++#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
> > ++  if (flag_poison_system_directories)
> > ++    {
> > ++       struct cpp_dir *p;
> > ++
> > ++       for (p = heads[QUOTE]; p; p = p->next)
> > ++         {
> > ++          if ((!strncmp (p->name, "/usr/include", 12))
> > ++              || (!strncmp (p->name, "/usr/local/include", 18))
> > ++              || (!strncmp (p->name, "/usr/X11R6/include", 18)))
> > ++            warning (OPT_Wpoison_system_directories,
> > ++                     "include location \"%s\" is unsafe for "
> > ++                     "cross-compilation",
> > ++                     p->name);
> 
> But you do not handle include paths.

What? We're precisely handling include paths here.

> We should error out if BR_COMPILER_PARANOID_UNSAFE_PATH is set and
> non-empty, no?

See above, that's exactly what is happening. By default
(BR_COMPILER_PARANOID_UNSAFE_PATH is unset or empty), only warnings are
generated. If BR_COMPILER_PARANOID_UNSAFE_PATH is set and non-empty,
then it will be an error.

You should probably test this, and you'll notice that the warning()
function above actually *errors* out if the OPT_W<foo> warning passed
as first argument has -Werror=<foo> in the command line.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

  reply	other threads:[~2014-09-10 20:24 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20 13:06 [Buildroot] [PATCH 00/12] toolchain: warn for unsafe library/header paths Thomas Petazzoni
2014-08-20 13:06 ` [Buildroot] [PATCH 01/12] toolchain-external: instrument wrapper to warn about unsafe paths Thomas Petazzoni
2014-09-10 19:42   ` Yann E. MORIN
2014-09-10 20:18     ` Thomas Petazzoni
2014-09-10 20:23       ` Yann E. MORIN
2014-08-20 13:06 ` [Buildroot] [PATCH 02/12] binutils/2.24: add patch to warn about unsafe library paths Thomas Petazzoni
2014-09-10 19:52   ` Yann E. MORIN
2014-09-10 20:19     ` Thomas Petazzoni
2014-08-20 13:06 ` [Buildroot] [PATCH 03/12] binutils/2.23: " Thomas Petazzoni
2014-08-20 13:06 ` [Buildroot] [PATCH 04/12] binutils/2.22: " Thomas Petazzoni
2014-08-20 13:06 ` [Buildroot] [PATCH 05/12] binutils/arc-4.8-R3: " Thomas Petazzoni
2014-08-20 13:06 ` [Buildroot] [PATCH 06/12] gcc/4.9: add patch to warn about unsafe header paths Thomas Petazzoni
2014-09-10 20:08   ` Yann E. MORIN
2014-09-10 20:24     ` Thomas Petazzoni [this message]
2014-09-10 22:10       ` Yann E. MORIN
2014-08-20 13:06 ` [Buildroot] [PATCH 07/12] gcc/4.8: " Thomas Petazzoni
2014-08-20 13:06 ` [Buildroot] [PATCH 08/12] gcc/arc-4.8-R3: " Thomas Petazzoni
2014-08-20 13:06 ` [Buildroot] [PATCH 09/12] gcc/4.7: " Thomas Petazzoni
2014-08-20 13:06 ` [Buildroot] [PATCH 10/12] gcc: enable poison system directories option Thomas Petazzoni
2014-09-10 20:09   ` Yann E. MORIN
2014-08-20 13:06 ` [Buildroot] [PATCH 11/12] binutils: " Thomas Petazzoni
2014-09-10 20:09   ` Yann E. MORIN
2014-08-20 13:06 ` [Buildroot] [PATCH 12/12] Add option for paranoid unsafe path checking Thomas Petazzoni
2014-09-10 20:12   ` Yann E. MORIN
2014-08-21 20:30 ` [Buildroot] [PATCH 00/12] toolchain: warn for unsafe library/header paths Romain Naour
2014-08-21 21:33   ` Thomas Petazzoni
2014-08-22 16:30     ` Yann E. MORIN
2014-08-22 19:29       ` Thomas De Schampheleire
2014-08-24 11:22         ` Yann E. MORIN
2014-08-26 20:14           ` Arnout Vandecappelle

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=20140910222400.5850961c@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=buildroot@busybox.net \
    /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.