From: Peter Zijlstra <peterz@infradead.org>
To: Kees Cook <keescook@chromium.org>
Cc: Tianlin Li <tli@digitalocean.com>,
kernel-hardening@lists.openwall.com,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>,
Russell King <linux@armlinux.org.uk>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Greentime Hu <green.hu@gmail.com>,
Vincent Chen <deanbo422@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>, "H . Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Jessica Yu <jeyu@kernel.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
Petr Mladek <pmladek@suse.com>,
Joe Lawrence <joe.lawrence@redhat.com>
Subject: Re: [RFC PATCH] kernel/module: have the callers of set_memory_*() check the return value
Date: Tue, 19 Nov 2019 22:43:51 +0100 [thread overview]
Message-ID: <20191119214351.GQ3079@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <201911190849.131691D@keescook>
On Tue, Nov 19, 2019 at 09:07:34AM -0800, Kees Cook wrote:
> > diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
> > index bda949fd84e8..7ea1338821d6 100644
> > --- a/arch/arm/kernel/ftrace.c
> > +++ b/arch/arm/kernel/ftrace.c
> > @@ -59,13 +59,15 @@ static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr)
> >
> > int ftrace_arch_code_modify_prepare(void)
> > {
> > - set_all_modules_text_rw();
> > - return 0;
> > + return set_all_modules_text_rw();
> > }
> >
> > int ftrace_arch_code_modify_post_process(void)
> > {
> > - set_all_modules_text_ro();
> > + int ret;
>
> Blank line here...
>
> > + ret = set_all_modules_text_ro();
> > + if (ret)
> > + return ret;
> > /* Make sure any TLB misses during machine stop are cleared. */
> > flush_tlb_all();
> > return 0;
>
> Are callers of these ftrace functions checking return values too?
Aside from the fact that I just deleted the set_all_modules_text_*()
functions, ftrace actually does check the return value. It prvides a
nice WARN and kills ftrace dead.
> > diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
> > index 171773257974..97a89c38f6b9 100644
> > --- a/arch/arm64/kernel/ftrace.c
> > +++ b/arch/arm64/kernel/ftrace.c
> > @@ -115,9 +115,11 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
> > }
> >
> > /* point the trampoline to our ftrace entry point */
> > - module_disable_ro(mod);
> > + if (module_disable_ro(mod))
> > + return -EINVAL;
> > *dst = trampoline;
> > - module_enable_ro(mod, true);
> > + if (module_enable_ro(mod, true))
> > + return -EINVAL;
> >
> > /*
> > * Ensure updated trampoline is visible to instruction
Patching dead code again:
https://lkml.kernel.org/r/20191029165832.33606-5-mark.rutland@arm.com
next prev parent reply other threads:[~2019-11-19 21:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-19 15:51 [RFC PATCH] kernel/module: have the callers of set_memory_*() check the return value Tianlin Li
2019-11-19 17:07 ` Kees Cook
2019-11-19 21:43 ` Peter Zijlstra [this message]
2019-11-19 21:51 ` Tianlin Li
2019-11-19 21:38 ` Peter Zijlstra
2019-11-19 21:54 ` Tianlin Li
2019-11-20 9:58 ` Borislav Petkov
2019-11-20 16:19 ` Tianlin Li
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=20191119214351.GQ3079@worktop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=deanbo422@gmail.com \
--cc=green.hu@gmail.com \
--cc=hpa@zytor.com \
--cc=jeyu@kernel.org \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux@armlinux.org.uk \
--cc=mbenes@suse.cz \
--cc=mingo@redhat.com \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tli@digitalocean.com \
--cc=will@kernel.org \
--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).