History

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/

Vivek Goyal committed 12 years ago

Commit 8370ede1 parent 05f65b56 files · +6 −7Browse files

Showing the changes to scripts/basic (3 of 6 files). Show all

Unified · Split

3 files
  1. scripts/basic/.gitignore +1 −0
  2. scripts/basic/Makefile +1 −0
  3. scripts/basic/bin2c.c +35 −0
scripts/basic/.gitignore+1−0
@@ -1 +1,2 @@
11 fixdep
2+bin2c
scripts/basic/Makefile+1−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
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/basic/bin2c.c+35−0
@@ -0,0 +1,35 @@
1+/*
2+ * Unloved program to convert a binary on stdin to a C include on stdout
3+ *
4+ * Jan 1999 Matt Mackall <mpm@selenic.com>
5+ *
6+ * This software may be used and distributed according to the terms
7+ * of the GNU General Public License, incorporated herein by reference.
8+ */
9+
10+#include <stdio.h>
11+
12+int main(int argc, char *argv[])
13+{
14+ int ch, total = 0;
15+
16+ if (argc > 1)
17+ printf("const char %s[] %s=\n",
18+ argv[1], argc > 2 ? argv[2] : "");
19+
20+ do {
21+ printf("\t\"");
22+ while ((ch = getchar()) != EOF) {
23+ total++;
24+ printf("\\x%02x", ch);
25+ if (total % 16 == 0)
26+ break;
27+ }
28+ printf("\"\n");
29+ } while (ch != EOF);
30+
31+ if (argc > 1)
32+ printf("\t;\n\nconst int %s_size = %d;\n", argv[1], total);
33+
34+ return 0;
35+}