From: Kees Cook <keescook@chromium.org>
To: Kristen Carlson Accardi <kristen@linux.intel.com>
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
arjan@linux.intel.com, x86@kernel.org,
linux-kernel@vger.kernel.org,
kernel-hardening@lists.openwall.com, rick.p.edgecombe@intel.com
Subject: Re: [PATCH v2 0/9] Function Granular KASLR
Date: Thu, 21 May 2020 14:54:39 -0700 [thread overview]
Message-ID: <202005211441.F63205B7@keescook> (raw)
In-Reply-To: <20200521165641.15940-1-kristen@linux.intel.com>
On Thu, May 21, 2020 at 09:56:31AM -0700, Kristen Carlson Accardi wrote:
> Changes in v2:
> --------------
> * Fix to address i386 build failure
> * Allow module reordering patch to be configured separately so that
> arm (or other non-x86_64 arches) can take advantage of module function
> reordering. This support has not be tested by me, but smoke tested by
> Ard Biesheuvel <ardb@kernel.org> on arm.
> * Fix build issue when building on arm as reported by
> Ard Biesheuvel <ardb@kernel.org>
> * minor chages for certain checkpatch warnings and review feedback.
I successfully built and booted this on top of linux-next. For my builds
I include:
CONFIG_LOCK_DEBUGGING_SUPPORT=y
CONFIG_PROVE_LOCKING=y
CONFIG_DEBUG_RT_MUTEXES=y
CONFIG_DEBUG_SPINLOCK=y
CONFIG_DEBUG_MUTEXES=y
CONFIG_DEBUG_WW_MUTEX_SLOWPATH=y
CONFIG_DEBUG_RWSEMS=y
CONFIG_DEBUG_LOCK_ALLOC=y
CONFIG_LOCKDEP=y
CONFIG_DEBUG_ATOMIC_SLEEP=y
which catches various things. One of those (I assume either CONFIG_LOCKDEP
or CONFIG_DEBUG_MUTEXES) has found an issue with kallsyms:
[ 34.112989] ------------[ cut here ]------------
[ 34.113560] WARNING: CPU: 1 PID: 1997 at kernel/module.c:260 module_assert_mutex+0x29/0x30
[ 34.114479] Modules linked in:
[ 34.114831] CPU: 1 PID: 1997 Comm: grep Tainted: G W 5.7.0-rc6-next-20200519+ #497
...
[ 34.128556] Call Trace:
[ 34.128867] module_kallsyms_on_each_symbol+0x1d/0xa0
[ 34.130238] kallsyms_on_each_symbol+0xbd/0xd0
[ 34.131642] kallsyms_sorted_open+0x3f/0x70
[ 34.132160] proc_reg_open+0x99/0x180
[ 34.133222] do_dentry_open+0x176/0x400
[ 34.134182] vfs_open+0x2d/0x30
[ 34.134579] do_open.isra.0+0x2a0/0x410
[ 34.135058] path_openat+0x175/0x620
[ 34.135506] do_filp_open+0x91/0x100
[ 34.136912] do_sys_openat2+0x210/0x2d0
[ 34.137388] do_sys_open+0x46/0x80
[ 34.137818] __x64_sys_openat+0x20/0x30
[ 34.138288] do_syscall_64+0x55/0x1d0
[ 34.138720] entry_SYSCALL_64_after_hwframe+0x49/0xb3
Triggering it is easy, just "cat /proc/kallsyms" (and I'd note that I
don't even have any modules loaded). Tracking this down, it just looks
like kallsyms needs to hold a lock while sorting:
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 558963b275ec..182b16a6079b 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -772,7 +772,9 @@ static int kallsyms_sorted_open(struct inode *inode, struct file *file)
INIT_LIST_HEAD(list);
+ mutex_lock(&module_mutex);
ret = kallsyms_on_each_symbol(get_all_symbol_name, list);
+ mutex_unlock(&module_mutex);
if (ret != 0)
return ret;
This fixes it for me. Everything else seems to be lovely. :) Nice work!
--
Kees Cook
next prev parent reply other threads:[~2020-05-21 21:54 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-21 16:56 [PATCH v2 0/9] Function Granular KASLR Kristen Carlson Accardi
2020-05-21 16:56 ` [PATCH v2 1/9] objtool: Do not assume order of parent/child functions Kristen Carlson Accardi
2020-05-21 16:56 ` [PATCH v2 2/9] x86: tools/relocs: Support >64K section headers Kristen Carlson Accardi
2020-05-21 16:56 ` [PATCH v2 3/9] x86/boot: Allow a "silent" kaslr random byte fetch Kristen Carlson Accardi
2020-05-21 16:56 ` [PATCH v2 4/9] x86: Makefile: Add build and config option for CONFIG_FG_KASLR Kristen Carlson Accardi
2020-05-21 20:00 ` Kees Cook
2020-05-21 16:56 ` [PATCH v2 5/9] x86: Make sure _etext includes function sections Kristen Carlson Accardi
2020-05-21 18:11 ` Kees Cook
2020-05-21 16:56 ` [PATCH v2 6/9] x86/tools: Add relative relocs for randomized functions Kristen Carlson Accardi
2020-05-21 19:54 ` Kees Cook
2020-05-21 16:56 ` [PATCH v2 7/9] x86: Add support for function granular KASLR Kristen Carlson Accardi
2020-05-21 21:08 ` Kees Cook
2020-05-21 21:42 ` Kristen Carlson Accardi
2020-06-04 17:27 ` Kristen Carlson Accardi
2020-06-04 22:37 ` Kees Cook
2020-05-21 16:56 ` [PATCH v2 8/9] kallsyms: Hide layout Kristen Carlson Accardi
2020-05-21 21:14 ` Kees Cook
2020-05-21 16:56 ` [PATCH v2 9/9] module: Reorder functions Kristen Carlson Accardi
2020-05-21 21:33 ` Kees Cook
2020-06-09 20:14 ` Kristen Carlson Accardi
2020-06-09 20:42 ` Kees Cook
2020-06-09 20:59 ` Kristen Carlson Accardi
2020-05-21 21:54 ` Kees Cook [this message]
2020-05-21 22:26 ` [PATCH v2 0/9] Function Granular KASLR Thomas Gleixner
2020-05-21 23:30 ` Kees Cook
2020-05-21 23:43 ` Thomas Gleixner
2020-05-21 23:44 ` Kristen Carlson Accardi
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=202005211441.F63205B7@keescook \
--to=keescook@chromium.org \
--cc=arjan@linux.intel.com \
--cc=bp@alien8.de \
--cc=kernel-hardening@lists.openwall.com \
--cc=kristen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rick.p.edgecombe@intel.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;
as well as URLs for NNTP newsgroup(s).