All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Emese Revfy <re.emese@gmail.com>
Cc: "kernel-hardening@lists.openwall.com" 
	<kernel-hardening@lists.openwall.com>,
	PaX Team <pageexec@freemail.hu>,
	Brad Spengler <spender@grsecurity.net>,
	Michal Marek <mmarek@suse.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	linux-kbuild <linux-kbuild@vger.kernel.org>,
	minipli@ld-linux.so, Russell King <linux@armlinux.org.uk>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	David Brown <david.brown@linaro.org>,
	"benh@kernel.crashing.org" <benh@kernel.crashing.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jeff Layton <jlayton@poochiereds.net>,
	Arnd Bergmann <arnd@arndb.de>, Sam Ravnborg <sam@ravnborg.org>,
	Karsten Keil <isdn@linux-pingi.de>
Subject: Re: [PATCH v2 1/3] Add the initify gcc plugin
Date: Wed, 13 Jul 2016 14:04:23 -0700	[thread overview]
Message-ID: <CAGXu5j+t_RBhQ0hLWQEi3Y55vBq5QibO_ar0zykjG7nLPOObmg@mail.gmail.com> (raw)
In-Reply-To: <20160713224849.b42c1260b6ebb3ec1f78fa41@gmail.com>

On Wed, Jul 13, 2016 at 1:48 PM, Emese Revfy <re.emese@gmail.com> wrote:
> On Tue, 12 Jul 2016 15:45:56 -0400
> Kees Cook <keescook@chromium.org> wrote:
>
>> On Mon, Jul 4, 2016 at 7:40 PM, Emese Revfy <re.emese@gmail.com> wrote:
>> > If a function is called by __init and __exit functions as well then
>> > the plugin moves it to the __exit section. This causes false positive
>> > section mismatch errors/warnings that I don't know how to handle yet.
>>
>> Should the mismatch checker be updated to recognize this case? Without
>> the plugin, I assume these kinds of functions would only ever be
>> marked for __exit? If so, should the plugin strip the __init marking
>> and only add __exit?
>
> I don't modify the existing attributes. I just add a new __init/__exit when
> a function hasn't a section attribute yet.
> There are three cases:
>  * when the function is called only by __init functions then the plugin adds
>    the __init attribute
>  * when the function is called only by __exit functions then the plugin adds
>    the __exit attribute
>  * when the function is called by __init and __exit functions too then the
>    plugin adds the __exit attribute.
> The last case causes the false positive(?) message of the section mismatch.

In the latter case, how does the linker actually choose where to put
such a function?

For a modular build, if it puts it in .init, it will be missing during
exit. If it puts it in .exit, that seems correct.

For a non-modular build, if it puts it in .init, this is correct. If
it puts it in .exit, it may be missing for init because the exit
section may have already been removed at final link time.

-Kees

-- 
Kees Cook
Chrome OS & Brillo Security

WARNING: multiple messages have this Message-ID (diff)
From: Kees Cook <keescook@chromium.org>
To: Emese Revfy <re.emese@gmail.com>
Cc: "kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>,
	PaX Team <pageexec@freemail.hu>,
	Brad Spengler <spender@grsecurity.net>,
	Michal Marek <mmarek@suse.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	linux-kbuild <linux-kbuild@vger.kernel.org>,
	minipli@ld-linux.so, Russell King <linux@armlinux.org.uk>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	David Brown <david.brown@linaro.org>,
	"benh@kernel.crashing.org" <benh@kernel.crashing.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jeff Layton <jlayton@poochiereds.net>,
	Arnd Bergmann <arnd@arndb.de>, Sam Ravnborg <sam@ravnborg.org>,
	Karsten Keil <isdn@linux-pingi.de>
Subject: [kernel-hardening] Re: [PATCH v2 1/3] Add the initify gcc plugin
Date: Wed, 13 Jul 2016 14:04:23 -0700	[thread overview]
Message-ID: <CAGXu5j+t_RBhQ0hLWQEi3Y55vBq5QibO_ar0zykjG7nLPOObmg@mail.gmail.com> (raw)
In-Reply-To: <20160713224849.b42c1260b6ebb3ec1f78fa41@gmail.com>

On Wed, Jul 13, 2016 at 1:48 PM, Emese Revfy <re.emese@gmail.com> wrote:
> On Tue, 12 Jul 2016 15:45:56 -0400
> Kees Cook <keescook@chromium.org> wrote:
>
>> On Mon, Jul 4, 2016 at 7:40 PM, Emese Revfy <re.emese@gmail.com> wrote:
>> > If a function is called by __init and __exit functions as well then
>> > the plugin moves it to the __exit section. This causes false positive
>> > section mismatch errors/warnings that I don't know how to handle yet.
>>
>> Should the mismatch checker be updated to recognize this case? Without
>> the plugin, I assume these kinds of functions would only ever be
>> marked for __exit? If so, should the plugin strip the __init marking
>> and only add __exit?
>
> I don't modify the existing attributes. I just add a new __init/__exit when
> a function hasn't a section attribute yet.
> There are three cases:
>  * when the function is called only by __init functions then the plugin adds
>    the __init attribute
>  * when the function is called only by __exit functions then the plugin adds
>    the __exit attribute
>  * when the function is called by __init and __exit functions too then the
>    plugin adds the __exit attribute.
> The last case causes the false positive(?) message of the section mismatch.

