From: Rusty Russell <rusty@rustcorp.com.au>
To: Kees Cook <keescook@chromium.org>, linux-kernel@vger.kernel.org
Cc: Michal Marek <mmarek@suse.cz>, Andi Kleen <andi@firstfloor.org>,
Fabio Estevam <fabio.estevam@freescale.com>,
Ming Lei <tom.leiming@gmail.com>, Andy Honig <ahonig@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
"H. Peter Anvin" <hpa@linux.intel.com>,
x86@kernel.org, Vivek Goyal <vgoyal@in.ibm.com>
Subject: Re: [PATCH] kallsyms: fix absolute addresses for kASLR
Date: Tue, 25 Feb 2014 11:59:20 +1030 [thread overview]
Message-ID: <87sir856a7.fsf@rustcorp.com.au> (raw)
In-Reply-To: <20140221201031.GA8089@www.outflux.net>
Kees Cook <keescook@chromium.org> writes:
> From: Andy Honig <ahonig@google.com>
>
> Currently symbols that are absolute addresses are incorrectly
> displayed in /proc/kallsyms if the kernel is loaded with kASLR.
>
> The problem was that the scripts/kallsyms.c file which generates
> the array of symbol names and addresses uses an relocatable value
> for all symbols, even absolute symbols. This patch fixes that.
Hi Andy, Kees,
This is not a good patch. See the commit where this was
introduced:
[PATCH] relocatable kernel: Fix kallsyms on avr32 after relocatable kernel changes
o On some platforms like avr32, section init comes before .text and
not necessarily a symbol's relative position w.r.t _text is positive.
In such cases assembler detects the overflow and emits warning. This
patch fixes it.
Did you just break avr32?
And absolute symbols are supposed to be handled in the other branch:
for (i = 0; i < table_cnt; i++) {
if (toupper(table[i].sym[0]) != 'A') {
if (_text <= table[i].addr)
printf("\tPTR\t_text + %#llx\n",
table[i].addr - _text);
else
printf("\tPTR\t_text - %#llx\n",
_text - table[i].addr);
} else {
printf("\tPTR\t%#llx\n", table[i].addr);
}
}
__per_cpu_start is not an absolute symbol anyway.
You need to fix this properly.
Rusty.
> Several kallsyms output in different boot states for comparison:
>
> $ egrep '_(stext|_per_cpu_(start|end))' /root/kallsyms.nokaslr
> 0000000000000000 D __per_cpu_start
> 0000000000014280 D __per_cpu_end
> ffffffff810001c8 T _stext
> $ egrep '_(stext|_per_cpu_(start|end))' /root/kallsyms.kaslr1
> 000000001f200000 D __per_cpu_start
> 000000001f214280 D __per_cpu_end
> ffffffffa02001c8 T _stext
> $ egrep '_(stext|_per_cpu_(start|end))' /root/kallsyms.kaslr2
> 000000000d400000 D __per_cpu_start
> 000000000d414280 D __per_cpu_end
> ffffffff8e4001c8 T _stext
> $ egrep '_(stext|_per_cpu_(start|end))' /root/kallsyms.kaslr-fixed
> 0000000000000000 D __per_cpu_start
> 0000000000014280 D __per_cpu_end
> ffffffffadc001c8 T _stext
>
> Signed-off-by: Andy Honig <ahonig@google.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> scripts/kallsyms.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
> index 10085de886fe..276e84b8a8e5 100644
> --- a/scripts/kallsyms.c
> +++ b/scripts/kallsyms.c
> @@ -330,8 +330,7 @@ static void write_src(void)
> printf("\tPTR\t_text + %#llx\n",
> table[i].addr - _text);
> else
> - printf("\tPTR\t_text - %#llx\n",
> - _text - table[i].addr);
> + printf("\tPTR\t%#llx\n", table[i].addr);
> } else {
> printf("\tPTR\t%#llx\n", table[i].addr);
> }
next prev parent reply other threads:[~2014-02-25 1:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-21 20:10 [PATCH] kallsyms: fix absolute addresses for kASLR Kees Cook
2014-02-25 1:29 ` Rusty Russell [this message]
2014-02-26 6:15 ` Kees Cook
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=87sir856a7.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=ahonig@google.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=fabio.estevam@freescale.com \
--cc=hpa@linux.intel.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.cz \
--cc=tom.leiming@gmail.com \
--cc=vgoyal@in.ibm.com \
--cc=x86@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