Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753230AbcDZVBH (ORCPT ); Tue, 26 Apr 2016 17:01:07 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39070 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752310AbcDZVBE (ORCPT ); Tue, 26 Apr 2016 17:01:04 -0400 Message-ID: <1461704447.5852.17.camel@decadent.org.uk> Subject: Re: [PATCH 1/3] module: Invalidate signatures on force-loaded modules From: Ben Hutchings To: Rusty Russell Cc: David Howells , David Woodhouse , keyrings@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 26 Apr 2016 23:00:47 +0200 In-Reply-To: <8760v464gr.fsf@rustcorp.com.au> References: <20160423184421.GL3348@decadent.org.uk> <20160423184501.GM3348@decadent.org.uk> <8760v464gr.fsf@rustcorp.com.au> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-m5VyUKYSBLAKLPhUL+O+" X-Mailer: Evolution 3.18.5.1-1 Mime-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8426:ae4:c500:9cba:69ae:962d:6167 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3037 Lines: 80 --=-m5VyUKYSBLAKLPhUL+O+ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2016-04-26 at 20:07 +0930, Rusty Russell wrote: > Ben Hutchings writes: > >=20 > > Signing a module should only make it trusted by the specific kernel it > > was built for, not anything else.=C2=A0=C2=A0Loading a signed module me= ant for a > > kernel with a different ABI could have interesting effects. > > Therefore, treat all signatures as invalid when a module is > > force-loaded. > >=20 > > Signed-off-by: Ben Hutchings > > Cc: stable@vger.kernel.org > > --- > > =C2=A0kernel/module.c | 13 +++++++++---- > > =C2=A01 file changed, 9 insertions(+), 4 deletions(-) > >=20 > > diff --git a/kernel/module.c b/kernel/module.c > > index 66426f743c29..649b1827ed15 100644 > > --- a/kernel/module.c > > +++ b/kernel/module.c > > @@ -2599,13 +2599,18 @@ static inline void kmemleak_load_module(const s= truct module *mod, > > =C2=A0#endif > > =C2=A0 > > =C2=A0#ifdef CONFIG_MODULE_SIG > > -static int module_sig_check(struct load_info *info) > > +static int module_sig_check(struct load_info *info, int flags) > > =C2=A0{ > > =C2=A0 int err =3D -ENOKEY; > > =C2=A0 const unsigned long markerlen =3D sizeof(MODULE_SIG_STRING) - 1; > > =C2=A0 const void *mod =3D info->hdr; > > =C2=A0 > > - if (info->len > markerlen && > > + /* > > + =C2=A0* Require flags =3D=3D 0, as a module with version information > > + =C2=A0* removed is no longer the module that was signed > > + =C2=A0*/ > > + if (flags =3D=3D 0 && > This check is a bit lazy.=C2=A0=C2=A0We could have other flags in future, > so this should really be !(flags & > (MODULE_INIT_IGNORE_MODVERSIONS|MODULE_INIT_IGNORE_VERMAGIC) right? Yes we could, but I'd prefer this to fail-safe in case no-one thinks about whether it should be updated then. Ben. --=20 Ben Hutchings The generation of random numbers is too important to be left to chance. - Robert Coveyo= u --=-m5VyUKYSBLAKLPhUL+O+ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCgAGBQJXH9b/AAoJEOe/yOyVhhEJ+MwQANSouaoyfhnrptYEuSmCQQ3R s0+nE2uPYq6P/TpzF93DpdqTEqtYS8iWN6DgOfsmDdX4Z2HUfiRxuf8E51+olpMS m6i+kixSluqVxSftmF/iWy8Xg0mdKr8rrvtxbkSiZ8NtM/lu4w0LqWjKy/SrI8UC 28RSZZV6nrm65LsHHG9OTLmj0NKvpjVZobJNnDCZU2zbpGWVC57nZKRiH8QCX3nI 6zvvpYAw8SHcr34WqLYn/j8DvriOuxboYwKWIxXuxWnaquMFe+Qu1p/fWENW0kn7 s9uSVlmLBH+NxYYF0OGszsZRej+st6CQ8I6thwL0D5ntq8QTXXnTnnWW/iKWZbkK urGQrOeIluiXd9qgvsf/orxWzGcNpCt/pGDvhoWk6xtAbfpCfisvmX7agS4xSKM5 yH/AnORV6BJfuvMizGs4luPLPmoR2HtOV4t9BH3P7fv3+lVxzQbaCfPUnj+zZQ5u e8RYFlkvFJovpM+RLVyWsZd8s806C6rjBrGmidnyhY1kauUCWORs7K8upPJkN+sm 1Irx2hWHQMJLPddwvkQ9VIyILxm11G6kYBey+qo/kKa3s5jLDE4bkroOZJrvXxxh +5Q3nIMKYC5FTM1M5Od4r8WYzFQ3McQUuaswOOekVrrgmKbuP3wVaDWqfoEbOGM9 r8zFECWTlGBveCa/zMuN =JH0/ -----END PGP SIGNATURE----- --=-m5VyUKYSBLAKLPhUL+O+--