In the latter case, how does the linker actually choose where to put
such a function?

For a modular build, if it puts it in .init, it will be missing during
exit. If it puts it in .exit, that seems correct.

For a non-modular build, if it puts it in .init, this is correct. If
it puts it in .exit, it may be missing for init because the exit
section may have already been removed at final link time.

-Kees

-- 
Kees Cook
Chrome OS & Brillo Security

  reply	other threads:[~2016-07-13 21:04 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04 23:39 [PATCH v2 0/3] Introduce the initify gcc plugin Emese Revfy
2016-07-04 23:39 ` [kernel-hardening] " Emese Revfy
2016-07-04 23:40 ` [PATCH v2 1/3] Add " Emese Revfy
2016-07-04 23:40   ` [kernel-hardening] " Emese Revfy
2016-07-12 19:45   ` Kees Cook
2016-07-12 19:45     ` [kernel-hardening] " Kees Cook
2016-07-12 19:45     ` Kees Cook
2016-07-12 20:07     ` Emese Revfy
2016-07-12 20:07       ` [kernel-hardening] " Emese Revfy
2016-07-12 20:07       ` Emese Revfy
2016-07-12 20:05       ` Kees Cook
2016-07-12 20:05         ` [kernel-hardening] " Kees Cook
2016-07-12 20:05         ` Kees Cook
2016-07-13 20:34         ` Emese Revfy
2016-07-13 20:34           ` [kernel-hardening] " Emese Revfy
2016-07-13 20:34           ` Emese Revfy
2016-07-12 22:08     ` Russell King - ARM Linux
2016-07-12 22:08       ` [kernel-hardening] " Russell King - ARM Linux
2016-07-12 22:08       ` Russell King - ARM Linux
2016-07-12 22:38       ` Kees Cook
2016-07-12 22:38         ` [kernel-hardening] " Kees Cook
2016-07-12 22:38         ` Kees Cook
2016-07-13 21:26         ` Emese Revfy
2016-07-13 21:26           ` [kernel-hardening] " Emese Revfy
2016-07-13 21:26           ` Emese Revfy
2016-07-13 20:48     ` Emese Revfy
2016-07-13 20:48       ` [kernel-hardening] " Emese Revfy
2016-07-13 20:48       ` Emese Revfy
2016-07-13 21:04       ` Kees Cook [this message]
2016-07-13 21:04         ` [kernel-hardening] " Kees Cook
2016-07-13 21:04         ` Kees Cook
2016-07-04 23:42 ` [PATCH v2 2/3] Mark functions with the __nocapture attribute Emese Revfy
2016-07-04 23:42   ` [kernel-hardening] " Emese Revfy
2016-07-12 19:08   ` Kees Cook
2016-07-12 19:08     ` [kernel-hardening] " Kees Cook
2016-07-12 19:08     ` Kees Cook
2016-07-12 19:23     ` [kernel-hardening] " Daniel Micay
2016-07-12 19:47       ` Kees Cook
2016-07-12 19:47         ` Kees Cook
2016-07-04 23:43 ` [PATCH v2 3/3] Constify some function parameters Emese Revfy
2016-07-04 23:43   ` [kernel-hardening] " Emese Revfy
2016-07-04 23:58   ` kbuild test robot
2016-07-04 23:58     ` [kernel-hardening] " kbuild test robot
2016-07-06 16:45     ` Emese Revfy
2016-07-06 16:45       ` [kernel-hardening] " Emese Revfy
2016-07-06 16:44   ` Emese Revfy
2016-07-06 16:44     ` [kernel-hardening] " Emese Revfy

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=CAGXu5j+t_RBhQ0hLWQEi3Y55vBq5QibO_ar0zykjG7nLPOObmg@mail.gmail.com \
    --to=keescook@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=catalin.marinas@arm.com \
    --cc=david.brown@linaro.org \
    --cc=isdn@linux-pingi.de \
    --cc=jlayton@poochiereds.net \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=linux@rasmusvillemoes.dk \
    --cc=minipli@ld-linux.so \
    --cc=mmarek@suse.com \
    --cc=pageexec@freemail.hu \
    --cc=re.emese@gmail.com \
    --cc=sam@ravnborg.org \
    --cc=spender@grsecurity.net \
    --cc=tglx@linutronix.de \
    --cc=yamada.masahiro@socionext.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 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.