lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191024183115.jomddpijq5u453qc@treble>
Date:   Thu, 24 Oct 2019 13:31:15 -0500
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     x86@...nel.org, linux-kernel@...r.kernel.org, rostedt@...dmis.org,
        mhiramat@...nel.org, bristot@...hat.com, jbaron@...mai.com,
        torvalds@...ux-foundation.org, tglx@...utronix.de,
        mingo@...nel.org, namit@...are.com, hpa@...or.com, luto@...nel.org,
        ard.biesheuvel@...aro.org, jeyu@...nel.org
Subject: Re: [PATCH v4 15/16] module: Move where we mark modules RO,X

On Thu, Oct 24, 2019 at 12:59:04PM +0200, Peter Zijlstra wrote:
> On Wed, Oct 23, 2019 at 12:15:14PM -0500, Josh Poimboeuf wrote:
> > On Wed, Oct 23, 2019 at 05:16:54PM +0200, Peter Zijlstra wrote:
> > > @@ -157,6 +158,14 @@ static int __apply_relocate_add(Elf64_Sh
> > >  
> > >  		val = sym->st_value + rel[i].r_addend;
> > >  
> > > +		/*
> > > +		 * .klp.rela.* sections should only contain module
> > > +		 * related RELAs. All core-kernel RELAs should be in
> > > +		 * normal .rela.* sections and be applied when loading
> > > +		 * the patch module itself.
> > > +		 */
> > > +		WARN_ON_ONCE(klp && core_kernel_text(val));
> > > +
> > 
> > This isn't quite true, we also use .klp.rela sections to access
> > unexported vmlinux symbols.
> 
> Yes, you said in that earlier email. That all makes it really hard to
> validate this. But unless we validate it, it will stay buggy :/
> 
> Hmmm.... /me ponders
> 
> The alternative would be to apply the .klp.rela.* sections twice, once
> at patch-module load time and then apply those core_kernel_text()
> entries, and then once later and skip over them.
> 
> How's this?

How about something like this?  Completely untested, but if you agree
with this approach I could hack up kpatch-build to test it properly.

diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index ab4a4606d19b..597bf32bc591 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -239,6 +239,17 @@ static int klp_resolve_symbols(Elf_Shdr *relasec, struct module *pmod)
 		if (ret)
 			return ret;
 
+		/*
+		 * Prevent module patches from using livepatch relas for
+		 * vmlinux symbols.  Presumably such symbols are exported and
+		 * normal relas can instead be used at patch module loading
+		 * time.
+		 */
+		if (!vmlinux && core_kernel_text(addr)) {
+			pr_err("unsupported livepatch symbol\n");
+			return -EINVAL;
+		}
+
 		sym->st_value = addr;
 	}
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