Skip to content

Commit 8370ede

Browse files
rhvgoyaltorvalds
authored andcommitted
bin2c: move bin2c in scripts/basic
This patch series does not do kernel signature verification yet. I plan to post another patch series for that. Now distributions are already signing PE/COFF bzImage with PKCS7 signature I plan to parse and verify those signatures. Primary goal of this patchset is to prepare groundwork so that kernel image can be signed and signatures be verified during kexec load. This should help with two things. - It should allow kexec/kdump on secureboot enabled machines. - In general it can help even without secureboot. By being able to verify kernel image signature in kexec, it should help with avoiding module signing restrictions. Matthew Garret showed how to boot into a custom kernel, modify first kernel's memory and then jump back to old kernel and bypass any policy one wants to. This patch (of 15): Kexec wants to use bin2c and it wants to use it really early in the build process. See arch/x86/purgatory/ code in later patches. So move bin2c in scripts/basic so that it can be built very early and be usable by arch/x86/purgatory/ Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Cc: Borislav Petkov <bp@suse.de> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Cc: Yinghai Lu <yinghai@kernel.org> Cc: Eric Biederman <ebiederm@xmission.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Matthew Garrett <mjg59@srcf.ucam.org> Cc: Greg Kroah-Hartman <greg@kroah.com> Cc: Dave Young <dyoung@redhat.com> Cc: WANG Chao <chaowang@redhat.com> Cc: Baoquan He <bhe@redhat.com> Cc: Andy Lutomirski <luto@amacapital.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 05f65b5 commit 8370ede

File tree

6 files changed

+6
-7
lines changed

6 files changed

+6
-7
lines changed

kernel/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ targets += config_data.gz
105105
$(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
106106
$(call if_changed,gzip)
107107

108-
filechk_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/bin2c; echo "MAGIC_END;")
108+
filechk_ikconfiggz = (echo "static const char kernel_config_data[] __used = MAGIC_START"; cat $< | scripts/basic/bin2c; echo "MAGIC_END;")
109109
targets += config_data.h
110110
$(obj)/config_data.h: $(obj)/config_data.gz FORCE
111111
$(call filechk,ikconfiggz)

scripts/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
conmakehash
55
kallsyms
66
pnmtologo
7-
bin2c
87
unifdef
98
ihex2fw
109
recordmcount

scripts/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ HOST_EXTRACFLAGS += -I$(srctree)/tools/include
1313
hostprogs-$(CONFIG_KALLSYMS) += kallsyms
1414
hostprogs-$(CONFIG_LOGO) += pnmtologo
1515
hostprogs-$(CONFIG_VT) += conmakehash
16-
hostprogs-$(CONFIG_IKCONFIG) += bin2c
1716
hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount
1817
hostprogs-$(CONFIG_BUILDTIME_EXTABLE_SORT) += sortextable
1918
hostprogs-$(CONFIG_ASN1) += asn1_compiler

scripts/basic/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
fixdep
2+
bin2c

scripts/basic/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# fixdep: Used to generate dependency information during build process
1010

1111
hostprogs-y := fixdep
12+
hostprogs-$(CONFIG_IKCONFIG) += bin2c
1213
always := $(hostprogs-y)
1314

1415
# fixdep is needed to compile other host programs

scripts/bin2c.c scripts/basic/bin2c.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@
1111

1212
int main(int argc, char *argv[])
1313
{
14-
int ch, total=0;
14+
int ch, total = 0;
1515

1616
if (argc > 1)
1717
printf("const char %s[] %s=\n",
1818
argv[1], argc > 2 ? argv[2] : "");
1919

2020
do {
2121
printf("\t\"");
22-
while ((ch = getchar()) != EOF)
23-
{
22+
while ((ch = getchar()) != EOF) {
2423
total++;
25-
printf("\\x%02x",ch);
24+
printf("\\x%02x", ch);
2625
if (total % 16 == 0)
2726
break;
2827
}

0 commit comments

Comments
 (0)