linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Rusty Russell <rusty@ozlabs.org>
Cc: David Howells <dhowells@redhat.com>,
	Michal Marek <mmarek@suse.cz>,
	linux-kernel@vger.kernel.org,
	James Hogan <james.hogan@imgtec.com>
Subject: Re: [PATCH 2/3] MODSIGN: Avoid using .incbin in C source
Date: Wed, 05 Dec 2012 08:39:11 +0100	[thread overview]
Message-ID: <s5hobi9aqxs.wl%tiwai@suse.de> (raw)
In-Reply-To: <87hao1gyiv.fsf@rustcorp.com.au>

At Wed, 05 Dec 2012 10:28:48 +1030,
Rusty Russell wrote:
> 
> David Howells <dhowells@redhat.com> writes:
> 
> > Michal Marek <mmarek@suse.cz> wrote:
> >
> >> Using the asm .incbin statement in C sources breaks any gcc wrapper which
> >> assumes that preprocessed C source is self-contained. Use a separate .S
> >> file to include the siging key and certificate.
> >
> > I was trying to avoid that as .S files generally don't crop up in generic
> > code and the format of the assembly varies with the arch.  However, you don't
> > seem to have anything that should cause a problem - so:
> >
> > Acked-by: David Howells <dhowells@redhat.com>
> 
> GLOBAL() is defined in x86 only, AFAICT.
> 
> Plus, we now have a patch from James (CC:d) to prepend
> CONFIG_SYMBOL_PREFIX to these as requird.

Yes, I noticed both things yesterday.

> 
> I think this will have to be done more carefully...

How about the revised patch below?


thanks,

Takashi

---
From: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH v2] MODSIGN: Avoid using .incbin in C source

Using the asm .incbin statement in C sources breaks any gcc wrapper which
assumes that preprocessed C source is self-contained. Use a separate .S
file to include the siging key and certificate.

Tested-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 kernel/Makefile              |  4 ++--
 kernel/modsign_certificate.S | 18 ++++++++++++++++++
 kernel/modsign_pubkey.c      |  6 ------
 3 files changed, 20 insertions(+), 8 deletions(-)
 create mode 100644 kernel/modsign_certificate.S

diff --git a/kernel/Makefile b/kernel/Makefile
index 86e3285..0bd9d43 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -54,7 +54,7 @@ obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
 obj-$(CONFIG_PROVE_LOCKING) += spinlock.o
 obj-$(CONFIG_UID16) += uid16.o
 obj-$(CONFIG_MODULES) += module.o
-obj-$(CONFIG_MODULE_SIG) += module_signing.o modsign_pubkey.o
+obj-$(CONFIG_MODULE_SIG) += module_signing.o modsign_pubkey.o modsign_certificate.o
 obj-$(CONFIG_KALLSYMS) += kallsyms.o
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
 obj-$(CONFIG_KEXEC) += kexec.o
@@ -139,7 +139,7 @@ ifeq ($(CONFIG_MODULE_SIG),y)
 extra_certificates:
 	touch $@
 
-kernel/modsign_pubkey.o: signing_key.x509 extra_certificates
+kernel/modsign_certificate.o: signing_key.x509 extra_certificates
 
 ###############################################################################
 #
diff --git a/kernel/modsign_certificate.S b/kernel/modsign_certificate.S
new file mode 100644
index 0000000..695d4e3
--- /dev/null
+++ b/kernel/modsign_certificate.S
@@ -0,0 +1,18 @@
+#ifndef SYMBOL_PREFIX
+#define ASM_SYMBOL(sym) sym
+#else
+#define PASTE2(x,y) x##y
+#define PASTE(x,y) PASTE2(x,y)
+#define ASM_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym)
+#endif
+
+#define GLOBAL(name)	\
+	.globl ASM_SYMBOL(name);	\
+	ASM_SYMBOL(name):
+
+	.section ".init.data","aw"
+
+GLOBAL(modsign_certificate_list)
+	.incbin "signing_key.x509"
+	.incbin "extra_certificates"
+GLOBAL(modsign_certificate_list_end)
diff --git a/kernel/modsign_pubkey.c b/kernel/modsign_pubkey.c
index 767e559..045504f 100644
--- a/kernel/modsign_pubkey.c
+++ b/kernel/modsign_pubkey.c
@@ -20,12 +20,6 @@ struct key *modsign_keyring;
 
 extern __initdata const u8 modsign_certificate_list[];
 extern __initdata const u8 modsign_certificate_list_end[];
-asm(".section .init.data,\"aw\"\n"
-    SYMBOL_PREFIX "modsign_certificate_list:\n"
-    ".incbin \"signing_key.x509\"\n"
-    ".incbin \"extra_certificates\"\n"
-    SYMBOL_PREFIX "modsign_certificate_list_end:"
-    );
 
 /*
  * We need to make sure ccache doesn't cache the .o file as it doesn't notice
-- 
1.8.0.1


  reply	other threads:[~2012-12-05  7:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04 10:18 [PATCH 1/3] MODSIGN: Fix comparison erros in scripts/sign-file Michal Marek
2012-12-04 10:18 ` [PATCH 2/3] MODSIGN: Avoid using .incbin in C source Michal Marek
2012-12-04 10:18 ` [PATCH 3/3] MODSIGN: Drop ccache hack Michal Marek
2012-12-04 18:15 ` [PATCH 1/3] MODSIGN: Fix comparison erros in scripts/sign-file David Howells
2012-12-04 18:17 ` [PATCH 2/3] MODSIGN: Avoid using .incbin in C source David Howells
2012-12-04 23:58   ` Rusty Russell
2012-12-05  7:39     ` Takashi Iwai [this message]
2012-12-05  9:50       ` Michal Marek
2012-12-05 10:06         ` Takashi Iwai
2012-12-05 10:30         ` James Hogan
2012-12-05 11:05           ` Michal Marek
2012-12-05 11:16             ` James Hogan
2012-12-07  4:40         ` Rusty Russell
2012-12-10 10:12           ` James Hogan
2012-12-05 10:30     ` David Howells
2012-12-05 10:54       ` Michal Marek
2012-12-05 12:35     ` David Howells
2012-12-05  7:46   ` Takashi Iwai
2012-12-04 18:29 ` [PATCH 3/3] MODSIGN: Drop ccache hack David Howells
2012-12-04 23:44 ` [PATCH 1/3] MODSIGN: Fix comparison erros in scripts/sign-file Rusty Russell

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=s5hobi9aqxs.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=dhowells@redhat.com \
    --cc=james.hogan@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=rusty@ozlabs.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).