From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: Joel Fernandes <joel@joelfernandes.org>
Cc: linux-kernel@vger.kernel.org,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
rostedt@goodmis.org, mathieu.desnoyers@efficios.com,
rcu@vger.kernel.org, kernel-hardening@lists.openwall.com,
kernel-team@android.com, Josh Triplett <josh@joshtriplett.org>,
Lai Jiangshan <jiangshanlai@gmail.com>
Subject: Re: [PATCH] module: Make srcu_struct ptr array as read-only
Date: Thu, 11 Apr 2019 19:35:42 -0700 [thread overview]
Message-ID: <20190412023542.GF14111@linux.ibm.com> (raw)
In-Reply-To: <20190412021422.GA208673@google.com>
On Thu, Apr 11, 2019 at 10:14:22PM -0400, Joel Fernandes wrote:
> On Thu, Apr 11, 2019 at 02:31:55PM -0700, Paul E. McKenney wrote:
> > On Thu, Apr 11, 2019 at 04:24:21PM -0400, Joel Fernandes (Google) wrote:
> > > Since commit title ("srcu: Allocate per-CPU data for DEFINE_SRCU() in
> > > modules"), modules that call DEFINE_{STATIC,}SRCU will have a new array
> > > of srcu_struct pointers, which is used by srcu code to initialize and
> > > clean up these structures and save valuable per-cpu reserved space.
> > >
> > > There is no reason for this array of pointers to be writable, and can
> > > cause security or other hidden bugs. Mark these are read-only after the
> > > module init has completed.
> > >
> > > Tested with the following diff to ensure array not writable:
> > >
> > > (diff is a bit reduced to avoid patch command getting confused)
> > > a/kernel/module.c
> > > b/kernel/module.c
> > > -3506,6 +3506,14 static noinline int do_init_module [snip]
> > > rcu_assign_pointer(mod->kallsyms, &mod->core_kallsyms);
> > > #endif
> > > module_enable_ro(mod, true);
> > > +
> > > + if (mod->srcu_struct_ptrs) {
> > > + // Check if srcu_struct_ptrs access is possible
> > > + char x = *(char *)mod->srcu_struct_ptrs;
> > > + *(char *)mod->srcu_struct_ptrs = 0;
> > > + *(char *)mod->srcu_struct_ptrs = x;
> > > + }
> > > +
> > > mod_tree_remove_init(mod);
> > > disable_ro_nx(&mod->init_layout);
> > > module_arch_freeing_init(mod);
> > >
> > > Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> > > Cc: paulmck@linux.vnet.ibm.com
> > > Cc: rostedt@goodmis.org
> > > Cc: mathieu.desnoyers@efficios.com
> > > Cc: rcu@vger.kernel.org
> > > Cc: kernel-hardening@lists.openwall.com
> > > Cc: kernel-team@android.com
> > > Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> >
> > Queued for testing and further review, thank you, Joel!
>
> Thanks a lot! I also just saw you added the rcutorture module to be built as
> a part kselftests which is really cool ;-)
Just a smoke test, really, but it will be interesting to see how
it goes. ;-)
Thanx, Paul
prev parent reply other threads:[~2019-04-12 2:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-11 20:24 [PATCH] module: Make srcu_struct ptr array as read-only Joel Fernandes (Google)
2019-04-11 21:31 ` Paul E. McKenney
2019-04-12 2:14 ` Joel Fernandes
2019-04-12 2:35 ` Paul E. McKenney [this message]
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=20190412023542.GF14111@linux.ibm.com \
--to=paulmck@linux.ibm.com \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mathieu.desnoyers@efficios.com \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.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).