From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
To: "keescook@chromium.org" <keescook@chromium.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"daniel@iogearbox.net" <daniel@iogearbox.net>,
"jannh@google.com" <jannh@google.com>,
"arjan@linux.intel.com" <arjan@linux.intel.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"x86@kernel.org" <x86@kernel.org>,
"kristen@linux.intel.com" <kristen@linux.intel.com>,
"hpa@zytor.com" <hpa@zytor.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"alexei.starovoitov@gmail.com" <alexei.starovoitov@gmail.com>,
"kernel-hardening@lists.openwall.com"
<kernel-hardening@lists.openwall.com>,
"Hansen, Dave" <dave.hansen@intel.com>
Subject: Re: [PATCH v6 3/4] vmalloc: Add debugfs modfraginfo
Date: Mon, 24 Sep 2018 18:58:44 +0000 [thread overview]
Message-ID: <1537815554.19013.49.camel@intel.com> (raw)
In-Reply-To: <CAGXu5jJj+08J9UeyQs5ku8CziYWA72iJ+hxMR2Z2tLiVwvU8MA@mail.gmail.com>
On Fri, 2018-09-21 at 11:56 -0700, Kees Cook wrote:
> On Thu, Sep 13, 2018 at 2:31 PM, Rick Edgecombe
> <rick.p.edgecombe@intel.com> wrote:
> > +done:
> > + gap = (MODULES_END - last_end);
> > + if (gap > largest_free)
> > + largest_free = gap;
> > + total_free += gap;
> > +
> > + spin_unlock(&vmap_area_lock);
> > +
> > + seq_printf(m, "\tLargest free space:\t%lu kB\n", largest_free /
> > 1024);
> > + seq_printf(m, "\t Total free space:\t%lu kB\n", total_free / 1024);
> > +
> > + if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_enabled())
> > + seq_printf(m, "Allocations in backup area:\t%lu\n",
> > backup_cnt);
> I don't think the IS_ENABLED is needed here?
The reason for this is that for ARCH=um, CONFIG_X86_64 is defined but
kaslr_enabled is not. kaslr_enabled is declared above to protect against a
compiler error.
So IS_ENABLED(CONFIG_RANDOMIZE_BASE) is protecting kaslr_enabled from causing a
linker error. It gets constant evaluated to 0 and the compiler optimizes out the
kaslr_enabled call. Thought it was better to guard with CONFIG_RANDOMIZE_BASE
than with CONFIG_UM, to try to catch the broader situation. I guess I could move
it to a helper inside ifdefs instead. Was trying to keep the ifdef-ed code down.
> I wonder if there is a better way to arrange this code that uses fewer
> ifdefs, etc. Maybe a single CONFIG that capture whether or not
> fine-grained module randomization is built in, like:
>
> config RANDOMIZE_FINE_MODULE
> def_bool y if RANDOMIZE_BASE && X86_64
>
> #ifdef CONFIG_RANDOMIZE_FINE_MODULE
> ...
> #endif
>
> But that doesn't capture the DEBUG_FS and PROC_FS bits ... so ...
> maybe not worth it. I guess, either way:
Hmmm, didn't know about that. Would clean it up some at least.
I wish the debugfs info could be in module.c to help with this IFDEFs, but it
needs vmalloc internals. MODULES_VADDR is not standardized across the ARCH's as
well, so this was my best attempt to implement this without having to make
changes in other architectures.
> Reviewed-by: Kees Cook <keescook@chromium.org>
>
> -Kees
>
next prev parent reply other threads:[~2018-09-24 18:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-13 21:31 [PATCH v6 0/4] KASLR feature to randomize each loadable module Rick Edgecombe
2018-09-13 21:31 ` [PATCH v6 1/4] vmalloc: Add __vmalloc_node_try_addr function Rick Edgecombe
2018-09-21 18:46 ` Kees Cook
2018-09-13 21:31 ` [PATCH v6 2/4] x86/modules: Increase randomization for modules Rick Edgecombe
2018-09-21 19:05 ` Kees Cook
2018-09-24 18:57 ` Edgecombe, Rick P
2018-09-24 19:58 ` Kees Cook
2018-09-24 21:27 ` Edgecombe, Rick P
2018-09-24 21:29 ` Kees Cook
2018-09-13 21:31 ` [PATCH v6 3/4] vmalloc: Add debugfs modfraginfo Rick Edgecombe
2018-09-21 18:56 ` Kees Cook
2018-09-24 18:58 ` Edgecombe, Rick P [this message]
2018-09-24 20:03 ` Kees Cook
2018-09-13 21:31 ` [PATCH v6 4/4] Kselftest for module text allocation benchmarking Rick Edgecombe
2018-09-18 0:27 ` kbuild test robot
2018-09-21 19:05 ` [PATCH v6 0/4] KASLR feature to randomize each loadable module 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=1537815554.19013.49.camel@intel.com \
--to=rick.p.edgecombe@intel.com \
--cc=alexei.starovoitov@gmail.com \
--cc=arjan@linux.intel.com \
--cc=daniel@iogearbox.net \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=jannh@google.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=kristen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--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