From: "Tobin C. Harding" <me@tobin.cc>
To: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Andy Lutomirski <luto@kernel.org>, Joe Perches <joe@perches.com>,
Network Development <netdev@vger.kernel.org>,
David Miller <davem@davemloft.net>,
"kernel-hardening@lists.openwall.com"
<kernel-hardening@lists.openwall.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Theodore Ts'o <tytso@mit.edu>,
Paolo Bonzini <pbonzini@redhat.com>,
Tycho Andersen <tycho@docker.com>,
"Roberts, William C" <william.c.roberts@intel.com>,
Tejun Heo <tj@kernel.org>,
Jordan Glover <Golden_Miller83@protonmail.ch>,
Greg KH <gregkh@linuxfoundation.org>,
Petr Mladek <pmladek@suse.com>, Ian Campbell <ijc@hellion.org.uk>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <wilal.deacon@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Chris Fries <cfries@google.com>,
Dave Weinstein <olorin@google.com>,
Daniel Micay <danielmicay@gmail.com>,
Djalal Harouni <tixxdz@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [kernel-hardening] Re: [PATCH v3] scripts: add leaking_addresses.pl
Date: Wed, 8 Nov 2017 13:05:38 +1100 [thread overview]
Message-ID: <20171108020538.GZ18478@eros> (raw)
In-Reply-To: <CAGXu5j+o6cf0PrnxD+W+09F7UY6JL+h7Bn5_4T2C0Z_fTZAx-w@mail.gmail.com>
Hi Kees,
It seems I over looked your suggestions when submitting v4. My mistake.
On Tue, Nov 07, 2017 at 01:22:13PM -0800, Kees Cook wrote:
> On Mon, Nov 6, 2017 at 9:27 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> > On Sun, Nov 5, 2017 at 9:19 PM, Tobin C. Harding <me@tobin.cc> wrote:
> >> Currently we are leaking addresses from the kernel to user space. This
> >> script is an attempt to find some of those leakages. Script parses
> >> `dmesg` output and /proc and /sys files for hex strings that look like
> >> kernel addresses.
> >
> > Lovely. This is great. It shows just how much totally pointless stuff
> > we leak, and to normal users that really shouldn't need it.
> >
> > I had planned to wait for 4.15 to look at the printk hashing stuff
> > etc, but this part I think I could/should merge early just because I
> > think a lot of kernel developers will go "Why the f*ck would we expose
> > that kernel address there?"
> >
> > The module sections stuff etc should likely be obviously root-only,
> > although maybe I'm missing some tool that ends up using it and is
> > useful to normal developers.
> >
> > And I'm thinking we could make kallsyms smarter too, and instead of
> > depending on kptr_restrict that screws over things with much too big a
> > hammer, we could make it take 'perf_event_paranoid' into account. I
> > suspect that's the main user of kallsyms that would still be relevant
> > to non-root.
>
> Linus, what do you have in mind for the root-only "yes we really need
> the actual address output" exceptions?
>
> For example, right now /sys/kernel/debug/kernel_page_tables
> (CONFIG_X86_PTDUMP=y) needs actual address and currently uses %x.
>
> Looking other places that stand out, it seems like
> /proc/lockdep_chains and /proc/lockdep (CONFIG_LOCKDEP=y) has a ton of
> %p usage. It's unclear to me if a hash is sufficient for meaningful
> debugging there?
>
> Seems like these three from dmesg could be removed?
>
> [ 0.000000] Base memory trampoline at [ffffa3fc40099000] 99000 size 24576
> arch/x86/realmode/init.c
>
> [ 0.000000] percpu: Embedded 38 pages/cpu @ffffa4007fc00000 s116944
> r8192 d30512 u524288
> mm/percpu.c
>
> [ 0.456395] software IO TLB [mem 0xbbfdf000-0xbffdf000] (64MB)
> mapped at [ffffa3fcfbfdf000-ffffa3fcfffdefff]
> lib/swiotlb.c
>
> Tobin, some other feedback on v4...
>
> I find the output hard to parse. Instead of:
>
> [27527 lockdep_chains] [ffffffffb226c628] cgroup_mutex
>
> Could we have:
>
> 27527 /proc/lockdep_chains: [ffffffffb226c628] cgroup_mutex
This is what I had during development, it becomes had to parse when the
message contains ':' and also if the address is not contained in braces
(I'm assuming '[ffffffffb226c628] cgroup_mutex' is the message).
We could use your suggested format but replace the ':' character?
> At the very least, getting the full file path is needed or might not
> be clear where something lives.
Current dev version includes this.
> And for my kernels, I needed to exclude usbmon or the script would
> hang (perhaps add a read timeout to the script to detect stalling
> files?)
Good idea, I'll add this.
> diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
> index 282c0cc2bdea..a9b729c0a052 100644
> --- a/scripts/leaking_addresses.pl
> +++ b/scripts/leaking_addresses.pl
> @@ -70,6 +70,7 @@ my @skip_walk_dirs_any = ('self',
> 'thread-self',
> 'cwd',
> 'fd',
> + 'usbmon',
> 'stderr',
> 'stdin',
> 'stdout');
>
Added this.
thanks. Again, sorry for missing this before v4.
Tobin
WARNING: multiple messages have this Message-ID (diff)
From: "Tobin C. Harding" <me@tobin.cc>
To: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Andy Lutomirski <luto@kernel.org>, Joe Perches <joe@perches.com>,
Network Development <netdev@vger.kernel.org>,
David Miller <davem@davemloft.net>,
"kernel-hardening@lists.openwall.com"
<kernel-hardening@lists.openwall.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
"Theodore Ts'o" <tytso@mit.edu>,
Paolo Bonzini <pbonzini@redhat.com>,
Tycho Andersen <tycho@docker.com>,
"Roberts, William C" <william.c.roberts@intel.com>,
Tejun Heo <tj@kernel.org>,
Jordan Glover <Golden_Miller83@protonmail.ch>,
Greg KH <gregkh@linuxfoundation.org>,
Petr Mladek <pmladek@suse.com>, Ian Campbell <ijc@hellion.org.uk>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <wilal.deacon@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Chris Fries <cfries@google.com>,
Dave Weinstein <olorin@google.com>,
Daniel Micay <danielmicay@gmail.com>,
Djalal Harouni <tixxdz@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] scripts: add leaking_addresses.pl
Date: Wed, 8 Nov 2017 13:05:38 +1100 [thread overview]
Message-ID: <20171108020538.GZ18478@eros> (raw)
In-Reply-To: <CAGXu5j+o6cf0PrnxD+W+09F7UY6JL+h7Bn5_4T2C0Z_fTZAx-w@mail.gmail.com>
Hi Kees,
It seems I over looked your suggestions when submitting v4. My mistake.
On Tue, Nov 07, 2017 at 01:22:13PM -0800, Kees Cook wrote:
> On Mon, Nov 6, 2017 at 9:27 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> > On Sun, Nov 5, 2017 at 9:19 PM, Tobin C. Harding <me@tobin.cc> wrote:
> >> Currently we are leaking addresses from the kernel to user space. This
> >> script is an attempt to find some of those leakages. Script parses
> >> `dmesg` output and /proc and /sys files for hex strings that look like
> >> kernel addresses.
> >
> > Lovely. This is great. It shows just how much totally pointless stuff
> > we leak, and to normal users that really shouldn't need it.
> >
> > I had planned to wait for 4.15 to look at the printk hashing stuff
> > etc, but this part I think I could/should merge early just because I
> > think a lot of kernel developers will go "Why the f*ck would we expose
> > that kernel address there?"
> >
> > The module sections stuff etc should likely be obviously root-only,
> > although maybe I'm missing some tool that ends up using it and is
> > useful to normal developers.
> >
> > And I'm thinking we could make kallsyms smarter too, and instead of
> > depending on kptr_restrict that screws over things with much too big a
> > hammer, we could make it take 'perf_event_paranoid' into account. I
> > suspect that's the main user of kallsyms that would still be relevant
> > to non-root.
>
> Linus, what do you have in mind for the root-only "yes we really need
> the actual address output" exceptions?
>
> For example, right now /sys/kernel/debug/kernel_page_tables
> (CONFIG_X86_PTDUMP=y) needs actual address and currently uses %x.
>
> Looking other places that stand out, it seems like
> /proc/lockdep_chains and /proc/lockdep (CONFIG_LOCKDEP=y) has a ton of
> %p usage. It's unclear to me if a hash is sufficient for meaningful
> debugging there?
>
> Seems like these three from dmesg could be removed?
>
> [ 0.000000] Base memory trampoline at [ffffa3fc40099000] 99000 size 24576
> arch/x86/realmode/init.c
>
> [ 0.000000] percpu: Embedded 38 pages/cpu @ffffa4007fc00000 s116944
> r8192 d30512 u524288
> mm/percpu.c
>
> [ 0.456395] software IO TLB [mem 0xbbfdf000-0xbffdf000] (64MB)
> mapped at [ffffa3fcfbfdf000-ffffa3fcfffdefff]
> lib/swiotlb.c
>
> Tobin, some other feedback on v4...
>
> I find the output hard to parse. Instead of:
>
> [27527 lockdep_chains] [ffffffffb226c628] cgroup_mutex
>
> Could we have:
>
> 27527 /proc/lockdep_chains: [ffffffffb226c628] cgroup_mutex
This is what I had during development, it becomes had to parse when the
message contains ':' and also if the address is not contained in braces
(I'm assuming '[ffffffffb226c628] cgroup_mutex' is the message).
We could use your suggested format but replace the ':' character?
> At the very least, getting the full file path is needed or might not
> be clear where something lives.
Current dev version includes this.
> And for my kernels, I needed to exclude usbmon or the script would
> hang (perhaps add a read timeout to the script to detect stalling
> files?)
Good idea, I'll add this.
> diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
> index 282c0cc2bdea..a9b729c0a052 100644
> --- a/scripts/leaking_addresses.pl
> +++ b/scripts/leaking_addresses.pl
> @@ -70,6 +70,7 @@ my @skip_walk_dirs_any = ('self',
> 'thread-self',
> 'cwd',
> 'fd',
> + 'usbmon',
> 'stderr',
> 'stdin',
> 'stdout');
>
Added this.
thanks. Again, sorry for missing this before v4.
Tobin
WARNING: multiple messages have this Message-ID (diff)
From: "Tobin C. Harding" <me@tobin.cc>
To: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Andy Lutomirski <luto@kernel.org>, Joe Perches <joe@perches.com>,
Network Development <netdev@vger.kernel.org>,
David Miller <davem@davemloft.net>,
"kernel-hardening@lists.openwall.com"
<kernel-hardening@lists.openwall.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Theodore Ts'o <tytso@mit.edu>,
Paolo Bonzini <pbonzini@redhat.com>,
Tycho Andersen <tycho@docker.com>,
"Roberts, William C" <william.c.roberts@intel.com>,
Tejun Heo <tj@kernel.org>,
Jordan Glover <Golden_Miller83@protonmail.ch>,
Greg KH <gregkh@linuxfoundation.org>,
Petr Mladek <pmladek@suse.com>, Ian Campbell <ijc@hellion.org.uk>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Subject: Re: [PATCH v3] scripts: add leaking_addresses.pl
Date: Wed, 8 Nov 2017 13:05:38 +1100 [thread overview]
Message-ID: <20171108020538.GZ18478@eros> (raw)
In-Reply-To: <CAGXu5j+o6cf0PrnxD+W+09F7UY6JL+h7Bn5_4T2C0Z_fTZAx-w@mail.gmail.com>
Hi Kees,
It seems I over looked your suggestions when submitting v4. My mistake.
On Tue, Nov 07, 2017 at 01:22:13PM -0800, Kees Cook wrote:
> On Mon, Nov 6, 2017 at 9:27 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> > On Sun, Nov 5, 2017 at 9:19 PM, Tobin C. Harding <me@tobin.cc> wrote:
> >> Currently we are leaking addresses from the kernel to user space. This
> >> script is an attempt to find some of those leakages. Script parses
> >> `dmesg` output and /proc and /sys files for hex strings that look like
> >> kernel addresses.
> >
> > Lovely. This is great. It shows just how much totally pointless stuff
> > we leak, and to normal users that really shouldn't need it.
> >
> > I had planned to wait for 4.15 to look at the printk hashing stuff
> > etc, but this part I think I could/should merge early just because I
> > think a lot of kernel developers will go "Why the f*ck would we expose
> > that kernel address there?"
> >
> > The module sections stuff etc should likely be obviously root-only,
> > although maybe I'm missing some tool that ends up using it and is
> > useful to normal developers.
> >
> > And I'm thinking we could make kallsyms smarter too, and instead of
> > depending on kptr_restrict that screws over things with much too big a
> > hammer, we could make it take 'perf_event_paranoid' into account. I
> > suspect that's the main user of kallsyms that would still be relevant
> > to non-root.
>
> Linus, what do you have in mind for the root-only "yes we really need
> the actual address output" exceptions?
>
> For example, right now /sys/kernel/debug/kernel_page_tables
> (CONFIG_X86_PTDUMP=y) needs actual address and currently uses %x.
>
> Looking other places that stand out, it seems like
> /proc/lockdep_chains and /proc/lockdep (CONFIG_LOCKDEP=y) has a ton of
> %p usage. It's unclear to me if a hash is sufficient for meaningful
> debugging there?
>
> Seems like these three from dmesg could be removed?
>
> [ 0.000000] Base memory trampoline at [ffffa3fc40099000] 99000 size 24576
> arch/x86/realmode/init.c
>
> [ 0.000000] percpu: Embedded 38 pages/cpu @ffffa4007fc00000 s116944
> r8192 d30512 u524288
> mm/percpu.c
>
> [ 0.456395] software IO TLB [mem 0xbbfdf000-0xbffdf000] (64MB)
> mapped at [ffffa3fcfbfdf000-ffffa3fcfffdefff]
> lib/swiotlb.c
>
> Tobin, some other feedback on v4...
>
> I find the output hard to parse. Instead of:
>
> [27527 lockdep_chains] [ffffffffb226c628] cgroup_mutex
>
> Could we have:
>
> 27527 /proc/lockdep_chains: [ffffffffb226c628] cgroup_mutex
This is what I had during development, it becomes had to parse when the
message contains ':' and also if the address is not contained in braces
(I'm assuming '[ffffffffb226c628] cgroup_mutex' is the message).
We could use your suggested format but replace the ':' character?
> At the very least, getting the full file path is needed or might not
> be clear where something lives.
Current dev version includes this.
> And for my kernels, I needed to exclude usbmon or the script would
> hang (perhaps add a read timeout to the script to detect stalling
> files?)
Good idea, I'll add this.
> diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
> index 282c0cc2bdea..a9b729c0a052 100644
> --- a/scripts/leaking_addresses.pl
> +++ b/scripts/leaking_addresses.pl
> @@ -70,6 +70,7 @@ my @skip_walk_dirs_any = ('self',
> 'thread-self',
> 'cwd',
> 'fd',
> + 'usbmon',
> 'stderr',
> 'stdin',
> 'stdout');
>
Added this.
thanks. Again, sorry for missing this before v4.
Tobin
next prev parent reply other threads:[~2017-11-08 2:05 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-06 5:19 [kernel-hardening] [PATCH v3] scripts: add leaking_addresses.pl Tobin C. Harding
2017-11-06 5:19 ` Tobin C. Harding
2017-11-06 17:27 ` [kernel-hardening] " Linus Torvalds
2017-11-06 17:27 ` Linus Torvalds
2017-11-06 17:27 ` Linus Torvalds
2017-11-06 17:41 ` [kernel-hardening] " Linus Torvalds
2017-11-06 17:41 ` Linus Torvalds
2017-11-06 17:41 ` Linus Torvalds
2017-11-06 21:15 ` [kernel-hardening] " Tobin C. Harding
2017-11-06 21:15 ` Tobin C. Harding
2017-11-06 21:15 ` Tobin C. Harding
2017-11-06 18:25 ` [kernel-hardening] " Pavel Vasilyev
2017-11-06 18:25 ` Pavel Vasilyev
2017-11-06 21:03 ` Tobin C. Harding
2017-11-06 21:03 ` Tobin C. Harding
2017-11-07 21:22 ` Kees Cook
2017-11-07 21:22 ` Kees Cook
2017-11-07 21:22 ` Kees Cook
2017-11-07 21:44 ` [kernel-hardening] " Linus Torvalds
2017-11-07 21:44 ` Linus Torvalds
2017-11-07 21:44 ` Linus Torvalds
2017-11-07 22:08 ` [kernel-hardening] " Kees Cook
2017-11-07 22:08 ` Kees Cook
2017-11-07 22:08 ` Kees Cook
2017-11-07 22:44 ` [kernel-hardening] " Steven Rostedt
2017-11-07 22:44 ` Steven Rostedt
2017-11-07 22:44 ` Steven Rostedt
2017-11-08 8:20 ` [kernel-hardening] " Peter Zijlstra
2017-11-08 8:20 ` Peter Zijlstra
2017-11-08 8:20 ` Peter Zijlstra
2017-11-08 3:06 ` [kernel-hardening] " Tobin C. Harding
2017-11-08 3:06 ` Tobin C. Harding
2017-11-08 3:06 ` Tobin C. Harding
2017-11-08 2:05 ` Tobin C. Harding [this message]
2017-11-08 2:05 ` Tobin C. Harding
2017-11-08 2:05 ` Tobin C. Harding
2017-11-08 4:18 ` [kernel-hardening] " Tobin C. Harding
2017-11-08 4:18 ` Tobin C. Harding
2017-11-08 4:18 ` Tobin C. Harding
2017-11-08 3:24 ` [kernel-hardening] " Tobin C. Harding
2017-11-08 3:24 ` Tobin C. Harding
2017-11-08 3:24 ` Tobin C. Harding
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=20171108020538.GZ18478@eros \
--to=me@tobin.cc \
--cc=Golden_Miller83@protonmail.ch \
--cc=Jason@zx2c4.com \
--cc=catalin.marinas@arm.com \
--cc=cfries@google.com \
--cc=danielmicay@gmail.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=ijc@hellion.org.uk \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olorin@google.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=tixxdz@gmail.com \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tycho@docker.com \
--cc=tytso@mit.edu \
--cc=wilal.deacon@arm.com \
--cc=william.c.roberts@intel.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.