linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* crypto: api - Move module sig ifdef into accessor function
@ 2015-04-22  3:28 Herbert Xu
  2015-04-22  6:59 ` Rusty Russell
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2015-04-22  3:28 UTC (permalink / raw)
  To: Linux Crypto Mailing List, Linux Kernel Mailing List, Rusty Russell

Currently we're hiding mod->sig_ok under an ifdef in open code.
This patch adds a module_sig_ok accessor function and removes that
ifdef.
    
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/crypto/algapi.c b/crypto/algapi.c
index 8057c9f..c63836f 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -44,12 +44,9 @@ static inline int crypto_set_driver_name(struct crypto_alg *alg)
 
 static inline void crypto_check_module_sig(struct module *mod)
 {
-#ifdef CONFIG_CRYPTO_FIPS
-	if (fips_enabled && mod && !mod->sig_ok)
+	if (fips_enabled && mod && !module_sig_ok(mod))
 		panic("Module %s signature verification failed in FIPS mode\n",
 		      mod->name);
-#endif
-	return;
 }
 
 static int crypto_check_alg(struct crypto_alg *alg)
diff --git a/include/linux/module.h b/include/linux/module.h
index c883b86..1e54360 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -655,4 +655,16 @@ static inline void module_bug_finalize(const Elf_Ehdr *hdr,
 static inline void module_bug_cleanup(struct module *mod) {}
 #endif	/* CONFIG_GENERIC_BUG */
 
+#ifdef CONFIG_MODULE_SIG
+static inline bool module_sig_ok(struct module *module)
+{
+	return module->sig_ok;
+}
+#else	/* !CONFIG_MODULE_SIG */
+static inline bool module_sig_ok(struct module *module)
+{
+	return true;
+}
+#endif	/* CONFIG_MODULE_SIG */
+
 #endif /* _LINUX_MODULE_H */
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: crypto: api - Move module sig ifdef into accessor function
  2015-04-22  3:28 crypto: api - Move module sig ifdef into accessor function Herbert Xu
@ 2015-04-22  6:59 ` Rusty Russell
  2015-04-22  8:12   ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Rusty Russell @ 2015-04-22  6:59 UTC (permalink / raw)
  To: Herbert Xu, Linux Crypto Mailing List, Linux Kernel Mailing List

Herbert Xu <herbert@gondor.apana.org.au> writes:
> Currently we're hiding mod->sig_ok under an ifdef in open code.
> This patch adds a module_sig_ok accessor function and removes that
> ifdef.
>     
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Did you want me to take this via modules-next?  Assuming not.

So:
        Acked-by: Rusty Russell <rusty@rustcorp.com.au>

Thanks,
Rusty.

> diff --git a/crypto/algapi.c b/crypto/algapi.c
> index 8057c9f..c63836f 100644
> --- a/crypto/algapi.c
> +++ b/crypto/algapi.c
> @@ -44,12 +44,9 @@ static inline int crypto_set_driver_name(struct crypto_alg *alg)
>  
>  static inline void crypto_check_module_sig(struct module *mod)
>  {
> -#ifdef CONFIG_CRYPTO_FIPS
> -	if (fips_enabled && mod && !mod->sig_ok)
> +	if (fips_enabled && mod && !module_sig_ok(mod))
>  		panic("Module %s signature verification failed in FIPS mode\n",
>  		      mod->name);
> -#endif
> -	return;
>  }
>  
>  static int crypto_check_alg(struct crypto_alg *alg)
> diff --git a/include/linux/module.h b/include/linux/module.h
> index c883b86..1e54360 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -655,4 +655,16 @@ static inline void module_bug_finalize(const Elf_Ehdr *hdr,
>  static inline void module_bug_cleanup(struct module *mod) {}
>  #endif	/* CONFIG_GENERIC_BUG */
>  
> +#ifdef CONFIG_MODULE_SIG
> +static inline bool module_sig_ok(struct module *module)
> +{
> +	return module->sig_ok;
> +}
> +#else	/* !CONFIG_MODULE_SIG */
> +static inline bool module_sig_ok(struct module *module)
> +{
> +	return true;
> +}
> +#endif	/* CONFIG_MODULE_SIG */
> +
>  #endif /* _LINUX_MODULE_H */
> -- 
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: crypto: api - Move module sig ifdef into accessor function
  2015-04-22  6:59 ` Rusty Russell
@ 2015-04-22  8:12   ` Herbert Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2015-04-22  8:12 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Linux Crypto Mailing List, Linux Kernel Mailing List

On Wed, Apr 22, 2015 at 04:29:16PM +0930, Rusty Russell wrote:
> Herbert Xu <herbert@gondor.apana.org.au> writes:
> > Currently we're hiding mod->sig_ok under an ifdef in open code.
> > This patch adds a module_sig_ok accessor function and removes that
> > ifdef.
> >     
> > Cc: Rusty Russell <rusty@rustcorp.com.au>
> > Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> 
> Did you want me to take this via modules-next?  Assuming not.
> 
> So:
>         Acked-by: Rusty Russell <rusty@rustcorp.com.au>

Thanks Rusty.  Yes I'd lik to push this through the crypto tree.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-22  8:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-22  3:28 crypto: api - Move module sig ifdef into accessor function Herbert Xu
2015-04-22  6:59 ` Rusty Russell
2015-04-22  8:12   ` Herbert Xu

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).