diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.asm-generic | 2 | ||||
-rw-r--r-- | scripts/Makefile.fwinst | 4 | ||||
-rw-r--r-- | scripts/Makefile.lib | 3 | ||||
-rw-r--r-- | scripts/Makefile.modinst | 3 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 77 | ||||
-rw-r--r-- | scripts/Makefile.modsign | 32 | ||||
-rwxr-xr-x | scripts/checkpatch.pl | 156 | ||||
-rw-r--r-- | scripts/coccinelle/api/d_find_alias.cocci | 80 | ||||
-rw-r--r-- | scripts/coccinelle/misc/warn.cocci | 109 | ||||
-rwxr-xr-x | scripts/config | 1 | ||||
-rw-r--r-- | scripts/dtc/Makefile | 2 | ||||
-rw-r--r-- | scripts/dtc/dtc.h | 44 | ||||
-rw-r--r-- | scripts/headers_install.pl | 3 | ||||
-rw-r--r-- | scripts/kconfig/expr.h | 5 | ||||
-rw-r--r-- | scripts/kconfig/list.h | 91 | ||||
-rw-r--r-- | scripts/kconfig/lkc_proto.h | 4 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/dialog.h | 1 | ||||
-rw-r--r-- | scripts/kconfig/mconf.c | 6 | ||||
-rw-r--r-- | scripts/kconfig/menu.c | 14 | ||||
-rwxr-xr-x | scripts/kernel-doc | 34 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 24 | ||||
-rw-r--r-- | scripts/pnmtologo.c | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/sign-file | 498 | ||||
-rw-r--r-- | scripts/sortextable.c | 1 | ||||
-rwxr-xr-x | scripts/tags.sh | 57 | ||||
-rwxr-xr-x | scripts/x509keyid | 268 |
26 files changed, 950 insertions, 576 deletions
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic index 40caf3c26cd5..d17e0ea911ed 100644 --- a/scripts/Makefile.asm-generic +++ b/scripts/Makefile.asm-generic | |||
@@ -5,7 +5,7 @@ | |||
5 | # and for each file listed in this file with generic-y creates | 5 | # and for each file listed in this file with generic-y creates |
6 | # a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) | 6 | # a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) |
7 | 7 | ||
8 | kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild | 8 | kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild |
9 | -include $(kbuild-file) | 9 | -include $(kbuild-file) |
10 | 10 | ||
11 | include scripts/Kbuild.include | 11 | include scripts/Kbuild.include |
diff --git a/scripts/Makefile.fwinst b/scripts/Makefile.fwinst index c3f69ae275d1..4d908d16c035 100644 --- a/scripts/Makefile.fwinst +++ b/scripts/Makefile.fwinst | |||
@@ -27,7 +27,7 @@ endif | |||
27 | installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) | 27 | installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) |
28 | 28 | ||
29 | installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) | 29 | installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) |
30 | installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/. | 30 | installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/./ |
31 | 31 | ||
32 | # Workaround for make < 3.81, where .SECONDEXPANSION doesn't work. | 32 | # Workaround for make < 3.81, where .SECONDEXPANSION doesn't work. |
33 | PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs | 33 | PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs |
@@ -42,7 +42,7 @@ quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@) | |||
42 | $(installed-fw-dirs): | 42 | $(installed-fw-dirs): |
43 | $(call cmd,mkdir) | 43 | $(call cmd,mkdir) |
44 | 44 | ||
45 | $(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $$(dir $(INSTALL_FW_PATH)/%) | 45 | $(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $(INSTALL_FW_PATH)/$$(dir %) |
46 | $(call cmd,install) | 46 | $(call cmd,install) |
47 | 47 | ||
48 | PHONY += __fw_install __fw_modinst FORCE | 48 | PHONY += __fw_install __fw_modinst FORCE |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0be6f110cce7..bdf42fdf64c9 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -266,6 +266,9 @@ $(obj)/%.dtb.S: $(obj)/%.dtb | |||
266 | quiet_cmd_dtc = DTC $@ | 266 | quiet_cmd_dtc = DTC $@ |
267 | cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile) $< | 267 | cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile) $< |
268 | 268 | ||
269 | $(obj)/%.dtb: $(src)/%.dts FORCE | ||
270 | $(call if_changed_dep,dtc) | ||
271 | |||
269 | # Bzip2 | 272 | # Bzip2 |
270 | # --------------------------------------------------------------------------- | 273 | # --------------------------------------------------------------------------- |
271 | 274 | ||
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 3d13d3a3edfe..ecbb44797e28 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst | |||
@@ -16,8 +16,9 @@ PHONY += $(modules) | |||
16 | __modinst: $(modules) | 16 | __modinst: $(modules) |
17 | @: | 17 | @: |
18 | 18 | ||
19 | # Don't stop modules_install if we can't sign external modules. | ||
19 | quiet_cmd_modules_install = INSTALL $@ | 20 | quiet_cmd_modules_install = INSTALL $@ |
20 | cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) | 21 | cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) ; $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) |
21 | 22 | ||
22 | # Modules built outside the kernel source tree go into extra by default | 23 | # Modules built outside the kernel source tree go into extra by default |
23 | INSTALL_MOD_DIR ?= extra | 24 | INSTALL_MOD_DIR ?= extra |
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 002089141df4..a1cb0222ebe6 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -14,8 +14,7 @@ | |||
14 | # 3) create one <module>.mod.c file pr. module | 14 | # 3) create one <module>.mod.c file pr. module |
15 | # 4) create one Module.symvers file with CRC for all exported symbols | 15 | # 4) create one Module.symvers file with CRC for all exported symbols |
16 | # 5) compile all <module>.mod.c files | 16 | # 5) compile all <module>.mod.c files |
17 | # 6) final link of the module to a <module.ko> (or <module.unsigned>) file | 17 | # 6) final link of the module to a <module.ko> file |
18 | # 7) signs the modules to a <module.ko> file | ||
19 | 18 | ||
20 | # Step 3 is used to place certain information in the module's ELF | 19 | # Step 3 is used to place certain information in the module's ELF |
21 | # section, including information such as: | 20 | # section, including information such as: |
@@ -33,8 +32,6 @@ | |||
33 | # Step 4 is solely used to allow module versioning in external modules, | 32 | # Step 4 is solely used to allow module versioning in external modules, |
34 | # where the CRC of each module is retrieved from the Module.symvers file. | 33 | # where the CRC of each module is retrieved from the Module.symvers file. |
35 | 34 | ||
36 | # Step 7 is dependent on CONFIG_MODULE_SIG being enabled. | ||
37 | |||
38 | # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined | 35 | # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined |
39 | # symbols in the final module linking stage | 36 | # symbols in the final module linking stage |
40 | # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. | 37 | # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. |
@@ -119,7 +116,6 @@ $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE | |||
119 | targets += $(modules:.ko=.mod.o) | 116 | targets += $(modules:.ko=.mod.o) |
120 | 117 | ||
121 | # Step 6), final link of the modules | 118 | # Step 6), final link of the modules |
122 | ifneq ($(CONFIG_MODULE_SIG),y) | ||
123 | quiet_cmd_ld_ko_o = LD [M] $@ | 119 | quiet_cmd_ld_ko_o = LD [M] $@ |
124 | cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \ | 120 | cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \ |
125 | $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ | 121 | $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ |
@@ -129,78 +125,7 @@ $(modules): %.ko :%.o %.mod.o FORCE | |||
129 | $(call if_changed,ld_ko_o) | 125 | $(call if_changed,ld_ko_o) |
130 | 126 | ||
131 | targets += $(modules) | 127 | targets += $(modules) |
132 | else | ||
133 | quiet_cmd_ld_ko_unsigned_o = LD [M] $@ | ||
134 | cmd_ld_ko_unsigned_o = \ | ||
135 | $(LD) -r $(LDFLAGS) \ | ||
136 | $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ | ||
137 | -o $@ $(filter-out FORCE,$^) \ | ||
138 | $(if $(AFTER_LINK),; $(AFTER_LINK)) | ||
139 | |||
140 | $(modules:.ko=.ko.unsigned): %.ko.unsigned :%.o %.mod.o FORCE | ||
141 | $(call if_changed,ld_ko_unsigned_o) | ||
142 | |||
143 | targets += $(modules:.ko=.ko.unsigned) | ||
144 | |||
145 | # Step 7), sign the modules | ||
146 | MODSECKEY = ./signing_key.priv | ||
147 | MODPUBKEY = ./signing_key.x509 | ||
148 | |||
149 | ifeq ($(wildcard $(MODSECKEY))+$(wildcard $(MODPUBKEY)),$(MODSECKEY)+$(MODPUBKEY)) | ||
150 | ifeq ($(KBUILD_SRC),) | ||
151 | # no O= is being used | ||
152 | SCRIPTS_DIR := scripts | ||
153 | else | ||
154 | SCRIPTS_DIR := $(KBUILD_SRC)/scripts | ||
155 | endif | ||
156 | SIGN_MODULES := 1 | ||
157 | else | ||
158 | SIGN_MODULES := 0 | ||
159 | endif | ||
160 | |||
161 | # only sign if it's an in-tree module | ||
162 | ifneq ($(KBUILD_EXTMOD),) | ||
163 | SIGN_MODULES := 0 | ||
164 | endif | ||
165 | 128 | ||
166 | # We strip the module as best we can - note that using both strip and eu-strip | ||
167 | # results in a smaller module than using either alone. | ||
168 | EU_STRIP = $(shell which eu-strip || echo true) | ||
169 | |||
170 | quiet_cmd_sign_ko_stripped_ko_unsigned = STRIP [M] $@ | ||
171 | cmd_sign_ko_stripped_ko_unsigned = \ | ||
172 | cp $< $@ && \ | ||
173 | strip -x -g $@ && \ | ||
174 | $(EU_STRIP) $@ | ||
175 | |||
176 | ifeq ($(SIGN_MODULES),1) | ||
177 | |||
178 | quiet_cmd_genkeyid = GENKEYID $@ | ||
179 | cmd_genkeyid = \ | ||
180 | perl $(SCRIPTS_DIR)/x509keyid $< $<.signer $<.keyid | ||
181 | |||
182 | %.signer %.keyid: % | ||
183 | $(call if_changed,genkeyid) | ||
184 | |||
185 | KEYRING_DEP := $(MODSECKEY) $(MODPUBKEY) $(MODPUBKEY).signer $(MODPUBKEY).keyid | ||
186 | quiet_cmd_sign_ko_ko_stripped = SIGN [M] $@ | ||
187 | cmd_sign_ko_ko_stripped = \ | ||
188 | sh $(SCRIPTS_DIR)/sign-file $(MODSECKEY) $(MODPUBKEY) $< $@ | ||
189 | else | ||
190 | KEYRING_DEP := | ||
191 | quiet_cmd_sign_ko_ko_unsigned = NO SIGN [M] $@ | ||
192 | cmd_sign_ko_ko_unsigned = \ | ||
193 | cp $< $@ | ||
194 | endif | ||
195 | |||
196 | $(modules): %.ko :%.ko.stripped $(KEYRING_DEP) FORCE | ||
197 | $(call if_changed,sign_ko_ko_stripped) | ||
198 | |||
199 | $(patsubst %.ko,%.ko.stripped,$(modules)): %.ko.stripped :%.ko.unsigned FORCE | ||
200 | $(call if_changed,sign_ko_stripped_ko_unsigned) | ||
201 | |||
202 | targets += $(modules) | ||
203 | endif | ||
204 | 129 | ||
205 | # Add FORCE to the prequisites of a target to force it to be always rebuilt. | 130 | # Add FORCE to the prequisites of a target to force it to be always rebuilt. |
206 | # --------------------------------------------------------------------------- | 131 | # --------------------------------------------------------------------------- |
diff --git a/scripts/Makefile.modsign b/scripts/Makefile.modsign new file mode 100644 index 000000000000..abfda626dbad --- /dev/null +++ b/scripts/Makefile.modsign | |||
@@ -0,0 +1,32 @@ | |||
1 | # ========================================================================== | ||
2 | # Signing modules | ||
3 | # ========================================================================== | ||
4 | |||
5 | PHONY := __modsign | ||
6 | __modsign: | ||
7 | |||
8 | include scripts/Kbuild.include | ||
9 | |||
10 | __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) | ||
11 | modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) | ||
12 | |||
13 | PHONY += $(modules) | ||
14 | __modsign: $(modules) | ||
15 | @: | ||
16 | |||
17 | quiet_cmd_sign_ko = SIGN [M] $(2)/$(notdir $@) | ||
18 | cmd_sign_ko = $(mod_sign_cmd) $(2)/$(notdir $@) | ||
19 | |||
20 | # Modules built outside the kernel source tree go into extra by default | ||
21 | INSTALL_MOD_DIR ?= extra | ||
22 | ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)) | ||
23 | |||
24 | modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) | ||
25 | |||
26 | $(modules): | ||
27 | $(call cmd,sign_ko,$(MODLIB)/$(modinst_dir)) | ||
28 | |||
29 | # Declare the contents of the .PHONY variable as phony. We keep that | ||
30 | # information in a variable se we can use it in if_changed and friends. | ||
31 | |||
32 | .PHONY: $(PHONY) | ||
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 21a9f5de0a21..4d2c7dfdaabd 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -33,6 +33,7 @@ my %ignore_type = (); | |||
33 | my @ignore = (); | 33 | my @ignore = (); |
34 | my $help = 0; | 34 | my $help = 0; |
35 | my $configuration_file = ".checkpatch.conf"; | 35 | my $configuration_file = ".checkpatch.conf"; |
36 | my $max_line_length = 80; | ||
36 | 37 | ||
37 | sub help { | 38 | sub help { |
38 | my ($exitcode) = @_; | 39 | my ($exitcode) = @_; |
@@ -51,6 +52,7 @@ Options: | |||
51 | -f, --file treat FILE as regular source file | 52 | -f, --file treat FILE as regular source file |
52 | --subjective, --strict enable more subjective tests | 53 | --subjective, --strict enable more subjective tests |
53 | --ignore TYPE(,TYPE2...) ignore various comma separated message types | 54 | --ignore TYPE(,TYPE2...) ignore various comma separated message types |
55 | --max-line-length=n set the maximum line length, if exceeded, warn | ||
54 | --show-types show the message "types" in the output | 56 | --show-types show the message "types" in the output |
55 | --root=PATH PATH to the kernel tree root | 57 | --root=PATH PATH to the kernel tree root |
56 | --no-summary suppress the per-file summary | 58 | --no-summary suppress the per-file summary |
@@ -107,6 +109,7 @@ GetOptions( | |||
107 | 'strict!' => \$check, | 109 | 'strict!' => \$check, |
108 | 'ignore=s' => \@ignore, | 110 | 'ignore=s' => \@ignore, |
109 | 'show-types!' => \$show_types, | 111 | 'show-types!' => \$show_types, |
112 | 'max-line-length=i' => \$max_line_length, | ||
110 | 'root=s' => \$root, | 113 | 'root=s' => \$root, |
111 | 'summary!' => \$summary, | 114 | 'summary!' => \$summary, |
112 | 'mailback!' => \$mailback, | 115 | 'mailback!' => \$mailback, |
@@ -227,7 +230,11 @@ our $Inline = qr{inline|__always_inline|noinline}; | |||
227 | our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; | 230 | our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; |
228 | our $Lval = qr{$Ident(?:$Member)*}; | 231 | our $Lval = qr{$Ident(?:$Member)*}; |
229 | 232 | ||
230 | our $Constant = qr{(?i:(?:[0-9]+|0x[0-9a-f]+)[ul]*)}; | 233 | our $Float_hex = qr{(?i:0x[0-9a-f]+p-?[0-9]+[fl]?)}; |
234 | our $Float_dec = qr{(?i:((?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?))}; | ||
235 | our $Float_int = qr{(?i:[0-9]+e-?[0-9]+[fl]?)}; | ||
236 | our $Float = qr{$Float_hex|$Float_dec|$Float_int}; | ||
237 | our $Constant = qr{(?:$Float|(?i:(?:0x[0-9a-f]+|[0-9]+)[ul]*))}; | ||
231 | our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)}; | 238 | our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)}; |
232 | our $Compare = qr{<=|>=|==|!=|<|>}; | 239 | our $Compare = qr{<=|>=|==|!=|<|>}; |
233 | our $Operators = qr{ | 240 | our $Operators = qr{ |
@@ -352,27 +359,6 @@ sub deparenthesize { | |||
352 | 359 | ||
353 | $chk_signoff = 0 if ($file); | 360 | $chk_signoff = 0 if ($file); |
354 | 361 | ||
355 | my @dep_includes = (); | ||
356 | my @dep_functions = (); | ||
357 | my $removal = "Documentation/feature-removal-schedule.txt"; | ||
358 | if ($tree && -f "$root/$removal") { | ||
359 | open(my $REMOVE, '<', "$root/$removal") || | ||
360 | die "$P: $removal: open failed - $!\n"; | ||
361 | while (<$REMOVE>) { | ||
362 | if (/^Check:\s+(.*\S)/) { | ||
363 | for my $entry (split(/[, ]+/, $1)) { | ||
364 | if ($entry =~ m@include/(.*)@) { | ||
365 | push(@dep_includes, $1); | ||
366 | |||
367 | } elsif ($entry !~ m@/@) { | ||
368 | push(@dep_functions, $entry); | ||
369 | } | ||
370 | } | ||
371 | } | ||
372 | } | ||
373 | close($REMOVE); | ||
374 | } | ||
375 | |||
376 | my @rawlines = (); | 362 | my @rawlines = (); |
377 | my @lines = (); | 363 | my @lines = (); |
378 | my $vname; | 364 | my $vname; |
@@ -1412,6 +1398,8 @@ sub process { | |||
1412 | my %suppress_export; | 1398 | my %suppress_export; |
1413 | my $suppress_statement = 0; | 1399 | my $suppress_statement = 0; |
1414 | 1400 | ||
1401 | my %camelcase = (); | ||
1402 | |||
1415 | # Pre-scan the patch sanitizing the lines. | 1403 | # Pre-scan the patch sanitizing the lines. |
1416 | # Pre-scan the patch looking for any __setup documentation. | 1404 | # Pre-scan the patch looking for any __setup documentation. |
1417 | # | 1405 | # |
@@ -1757,6 +1745,13 @@ sub process { | |||
1757 | #print "is_start<$is_start> is_end<$is_end> length<$length>\n"; | 1745 | #print "is_start<$is_start> is_end<$is_end> length<$length>\n"; |
1758 | } | 1746 | } |
1759 | 1747 | ||
1748 | # discourage the addition of CONFIG_EXPERIMENTAL in Kconfig. | ||
1749 | if ($realfile =~ /Kconfig/ && | ||
1750 | $line =~ /.\s*depends on\s+.*\bEXPERIMENTAL\b/) { | ||
1751 | WARN("CONFIG_EXPERIMENTAL", | ||
1752 | "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n"); | ||
1753 | } | ||
1754 | |||
1760 | if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && | 1755 | if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && |
1761 | ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { | 1756 | ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { |
1762 | my $flag = $1; | 1757 | my $flag = $1; |
@@ -1774,15 +1769,15 @@ sub process { | |||
1774 | # check we are in a valid source file if not then ignore this hunk | 1769 | # check we are in a valid source file if not then ignore this hunk |
1775 | next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); | 1770 | next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); |
1776 | 1771 | ||
1777 | #80 column limit | 1772 | #line length limit |
1778 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && | 1773 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && |
1779 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && | 1774 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && |
1780 | !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ || | 1775 | !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ || |
1781 | $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && | 1776 | $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && |
1782 | $length > 80) | 1777 | $length > $max_line_length) |
1783 | { | 1778 | { |
1784 | WARN("LONG_LINE", | 1779 | WARN("LONG_LINE", |
1785 | "line over 80 characters\n" . $herecurr); | 1780 | "line over $max_line_length characters\n" . $herecurr); |
1786 | } | 1781 | } |
1787 | 1782 | ||
1788 | # Check for user-visible strings broken across lines, which breaks the ability | 1783 | # Check for user-visible strings broken across lines, which breaks the ability |
@@ -1890,8 +1885,10 @@ sub process { | |||
1890 | } | 1885 | } |
1891 | 1886 | ||
1892 | if ($realfile =~ m@^(drivers/net/|net/)@ && | 1887 | if ($realfile =~ m@^(drivers/net/|net/)@ && |
1893 | $rawline !~ m@^\+[ \t]*(\/\*|\*\/)@ && | 1888 | $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ && #trailing */ |
1894 | $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { | 1889 | $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/ |
1890 | $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ && #trailing **/ | ||
1891 | $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { #non blank */ | ||
1895 | WARN("NETWORKING_BLOCK_COMMENT_STYLE", | 1892 | WARN("NETWORKING_BLOCK_COMMENT_STYLE", |
1896 | "networking block comments put the trailing */ on a separate line\n" . $herecurr); | 1893 | "networking block comments put the trailing */ on a separate line\n" . $herecurr); |
1897 | } | 1894 | } |
@@ -1910,6 +1907,12 @@ sub process { | |||
1910 | # check we are in a valid C source file if not then ignore this hunk | 1907 | # check we are in a valid C source file if not then ignore this hunk |
1911 | next if ($realfile !~ /\.(h|c)$/); | 1908 | next if ($realfile !~ /\.(h|c)$/); |
1912 | 1909 | ||
1910 | # discourage the addition of CONFIG_EXPERIMENTAL in #if(def). | ||
1911 | if ($line =~ /^\+\s*\#\s*if.*\bCONFIG_EXPERIMENTAL\b/) { | ||
1912 | WARN("CONFIG_EXPERIMENTAL", | ||
1913 | "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n"); | ||
1914 | } | ||
1915 | |||
1913 | # check for RCS/CVS revision markers | 1916 | # check for RCS/CVS revision markers |
1914 | if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) { | 1917 | if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) { |
1915 | WARN("CVS_KEYWORD", | 1918 | WARN("CVS_KEYWORD", |
@@ -2223,8 +2226,11 @@ sub process { | |||
2223 | my $path = $1; | 2226 | my $path = $1; |
2224 | if ($path =~ m{//}) { | 2227 | if ($path =~ m{//}) { |
2225 | ERROR("MALFORMED_INCLUDE", | 2228 | ERROR("MALFORMED_INCLUDE", |
2226 | "malformed #include filename\n" . | 2229 | "malformed #include filename\n" . $herecurr); |
2227 | $herecurr); | 2230 | } |
2231 | if ($path =~ "^uapi/" && $realfile =~ m@\binclude/uapi/@) { | ||
2232 | ERROR("UAPI_INCLUDE", | ||
2233 | "No #include in ...include/uapi/... should use a uapi/ path prefix\n" . $herecurr); | ||
2228 | } | 2234 | } |
2229 | } | 2235 | } |
2230 | 2236 | ||
@@ -2904,12 +2910,17 @@ sub process { | |||
2904 | } | 2910 | } |
2905 | } | 2911 | } |
2906 | 2912 | ||
2907 | #studly caps, commented out until figure out how to distinguish between use of existing and adding new | 2913 | #CamelCase |
2908 | # if (($line=~/[\w_][a-z\d]+[A-Z]/) and !($line=~/print/)) { | 2914 | while ($line =~ m{($Constant|$Lval)}g) { |
2909 | # print "No studly caps, use _\n"; | 2915 | my $var = $1; |
2910 | # print "$herecurr"; | 2916 | if ($var !~ /$Constant/ && |
2911 | # $clean = 0; | 2917 | $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ && |
2912 | # } | 2918 | !defined $camelcase{$var}) { |
2919 | $camelcase{$var} = 1; | ||
2920 | WARN("CAMELCASE", | ||
2921 | "Avoid CamelCase: <$var>\n" . $herecurr); | ||
2922 | } | ||
2923 | } | ||
2913 | 2924 | ||
2914 | #no spaces allowed after \ in define | 2925 | #no spaces allowed after \ in define |
2915 | if ($line=~/\#\s*define.*\\\s$/) { | 2926 | if ($line=~/\#\s*define.*\\\s$/) { |
@@ -3011,6 +3022,17 @@ sub process { | |||
3011 | "Macros with complex values should be enclosed in parenthesis\n" . "$herectx"); | 3022 | "Macros with complex values should be enclosed in parenthesis\n" . "$herectx"); |
3012 | } | 3023 | } |
3013 | } | 3024 | } |
3025 | |||
3026 | # check for line continuations outside of #defines, preprocessor #, and asm | ||
3027 | |||
3028 | } else { | ||
3029 | if ($prevline !~ /^..*\\$/ && | ||
3030 | $line !~ /^\+\s*\#.*\\$/ && # preprocessor | ||
3031 | $line !~ /^\+.*\b(__asm__|asm)\b.*\\$/ && # asm | ||
3032 | $line =~ /^\+.*\\$/) { | ||
3033 | WARN("LINE_CONTINUATIONS", | ||
3034 | "Avoid unnecessary line continuations\n" . $herecurr); | ||
3035 | } | ||
3014 | } | 3036 | } |
3015 | 3037 | ||
3016 | # do {} while (0) macro tests: | 3038 | # do {} while (0) macro tests: |
@@ -3181,20 +3203,14 @@ sub process { | |||
3181 | } | 3203 | } |
3182 | } | 3204 | } |
3183 | 3205 | ||
3184 | # don't include deprecated include files (uses RAW line) | 3206 | # check for unnecessary blank lines around braces |
3185 | for my $inc (@dep_includes) { | 3207 | if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) { |
3186 | if ($rawline =~ m@^.\s*\#\s*include\s*\<$inc>@) { | 3208 | CHK("BRACES", |
3187 | ERROR("DEPRECATED_INCLUDE", | 3209 | "Blank lines aren't necessary before a close brace '}'\n" . $hereprev); |
3188 | "Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n" . $herecurr); | ||
3189 | } | ||
3190 | } | 3210 | } |
3191 | 3211 | if (($line =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) { | |
3192 | # don't use deprecated functions | 3212 | CHK("BRACES", |
3193 | for my $func (@dep_functions) { | 3213 | "Blank lines aren't necessary after an open brace '{'\n" . $hereprev); |
3194 | if ($line =~ /\b$func\b/) { | ||
3195 | ERROR("DEPRECATED_FUNCTION", | ||
3196 | "Don't use $func(): see Documentation/feature-removal-schedule.txt\n" . $herecurr); | ||
3197 | } | ||
3198 | } | 3214 | } |
3199 | 3215 | ||
3200 | # no volatiles please | 3216 | # no volatiles please |
@@ -3211,20 +3227,12 @@ sub process { | |||
3211 | $herecurr); | 3227 | $herecurr); |
3212 | } | 3228 | } |
3213 | 3229 | ||
3214 | # check for needless kfree() checks | 3230 | # check for needless "if (<foo>) fn(<foo>)" uses |
3215 | if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { | 3231 | if ($prevline =~ /\bif\s*\(\s*($Lval)\s*\)/) { |
3216 | my $expr = $1; | 3232 | my $expr = '\s*\(\s*' . quotemeta($1) . '\s*\)\s*;'; |
3217 | if ($line =~ /\bkfree\(\Q$expr\E\);/) { | 3233 | if ($line =~ /\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?)$expr/) { |
3218 | WARN("NEEDLESS_KFREE", | 3234 | WARN('NEEDLESS_IF', |
3219 | "kfree(NULL) is safe this check is probably not required\n" . $hereprev); | 3235 | "$1(NULL) is safe this check is probably not required\n" . $hereprev); |
3220 | } | ||
3221 | } | ||
3222 | # check for needless usb_free_urb() checks | ||
3223 | if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { | ||
3224 | my $expr = $1; | ||
3225 | if ($line =~ /\busb_free_urb\(\Q$expr\E\);/) { | ||
3226 | WARN("NEEDLESS_USB_FREE_URB", | ||
3227 | "usb_free_urb(NULL) is safe this check is probably not required\n" . $hereprev); | ||
3228 | } | 3236 | } |
3229 | } | 3237 | } |
3230 | 3238 | ||
@@ -3342,6 +3350,12 @@ sub process { | |||
3342 | "Avoid line continuations in quoted strings\n" . $herecurr); | 3350 | "Avoid line continuations in quoted strings\n" . $herecurr); |
3343 | } | 3351 | } |
3344 | 3352 | ||
3353 | # check for struct spinlock declarations | ||
3354 | if ($line =~ /^.\s*\bstruct\s+spinlock\s+\w+\s*;/) { | ||
3355 | WARN("USE_SPINLOCK_T", | ||
3356 | "struct spinlock should be spinlock_t\n" . $herecurr); | ||
3357 | } | ||
3358 | |||
3345 | # Check for misused memsets | 3359 | # Check for misused memsets |
3346 | if ($^V && $^V ge 5.10.0 && | 3360 | if ($^V && $^V ge 5.10.0 && |
3347 | defined $stat && | 3361 | defined $stat && |
@@ -3448,8 +3462,22 @@ sub process { | |||
3448 | 3462 | ||
3449 | # check for multiple semicolons | 3463 | # check for multiple semicolons |
3450 | if ($line =~ /;\s*;\s*$/) { | 3464 | if ($line =~ /;\s*;\s*$/) { |
3451 | WARN("ONE_SEMICOLON", | 3465 | WARN("ONE_SEMICOLON", |
3452 | "Statements terminations use 1 semicolon\n" . $herecurr); | 3466 | "Statements terminations use 1 semicolon\n" . $herecurr); |
3467 | } | ||
3468 | |||
3469 | # check for switch/default statements without a break; | ||
3470 | if ($^V && $^V ge 5.10.0 && | ||
3471 | defined $stat && | ||
3472 | $stat =~ /^\+[$;\s]*(?:case[$;\s]+\w+[$;\s]*:[$;\s]*|)*[$;\s]*\bdefault[$;\s]*:[$;\s]*;/g) { | ||
3473 | my $ctx = ''; | ||
3474 | my $herectx = $here . "\n"; | ||
3475 | my $cnt = statement_rawlines($stat); | ||
3476 | for (my $n = 0; $n < $cnt; $n++) { | ||
3477 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
3478 | } | ||
3479 | WARN("DEFAULT_NO_BREAK", | ||
3480 | "switch default: should use break\n" . $herectx); | ||
3453 | } | 3481 | } |
3454 | 3482 | ||
3455 | # check for gcc specific __FUNCTION__ | 3483 | # check for gcc specific __FUNCTION__ |
diff --git a/scripts/coccinelle/api/d_find_alias.cocci b/scripts/coccinelle/api/d_find_alias.cocci new file mode 100644 index 000000000000..a9694a8d3e5a --- /dev/null +++ b/scripts/coccinelle/api/d_find_alias.cocci | |||
@@ -0,0 +1,80 @@ | |||
1 | /// Make sure calls to d_find_alias() have a corresponding call to dput(). | ||
2 | // | ||
3 | // Keywords: d_find_alias, dput | ||
4 | // | ||
5 | // Confidence: Moderate | ||
6 | // URL: http://coccinelle.lip6.fr/ | ||
7 | // Options: -include_headers | ||
8 | |||
9 | virtual context | ||
10 | virtual org | ||
11 | virtual patch | ||
12 | virtual report | ||
13 | |||
14 | @r exists@ | ||
15 | local idexpression struct dentry *dent; | ||
16 | expression E, E1; | ||
17 | statement S1, S2; | ||
18 | position p1, p2; | ||
19 | @@ | ||
20 | ( | ||
21 | if (!(dent@p1 = d_find_alias(...))) S1 | ||
22 | | | ||
23 | dent@p1 = d_find_alias(...) | ||
24 | ) | ||
25 | |||
26 | <...when != dput(dent) | ||
27 | when != if (...) { <+... dput(dent) ...+> } | ||
28 | when != true !dent || ... | ||
29 | when != dent = E | ||
30 | when != E = dent | ||
31 | if (!dent || ...) S2 | ||
32 | ...> | ||
33 | ( | ||
34 | return <+...dent...+>; | ||
35 | | | ||
36 | return @p2 ...; | ||
37 | | | ||
38 | dent@p2 = E1; | ||
39 | | | ||
40 | E1 = dent; | ||
41 | ) | ||
42 | |||
43 | @depends on context@ | ||
44 | local idexpression struct dentry *r.dent; | ||
45 | position r.p1,r.p2; | ||
46 | @@ | ||
47 | * dent@p1 = ... | ||
48 | ... | ||
49 | ( | ||
50 | * return@p2 ...; | ||
51 | | | ||
52 | * dent@p2 | ||
53 | ) | ||
54 | |||
55 | |||
56 | @script:python depends on org@ | ||
57 | p1 << r.p1; | ||
58 | p2 << r.p2; | ||
59 | @@ | ||
60 | cocci.print_main("Missing call to dput()",p1) | ||
61 | cocci.print_secs("",p2) | ||
62 | |||
63 | @depends on patch@ | ||
64 | local idexpression struct dentry *r.dent; | ||
65 | position r.p2; | ||
66 | @@ | ||
67 | ( | ||
68 | + dput(dent); | ||
69 | return @p2 ...; | ||
70 | | | ||
71 | + dput(dent); | ||
72 | dent@p2 = ...; | ||
73 | ) | ||
74 | |||
75 | @script:python depends on report@ | ||
76 | p1 << r.p1; | ||
77 | p2 << r.p2; | ||
78 | @@ | ||
79 | msg = "Missing call to dput() at line %s." | ||
80 | coccilib.report.print_report(p1[0], msg % (p2[0].line)) | ||
diff --git a/scripts/coccinelle/misc/warn.cocci b/scripts/coccinelle/misc/warn.cocci new file mode 100644 index 000000000000..fda8c3558e4f --- /dev/null +++ b/scripts/coccinelle/misc/warn.cocci | |||
@@ -0,0 +1,109 @@ | |||
1 | /// Use WARN(1,...) rather than printk followed by WARN_ON(1) | ||
2 | /// | ||
3 | // Confidence: High | ||
4 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
5 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | ||
6 | // URL: http://coccinelle.lip6.fr/ | ||
7 | // Comments: | ||
8 | // Options: -no_includes -include_headers | ||
9 | |||
10 | virtual patch | ||
11 | virtual context | ||
12 | virtual org | ||
13 | virtual report | ||
14 | |||
15 | @bad1@ | ||
16 | position p; | ||
17 | @@ | ||
18 | |||
19 | printk(...); | ||
20 | printk@p(...); | ||
21 | WARN_ON(1); | ||
22 | |||
23 | @r1 depends on context || report || org@ | ||
24 | position p != bad1.p; | ||
25 | @@ | ||
26 | |||
27 | printk@p(...); | ||
28 | *WARN_ON(1); | ||
29 | |||
30 | @script:python depends on org@ | ||
31 | p << r1.p; | ||
32 | @@ | ||
33 | |||
34 | cocci.print_main("printk + WARN_ON can be just WARN",p) | ||
35 | |||
36 | @script:python depends on report@ | ||
37 | p << r1.p; | ||
38 | @@ | ||
39 | |||
40 | msg = "SUGGESTION: printk + WARN_ON can be just WARN" | ||
41 | coccilib.report.print_report(p[0],msg) | ||
42 | |||
43 | @ok1 depends on patch@ | ||
44 | expression list es; | ||
45 | position p != bad1.p; | ||
46 | @@ | ||
47 | |||
48 | -printk@p( | ||
49 | +WARN(1, | ||
50 | es); | ||
51 | -WARN_ON(1); | ||
52 | |||
53 | @depends on patch@ | ||
54 | expression list ok1.es; | ||
55 | @@ | ||
56 | |||
57 | if (...) | ||
58 | - { | ||
59 | WARN(1,es); | ||
60 | - } | ||
61 | |||
62 | // -------------------------------------------------------------------- | ||
63 | |||
64 | @bad2@ | ||
65 | position p; | ||
66 | @@ | ||
67 | |||
68 | printk(...); | ||
69 | printk@p(...); | ||
70 | WARN_ON_ONCE(1); | ||
71 | |||
72 | @r2 depends on context || report || org@ | ||
73 | position p != bad1.p; | ||
74 | @@ | ||
75 | |||
76 | printk@p(...); | ||
77 | *WARN_ON_ONCE(1); | ||
78 | |||
79 | @script:python depends on org@ | ||
80 | p << r2.p; | ||
81 | @@ | ||
82 | |||
83 | cocci.print_main("printk + WARN_ON_ONCE can be just WARN_ONCE",p) | ||
84 | |||
85 | @script:python depends on report@ | ||
86 | p << r2.p; | ||
87 | @@ | ||
88 | |||
89 | msg = "SUGGESTION: printk + WARN_ON_ONCE can be just WARN_ONCE" | ||
90 | coccilib.report.print_report(p[0],msg) | ||
91 | |||
92 | @ok2 depends on patch@ | ||
93 | expression list es; | ||
94 | position p != bad2.p; | ||
95 | @@ | ||
96 | |||
97 | -printk@p( | ||
98 | +WARN_ONCE(1, | ||
99 | es); | ||
100 | -WARN_ON_ONCE(1); | ||
101 | |||
102 | @depends on patch@ | ||
103 | expression list ok2.es; | ||
104 | @@ | ||
105 | |||
106 | if (...) | ||
107 | - { | ||
108 | WARN_ONCE(1,es); | ||
109 | - } | ||
diff --git a/scripts/config b/scripts/config index ee355394f4ef..bb4d3deb6d1c 100755 --- a/scripts/config +++ b/scripts/config | |||
@@ -101,7 +101,6 @@ while [ "$1" != "" ] ; do | |||
101 | case "$CMD" in | 101 | case "$CMD" in |
102 | --keep-case|-k) | 102 | --keep-case|-k) |
103 | MUNGE_CASE=no | 103 | MUNGE_CASE=no |
104 | shift | ||
105 | continue | 104 | continue |
106 | ;; | 105 | ;; |
107 | --refresh) | 106 | --refresh) |
diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index 6d1c6bb9f224..2a48022c41e7 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile | |||
@@ -27,3 +27,5 @@ HOSTCFLAGS_dtc-parser.tab.o := $(HOSTCFLAGS_DTC) | |||
27 | # dependencies on generated files need to be listed explicitly | 27 | # dependencies on generated files need to be listed explicitly |
28 | $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h | 28 | $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h |
29 | 29 | ||
30 | # generated files need to be cleaned explicitly | ||
31 | clean-files := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h | ||
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index d501c8605f26..3e42a071070e 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h | |||
@@ -161,51 +161,27 @@ struct node { | |||
161 | struct label *labels; | 161 | struct label *labels; |
162 | }; | 162 | }; |
163 | 163 | ||
164 | static inline struct label *for_each_label_next(struct label *l) | ||
165 | { | ||
166 | do { | ||
167 | l = l->next; | ||
168 | } while (l && l->deleted); | ||
169 | |||
170 | return l; | ||
171 | } | ||
172 | |||
173 | #define for_each_label(l0, l) \ | ||
174 | for ((l) = (l0); (l); (l) = for_each_label_next(l)) | ||
175 | |||
176 | #define for_each_label_withdel(l0, l) \ | 164 | #define for_each_label_withdel(l0, l) \ |
177 | for ((l) = (l0); (l); (l) = (l)->next) | 165 | for ((l) = (l0); (l); (l) = (l)->next) |
178 | 166 | ||
179 | static inline struct property *for_each_property_next(struct property *p) | 167 | #define for_each_label(l0, l) \ |
180 | { | 168 | for_each_label_withdel(l0, l) \ |
181 | do { | 169 | if (!(l)->deleted) |
182 | p = p->next; | ||
183 | } while (p && p->deleted); | ||
184 | |||
185 | return p; | ||
186 | } | ||
187 | |||
188 | #define for_each_property(n, p) \ | ||
189 | for ((p) = (n)->proplist; (p); (p) = for_each_property_next(p)) | ||
190 | 170 | ||
191 | #define for_each_property_withdel(n, p) \ | 171 | #define for_each_property_withdel(n, p) \ |
192 | for ((p) = (n)->proplist; (p); (p) = (p)->next) | 172 | for ((p) = (n)->proplist; (p); (p) = (p)->next) |
193 | 173 | ||
194 | static inline struct node *for_each_child_next(struct node *c) | 174 | #define for_each_property(n, p) \ |
195 | { | 175 | for_each_property_withdel(n, p) \ |
196 | do { | 176 | if (!(p)->deleted) |
197 | c = c->next_sibling; | ||
198 | } while (c && c->deleted); | ||
199 | |||
200 | return c; | ||
201 | } | ||
202 | |||
203 | #define for_each_child(n, c) \ | ||
204 | for ((c) = (n)->children; (c); (c) = for_each_child_next(c)) | ||
205 | 177 | ||
206 | #define for_each_child_withdel(n, c) \ | 178 | #define for_each_child_withdel(n, c) \ |
207 | for ((c) = (n)->children; (c); (c) = (c)->next_sibling) | 179 | for ((c) = (n)->children; (c); (c) = (c)->next_sibling) |
208 | 180 | ||
181 | #define for_each_child(n, c) \ | ||
182 | for_each_child_withdel(n, c) \ | ||
183 | if (!(c)->deleted) | ||
184 | |||
209 | void add_label(struct label **labels, char *label); | 185 | void add_label(struct label **labels, char *label); |
210 | void delete_labels(struct label **labels); | 186 | void delete_labels(struct label **labels); |
211 | 187 | ||
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl index 239d22d4207b..6c353ae8a451 100644 --- a/scripts/headers_install.pl +++ b/scripts/headers_install.pl | |||
@@ -42,6 +42,9 @@ foreach my $filename (@files) { | |||
42 | $line =~ s/(^|\s)(inline)\b/$1__$2__/g; | 42 | $line =~ s/(^|\s)(inline)\b/$1__$2__/g; |
43 | $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; | 43 | $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; |
44 | $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; | 44 | $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; |
45 | $line =~ s/#ifndef _UAPI/#ifndef /; | ||
46 | $line =~ s/#define _UAPI/#define /; | ||
47 | $line =~ s!#endif /[*] _UAPI!#endif /* !; | ||
45 | printf {$out} "%s", $line; | 48 | printf {$out} "%s", $line; |
46 | } | 49 | } |
47 | close $out; | 50 | close $out; |
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index bd2e09895553..cdd48600e02a 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
@@ -12,7 +12,7 @@ extern "C" { | |||
12 | 12 | ||
13 | #include <assert.h> | 13 | #include <assert.h> |
14 | #include <stdio.h> | 14 | #include <stdio.h> |
15 | #include <sys/queue.h> | 15 | #include "list.h" |
16 | #ifndef __cplusplus | 16 | #ifndef __cplusplus |
17 | #include <stdbool.h> | 17 | #include <stdbool.h> |
18 | #endif | 18 | #endif |
@@ -175,12 +175,11 @@ struct menu { | |||
175 | #define MENU_ROOT 0x0002 | 175 | #define MENU_ROOT 0x0002 |
176 | 176 | ||
177 | struct jump_key { | 177 | struct jump_key { |
178 | CIRCLEQ_ENTRY(jump_key) entries; | 178 | struct list_head entries; |
179 | size_t offset; | 179 | size_t offset; |
180 | struct menu *target; | 180 | struct menu *target; |
181 | int index; | 181 | int index; |
182 | }; | 182 | }; |
183 | CIRCLEQ_HEAD(jk_head, jump_key); | ||
184 | 183 | ||
185 | #define JUMP_NB 9 | 184 | #define JUMP_NB 9 |
186 | 185 | ||
diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h new file mode 100644 index 000000000000..0ae730be5f49 --- /dev/null +++ b/scripts/kconfig/list.h | |||
@@ -0,0 +1,91 @@ | |||
1 | #ifndef LIST_H | ||
2 | #define LIST_H | ||
3 | |||
4 | /* | ||
5 | * Copied from include/linux/... | ||
6 | */ | ||
7 | |||
8 | #undef offsetof | ||
9 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) | ||
10 | |||
11 | /** | ||
12 | * container_of - cast a member of a structure out to the containing structure | ||
13 | * @ptr: the pointer to the member. | ||
14 | * @type: the type of the container struct this is embedded in. | ||
15 | * @member: the name of the member within the struct. | ||
16 | * | ||
17 | */ | ||
18 | #define container_of(ptr, type, member) ({ \ | ||
19 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | ||
20 | (type *)( (char *)__mptr - offsetof(type,member) );}) | ||
21 | |||
22 | |||
23 | struct list_head { | ||
24 | struct list_head *next, *prev; | ||
25 | }; | ||
26 | |||
27 | |||
28 | #define LIST_HEAD_INIT(name) { &(name), &(name) } | ||
29 | |||
30 | #define LIST_HEAD(name) \ | ||
31 | struct list_head name = LIST_HEAD_INIT(name) | ||
32 | |||
33 | /** | ||
34 | * list_entry - get the struct for this entry | ||
35 | * @ptr: the &struct list_head pointer. | ||
36 | * @type: the type of the struct this is embedded in. | ||
37 | * @member: the name of the list_struct within the struct. | ||
38 | */ | ||
39 | #define list_entry(ptr, type, member) \ | ||
40 | container_of(ptr, type, member) | ||
41 | |||
42 | /** | ||
43 | * list_for_each_entry - iterate over list of given type | ||
44 | * @pos: the type * to use as a loop cursor. | ||
45 | * @head: the head for your list. | ||
46 | * @member: the name of the list_struct within the struct. | ||
47 | */ | ||
48 | #define list_for_each_entry(pos, head, member) \ | ||
49 | for (pos = list_entry((head)->next, typeof(*pos), member); \ | ||
50 | &pos->member != (head); \ | ||
51 | pos = list_entry(pos->member.next, typeof(*pos), member)) | ||
52 | |||
53 | /** | ||
54 | * list_empty - tests whether a list is empty | ||
55 | * @head: the list to test. | ||
56 | */ | ||
57 | static inline int list_empty(const struct list_head *head) | ||
58 | { | ||
59 | return head->next == head; | ||
60 | } | ||
61 | |||
62 | /* | ||
63 | * Insert a new entry between two known consecutive entries. | ||
64 | * | ||
65 | * This is only for internal list manipulation where we know | ||
66 | * the prev/next entries already! | ||
67 | */ | ||
68 | static inline void __list_add(struct list_head *_new, | ||
69 | struct list_head *prev, | ||
70 | struct list_head *next) | ||
71 | { | ||
72 | next->prev = _new; | ||
73 | _new->next = next; | ||
74 | _new->prev = prev; | ||
75 | prev->next = _new; | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * list_add_tail - add a new entry | ||
80 | * @new: new entry to be added | ||
81 | * @head: list head to add it before | ||
82 | * | ||
83 | * Insert a new entry before the specified head. | ||
84 | * This is useful for implementing queues. | ||
85 | */ | ||
86 | static inline void list_add_tail(struct list_head *_new, struct list_head *head) | ||
87 | { | ||
88 | __list_add(_new, head->prev, head); | ||
89 | } | ||
90 | |||
91 | #endif | ||
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 1d1c08537f1e..ef1a7381f956 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h | |||
@@ -21,9 +21,9 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu)); | |||
21 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); | 21 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); |
22 | P(menu_has_help,bool,(struct menu *menu)); | 22 | P(menu_has_help,bool,(struct menu *menu)); |
23 | P(menu_get_help,const char *,(struct menu *menu)); | 23 | P(menu_get_help,const char *,(struct menu *menu)); |
24 | P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct jk_head | 24 | P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head |
25 | *head)); | 25 | *head)); |
26 | P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct jk_head | 26 | P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head |
27 | *head)); | 27 | *head)); |
28 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); | 28 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); |
29 | 29 | ||
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index ee17a5264d5b..307022a8beef 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h | |||
@@ -221,7 +221,6 @@ int dialog_menu(const char *title, const char *prompt, | |||
221 | const void *selected, int *s_scroll); | 221 | const void *selected, int *s_scroll); |
222 | int dialog_checklist(const char *title, const char *prompt, int height, | 222 | int dialog_checklist(const char *title, const char *prompt, int height, |
223 | int width, int list_height); | 223 | int width, int list_height); |
224 | extern char dialog_input_result[]; | ||
225 | int dialog_inputbox(const char *title, const char *prompt, int height, | 224 | int dialog_inputbox(const char *title, const char *prompt, int height, |
226 | int width, const char *init); | 225 | int width, const char *init); |
227 | 226 | ||
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 680135effd9b..566288a76370 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -313,7 +313,7 @@ static void set_config_filename(const char *config_filename) | |||
313 | 313 | ||
314 | 314 | ||
315 | struct search_data { | 315 | struct search_data { |
316 | struct jk_head *head; | 316 | struct list_head *head; |
317 | struct menu **targets; | 317 | struct menu **targets; |
318 | int *keys; | 318 | int *keys; |
319 | }; | 319 | }; |
@@ -324,7 +324,7 @@ static void update_text(char *buf, size_t start, size_t end, void *_data) | |||
324 | struct jump_key *pos; | 324 | struct jump_key *pos; |
325 | int k = 0; | 325 | int k = 0; |
326 | 326 | ||
327 | CIRCLEQ_FOREACH(pos, data->head, entries) { | 327 | list_for_each_entry(pos, data->head, entries) { |
328 | if (pos->offset >= start && pos->offset < end) { | 328 | if (pos->offset >= start && pos->offset < end) { |
329 | char header[4]; | 329 | char header[4]; |
330 | 330 | ||
@@ -381,7 +381,7 @@ again: | |||
381 | 381 | ||
382 | sym_arr = sym_re_search(dialog_input); | 382 | sym_arr = sym_re_search(dialog_input); |
383 | do { | 383 | do { |
384 | struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head); | 384 | LIST_HEAD(head); |
385 | struct menu *targets[JUMP_NB]; | 385 | struct menu *targets[JUMP_NB]; |
386 | int keys[JUMP_NB + 1], i; | 386 | int keys[JUMP_NB + 1], i; |
387 | struct search_data data = { | 387 | struct search_data data = { |
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 84a2ba2077aa..f3bffa309333 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c | |||
@@ -508,7 +508,7 @@ const char *menu_get_help(struct menu *menu) | |||
508 | } | 508 | } |
509 | 509 | ||
510 | static void get_prompt_str(struct gstr *r, struct property *prop, | 510 | static void get_prompt_str(struct gstr *r, struct property *prop, |
511 | struct jk_head *head) | 511 | struct list_head *head) |
512 | { | 512 | { |
513 | int i, j; | 513 | int i, j; |
514 | struct menu *submenu[8], *menu, *location = NULL; | 514 | struct menu *submenu[8], *menu, *location = NULL; |
@@ -544,12 +544,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop, | |||
544 | } else | 544 | } else |
545 | jump->target = location; | 545 | jump->target = location; |
546 | 546 | ||
547 | if (CIRCLEQ_EMPTY(head)) | 547 | if (list_empty(head)) |
548 | jump->index = 0; | 548 | jump->index = 0; |
549 | else | 549 | else |
550 | jump->index = CIRCLEQ_LAST(head)->index + 1; | 550 | jump->index = list_entry(head->prev, struct jump_key, |
551 | entries)->index + 1; | ||
551 | 552 | ||
552 | CIRCLEQ_INSERT_TAIL(head, jump, entries); | 553 | list_add_tail(&jump->entries, head); |
553 | } | 554 | } |
554 | 555 | ||
555 | if (i > 0) { | 556 | if (i > 0) { |
@@ -573,7 +574,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop, | |||
573 | /* | 574 | /* |
574 | * head is optional and may be NULL | 575 | * head is optional and may be NULL |
575 | */ | 576 | */ |
576 | void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) | 577 | void get_symbol_str(struct gstr *r, struct symbol *sym, |
578 | struct list_head *head) | ||
577 | { | 579 | { |
578 | bool hit; | 580 | bool hit; |
579 | struct property *prop; | 581 | struct property *prop; |
@@ -612,7 +614,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) | |||
612 | str_append(r, "\n\n"); | 614 | str_append(r, "\n\n"); |
613 | } | 615 | } |
614 | 616 | ||
615 | struct gstr get_relations_str(struct symbol **sym_arr, struct jk_head *head) | 617 | struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head) |
616 | { | 618 | { |
617 | struct symbol *sym; | 619 | struct symbol *sym; |
618 | struct gstr res = str_new(); | 620 | struct gstr res = str_new(); |
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 46e7aff80d1a..28b761567815 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
@@ -137,6 +137,8 @@ use strict; | |||
137 | # should document the "Context:" of the function, e.g. whether the functions | 137 | # should document the "Context:" of the function, e.g. whether the functions |
138 | # can be called form interrupts. Unlike other sections you can end it with an | 138 | # can be called form interrupts. Unlike other sections you can end it with an |
139 | # empty line. | 139 | # empty line. |
140 | # A non-void function should have a "Return:" section describing the return | ||
141 | # value(s). | ||
140 | # Example-sections should contain the string EXAMPLE so that they are marked | 142 | # Example-sections should contain the string EXAMPLE so that they are marked |
141 | # appropriately in DocBook. | 143 | # appropriately in DocBook. |
142 | # | 144 | # |
@@ -315,6 +317,7 @@ my $section_default = "Description"; # default section | |||
315 | my $section_intro = "Introduction"; | 317 | my $section_intro = "Introduction"; |
316 | my $section = $section_default; | 318 | my $section = $section_default; |
317 | my $section_context = "Context"; | 319 | my $section_context = "Context"; |
320 | my $section_return = "Return"; | ||
318 | 321 | ||
319 | my $undescribed = "-- undescribed --"; | 322 | my $undescribed = "-- undescribed --"; |
320 | 323 | ||
@@ -2039,6 +2042,28 @@ sub check_sections($$$$$$) { | |||
2039 | } | 2042 | } |
2040 | 2043 | ||
2041 | ## | 2044 | ## |
2045 | # Checks the section describing the return value of a function. | ||
2046 | sub check_return_section { | ||
2047 | my $file = shift; | ||
2048 | my $declaration_name = shift; | ||
2049 | my $return_type = shift; | ||
2050 | |||
2051 | # Ignore an empty return type (It's a macro) | ||
2052 | # Ignore functions with a "void" return type. (But don't ignore "void *") | ||
2053 | if (($return_type eq "") || ($return_type =~ /void\s*\w*\s*$/)) { | ||
2054 | return; | ||
2055 | } | ||
2056 | |||
2057 | if (!defined($sections{$section_return}) || | ||
2058 | $sections{$section_return} eq "") { | ||
2059 | print STDERR "Warning(${file}:$.): " . | ||
2060 | "No description found for return value of " . | ||
2061 | "'$declaration_name'\n"; | ||
2062 | ++$warnings; | ||
2063 | } | ||
2064 | } | ||
2065 | |||
2066 | ## | ||
2042 | # takes a function prototype and the name of the current file being | 2067 | # takes a function prototype and the name of the current file being |
2043 | # processed and spits out all the details stored in the global | 2068 | # processed and spits out all the details stored in the global |
2044 | # arrays/hashes. | 2069 | # arrays/hashes. |
@@ -2109,6 +2134,15 @@ sub dump_function($$) { | |||
2109 | my $prms = join " ", @parameterlist; | 2134 | my $prms = join " ", @parameterlist; |
2110 | check_sections($file, $declaration_name, "function", $sectcheck, $prms, ""); | 2135 | check_sections($file, $declaration_name, "function", $sectcheck, $prms, ""); |
2111 | 2136 | ||
2137 | # This check emits a lot of warnings at the moment, because many | ||
2138 | # functions don't have a 'Return' doc section. So until the number | ||
2139 | # of warnings goes sufficiently down, the check is only performed in | ||
2140 | # verbose mode. | ||
2141 | # TODO: always perform the check. | ||
2142 | if ($verbose) { | ||
2143 | check_return_section($file, $declaration_name, $return_type); | ||
2144 | } | ||
2145 | |||
2112 | output_declaration($declaration_name, | 2146 | output_declaration($declaration_name, |
2113 | 'function', | 2147 | 'function', |
2114 | {'function' => $declaration_name, | 2148 | {'function' => $declaration_name, |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 0d93856a03f4..ff36c508a10e 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -858,25 +858,23 @@ static void check_section(const char *modname, struct elf_info *elf, | |||
858 | 858 | ||
859 | #define ALL_INIT_DATA_SECTIONS \ | 859 | #define ALL_INIT_DATA_SECTIONS \ |
860 | ".init.setup$", ".init.rodata$", \ | 860 | ".init.setup$", ".init.rodata$", \ |
861 | ".devinit.rodata$", ".cpuinit.rodata$", ".meminit.rodata$", \ | 861 | ".cpuinit.rodata$", ".meminit.rodata$", \ |
862 | ".init.data$", ".devinit.data$", ".cpuinit.data$", ".meminit.data$" | 862 | ".init.data$", ".cpuinit.data$", ".meminit.data$" |
863 | #define ALL_EXIT_DATA_SECTIONS \ | 863 | #define ALL_EXIT_DATA_SECTIONS \ |
864 | ".exit.data$", ".devexit.data$", ".cpuexit.data$", ".memexit.data$" | 864 | ".exit.data$", ".cpuexit.data$", ".memexit.data$" |
865 | 865 | ||
866 | #define ALL_INIT_TEXT_SECTIONS \ | 866 | #define ALL_INIT_TEXT_SECTIONS \ |
867 | ".init.text$", ".devinit.text$", ".cpuinit.text$", ".meminit.text$" | 867 | ".init.text$", ".cpuinit.text$", ".meminit.text$" |
868 | #define ALL_EXIT_TEXT_SECTIONS \ | 868 | #define ALL_EXIT_TEXT_SECTIONS \ |
869 | ".exit.text$", ".devexit.text$", ".cpuexit.text$", ".memexit.text$" | 869 | ".exit.text$", ".cpuexit.text$", ".memexit.text$" |
870 | 870 | ||
871 | #define ALL_PCI_INIT_SECTIONS \ | 871 | #define ALL_PCI_INIT_SECTIONS \ |
872 | ".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \ | 872 | ".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \ |
873 | ".pci_fixup_enable$", ".pci_fixup_resume$", \ | 873 | ".pci_fixup_enable$", ".pci_fixup_resume$", \ |
874 | ".pci_fixup_resume_early$", ".pci_fixup_suspend$" | 874 | ".pci_fixup_resume_early$", ".pci_fixup_suspend$" |
875 | 875 | ||
876 | #define ALL_XXXINIT_SECTIONS DEV_INIT_SECTIONS, CPU_INIT_SECTIONS, \ | 876 | #define ALL_XXXINIT_SECTIONS CPU_INIT_SECTIONS, MEM_INIT_SECTIONS |
877 | MEM_INIT_SECTIONS | 877 | #define ALL_XXXEXIT_SECTIONS CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS |
878 | #define ALL_XXXEXIT_SECTIONS DEV_EXIT_SECTIONS, CPU_EXIT_SECTIONS, \ | ||
879 | MEM_EXIT_SECTIONS | ||
880 | 878 | ||
881 | #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS | 879 | #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS |
882 | #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS | 880 | #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS |
@@ -885,12 +883,10 @@ static void check_section(const char *modname, struct elf_info *elf, | |||
885 | #define TEXT_SECTIONS ".text$" | 883 | #define TEXT_SECTIONS ".text$" |
886 | 884 | ||
887 | #define INIT_SECTIONS ".init.*" | 885 | #define INIT_SECTIONS ".init.*" |
888 | #define DEV_INIT_SECTIONS ".devinit.*" | ||
889 | #define CPU_INIT_SECTIONS ".cpuinit.*" | 886 | #define CPU_INIT_SECTIONS ".cpuinit.*" |
890 | #define MEM_INIT_SECTIONS ".meminit.*" | 887 | #define MEM_INIT_SECTIONS ".meminit.*" |
891 | 888 | ||
892 | #define EXIT_SECTIONS ".exit.*" | 889 | #define EXIT_SECTIONS ".exit.*" |
893 | #define DEV_EXIT_SECTIONS ".devexit.*" | ||
894 | #define CPU_EXIT_SECTIONS ".cpuexit.*" | 890 | #define CPU_EXIT_SECTIONS ".cpuexit.*" |
895 | #define MEM_EXIT_SECTIONS ".memexit.*" | 891 | #define MEM_EXIT_SECTIONS ".memexit.*" |
896 | 892 | ||
@@ -979,7 +975,7 @@ const struct sectioncheck sectioncheck[] = { | |||
979 | .mismatch = DATA_TO_ANY_EXIT, | 975 | .mismatch = DATA_TO_ANY_EXIT, |
980 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 976 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
981 | }, | 977 | }, |
982 | /* Do not reference init code/data from devinit/cpuinit/meminit code/data */ | 978 | /* Do not reference init code/data from cpuinit/meminit code/data */ |
983 | { | 979 | { |
984 | .fromsec = { ALL_XXXINIT_SECTIONS, NULL }, | 980 | .fromsec = { ALL_XXXINIT_SECTIONS, NULL }, |
985 | .tosec = { INIT_SECTIONS, NULL }, | 981 | .tosec = { INIT_SECTIONS, NULL }, |
@@ -1000,7 +996,7 @@ const struct sectioncheck sectioncheck[] = { | |||
1000 | .mismatch = XXXINIT_TO_SOME_INIT, | 996 | .mismatch = XXXINIT_TO_SOME_INIT, |
1001 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 997 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
1002 | }, | 998 | }, |
1003 | /* Do not reference exit code/data from devexit/cpuexit/memexit code/data */ | 999 | /* Do not reference exit code/data from cpuexit/memexit code/data */ |
1004 | { | 1000 | { |
1005 | .fromsec = { ALL_XXXEXIT_SECTIONS, NULL }, | 1001 | .fromsec = { ALL_XXXEXIT_SECTIONS, NULL }, |
1006 | .tosec = { EXIT_SECTIONS, NULL }, | 1002 | .tosec = { EXIT_SECTIONS, NULL }, |
@@ -1089,7 +1085,7 @@ static const struct sectioncheck *section_mismatch( | |||
1089 | * Pattern 2: | 1085 | * Pattern 2: |
1090 | * Many drivers utilise a *driver container with references to | 1086 | * Many drivers utilise a *driver container with references to |
1091 | * add, remove, probe functions etc. | 1087 | * add, remove, probe functions etc. |
1092 | * These functions may often be marked __devinit and we do not want to | 1088 | * These functions may often be marked __cpuinit and we do not want to |
1093 | * warn here. | 1089 | * warn here. |
1094 | * the pattern is identified by: | 1090 | * the pattern is identified by: |
1095 | * tosec = init or exit section | 1091 | * tosec = init or exit section |
diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c index 5c113123ed9f..68bb4efc5af4 100644 --- a/scripts/pnmtologo.c +++ b/scripts/pnmtologo.c | |||
@@ -74,6 +74,7 @@ static unsigned int logo_height; | |||
74 | static struct color **logo_data; | 74 | static struct color **logo_data; |
75 | static struct color logo_clut[MAX_LINUX_LOGO_COLORS]; | 75 | static struct color logo_clut[MAX_LINUX_LOGO_COLORS]; |
76 | static unsigned int logo_clutsize; | 76 | static unsigned int logo_clutsize; |
77 | static int is_plain_pbm = 0; | ||
77 | 78 | ||
78 | static void die(const char *fmt, ...) | 79 | static void die(const char *fmt, ...) |
79 | __attribute__ ((noreturn)) __attribute ((format (printf, 1, 2))); | 80 | __attribute__ ((noreturn)) __attribute ((format (printf, 1, 2))); |
@@ -103,6 +104,11 @@ static unsigned int get_number(FILE *fp) | |||
103 | val = 0; | 104 | val = 0; |
104 | while (isdigit(c)) { | 105 | while (isdigit(c)) { |
105 | val = 10*val+c-'0'; | 106 | val = 10*val+c-'0'; |
107 | /* some PBM are 'broken'; GiMP for example exports a PBM without space | ||
108 | * between the digits. This is Ok cause we know a PBM can only have a '1' | ||
109 | * or a '0' for the digit. */ | ||
110 | if (is_plain_pbm) | ||
111 | break; | ||
106 | c = fgetc(fp); | 112 | c = fgetc(fp); |
107 | if (c == EOF) | 113 | if (c == EOF) |
108 | die("%s: end of file\n", filename); | 114 | die("%s: end of file\n", filename); |
@@ -167,6 +173,7 @@ static void read_image(void) | |||
167 | switch (magic) { | 173 | switch (magic) { |
168 | case '1': | 174 | case '1': |
169 | /* Plain PBM */ | 175 | /* Plain PBM */ |
176 | is_plain_pbm = 1; | ||
170 | for (i = 0; i < logo_height; i++) | 177 | for (i = 0; i < logo_height; i++) |
171 | for (j = 0; j < logo_width; j++) | 178 | for (j = 0; j < logo_width; j++) |
172 | logo_data[i][j].red = logo_data[i][j].green = | 179 | logo_data[i][j].red = logo_data[i][j].green = |
diff --git a/scripts/sign-file b/scripts/sign-file index e58e34e50ac5..974a20b661b7 100644..100755 --- a/scripts/sign-file +++ b/scripts/sign-file | |||
@@ -1,115 +1,429 @@ | |||
1 | #!/bin/sh | 1 | #!/usr/bin/perl -w |
2 | # | 2 | # |
3 | # Sign a module file using the given key. | 3 | # Sign a module file using the given key. |
4 | # | 4 | # |
5 | # Format: sign-file <key> <x509> <src-file> <dst-file> | 5 | # Format: |
6 | # | 6 | # |
7 | 7 | # ./scripts/sign-file [-v] <key> <x509> <module> [<dest>] | |
8 | scripts=`dirname $0` | 8 | # |
9 | 9 | # | |
10 | CONFIG_MODULE_SIG_SHA512=y | 10 | use strict; |
11 | if [ -r .config ] | 11 | use FileHandle; |
12 | then | 12 | use IPC::Open2; |
13 | . ./.config | 13 | |
14 | fi | 14 | my $verbose = 0; |
15 | 15 | if ($#ARGV >= 0 && $ARGV[0] eq "-v") { | |
16 | key="$1" | 16 | $verbose = 1; |
17 | x509="$2" | 17 | shift; |
18 | src="$3" | 18 | } |
19 | dst="$4" | 19 | |
20 | 20 | die "Format: ./scripts/sign-file [-v] <key> <x509> <module> [<dest>]\n" | |
21 | if [ ! -r "$key" ] | 21 | if ($#ARGV != 2 && $#ARGV != 3); |
22 | then | 22 | |
23 | echo "Can't read private key" >&2 | 23 | my $private_key = $ARGV[0]; |
24 | exit 2 | 24 | my $x509 = $ARGV[1]; |
25 | fi | 25 | my $module = $ARGV[2]; |
26 | 26 | my $dest = ($#ARGV == 3) ? $ARGV[3] : $ARGV[2] . "~"; | |
27 | if [ ! -r "$x509" ] | 27 | |
28 | then | 28 | die "Can't read private key\n" unless (-r $private_key); |
29 | echo "Can't read X.509 certificate" >&2 | 29 | die "Can't read X.509 certificate\n" unless (-r $x509); |
30 | exit 2 | 30 | die "Can't read module\n" unless (-r $module); |
31 | fi | 31 | |
32 | if [ ! -r "$x509.signer" ] | 32 | # |
33 | then | 33 | # Read the kernel configuration |
34 | echo "Can't read Signer name" >&2 | 34 | # |
35 | exit 2; | 35 | my %config = ( |
36 | fi | 36 | CONFIG_MODULE_SIG_SHA512 => 1 |
37 | if [ ! -r "$x509.keyid" ] | 37 | ); |
38 | then | 38 | |
39 | echo "Can't read Key identifier" >&2 | 39 | if (-r ".config") { |
40 | exit 2; | 40 | open(FD, "<.config") || die ".config"; |
41 | fi | 41 | while (<FD>) { |
42 | if ($_ =~ /^(CONFIG_.*)=[ym]/) { | ||
43 | $config{$1} = 1; | ||
44 | } | ||
45 | } | ||
46 | close(FD); | ||
47 | } | ||
48 | |||
49 | # | ||
50 | # Function to read the contents of a file into a variable. | ||
51 | # | ||
52 | sub read_file($) | ||
53 | { | ||
54 | my ($file) = @_; | ||
55 | my $contents; | ||
56 | my $len; | ||
57 | |||
58 | open(FD, "<$file") || die $file; | ||
59 | binmode FD; | ||
60 | my @st = stat(FD); | ||
61 | die $file if (!@st); | ||
62 | $len = read(FD, $contents, $st[7]) || die $file; | ||
63 | close(FD) || die $file; | ||
64 | die "$file: Wanted length ", $st[7], ", got ", $len, "\n" | ||
65 | if ($len != $st[7]); | ||
66 | return $contents; | ||
67 | } | ||
68 | |||
69 | ############################################################################### | ||
70 | # | ||
71 | # First of all, we have to parse the X.509 certificate to find certain details | ||
72 | # about it. | ||
73 | # | ||
74 | # We read the DER-encoded X509 certificate and parse it to extract the Subject | ||
75 | # name and Subject Key Identifier. Theis provides the data we need to build | ||
76 | # the certificate identifier. | ||
77 | # | ||
78 | # The signer's name part of the identifier is fabricated from the commonName, | ||
79 | # the organizationName or the emailAddress components of the X.509 subject | ||
80 | # name. | ||
81 | # | ||
82 | # The subject key ID is used to select which of that signer's certificates | ||
83 | # we're intending to use to sign the module. | ||
84 | # | ||
85 | ############################################################################### | ||
86 | my $x509_certificate = read_file($x509); | ||
87 | |||
88 | my $UNIV = 0 << 6; | ||
89 | my $APPL = 1 << 6; | ||
90 | my $CONT = 2 << 6; | ||
91 | my $PRIV = 3 << 6; | ||
92 | |||
93 | my $CONS = 0x20; | ||
94 | |||
95 | my $BOOLEAN = 0x01; | ||
96 | my $INTEGER = 0x02; | ||
97 | my $BIT_STRING = 0x03; | ||
98 | my $OCTET_STRING = 0x04; | ||
99 | my $NULL = 0x05; | ||
100 | my $OBJ_ID = 0x06; | ||
101 | my $UTF8String = 0x0c; | ||
102 | my $SEQUENCE = 0x10; | ||
103 | my $SET = 0x11; | ||
104 | my $UTCTime = 0x17; | ||
105 | my $GeneralizedTime = 0x18; | ||
106 | |||
107 | my %OIDs = ( | ||
108 | pack("CCC", 85, 4, 3) => "commonName", | ||
109 | pack("CCC", 85, 4, 6) => "countryName", | ||
110 | pack("CCC", 85, 4, 10) => "organizationName", | ||
111 | pack("CCC", 85, 4, 11) => "organizationUnitName", | ||
112 | pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 1) => "rsaEncryption", | ||
113 | pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 5) => "sha1WithRSAEncryption", | ||
114 | pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 9, 1) => "emailAddress", | ||
115 | pack("CCC", 85, 29, 35) => "authorityKeyIdentifier", | ||
116 | pack("CCC", 85, 29, 14) => "subjectKeyIdentifier", | ||
117 | pack("CCC", 85, 29, 19) => "basicConstraints" | ||
118 | ); | ||
119 | |||
120 | ############################################################################### | ||
121 | # | ||
122 | # Extract an ASN.1 element from a string and return information about it. | ||
123 | # | ||
124 | ############################################################################### | ||
125 | sub asn1_extract($$@) | ||
126 | { | ||
127 | my ($cursor, $expected_tag, $optional) = @_; | ||
128 | |||
129 | return [ -1 ] | ||
130 | if ($cursor->[1] == 0 && $optional); | ||
131 | |||
132 | die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (elem ", $cursor->[1], ")\n" | ||
133 | if ($cursor->[1] < 2); | ||
134 | |||
135 | my ($tag, $len) = unpack("CC", substr(${$cursor->[2]}, $cursor->[0], 2)); | ||
136 | |||
137 | if ($expected_tag != -1 && $tag != $expected_tag) { | ||
138 | return [ -1 ] | ||
139 | if ($optional); | ||
140 | die $x509, ": ", $cursor->[0], ": ASN.1 unexpected tag (", $tag, | ||
141 | " not ", $expected_tag, ")\n"; | ||
142 | } | ||
143 | |||
144 | $cursor->[0] += 2; | ||
145 | $cursor->[1] -= 2; | ||
146 | |||
147 | die $x509, ": ", $cursor->[0], ": ASN.1 long tag\n" | ||
148 | if (($tag & 0x1f) == 0x1f); | ||
149 | die $x509, ": ", $cursor->[0], ": ASN.1 indefinite length\n" | ||
150 | if ($len == 0x80); | ||
151 | |||
152 | if ($len > 0x80) { | ||
153 | my $l = $len - 0x80; | ||
154 | die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (len len $l)\n" | ||
155 | if ($cursor->[1] < $l); | ||
156 | |||
157 | if ($l == 0x1) { | ||
158 | $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)); | ||
159 | } elsif ($l == 0x2) { | ||
160 | $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0], 2)); | ||
161 | } elsif ($l == 0x3) { | ||
162 | $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)) << 16; | ||
163 | $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0] + 1, 2)); | ||
164 | } elsif ($l == 0x4) { | ||
165 | $len = unpack("N", substr(${$cursor->[2]}, $cursor->[0], 4)); | ||
166 | } else { | ||
167 | die $x509, ": ", $cursor->[0], ": ASN.1 element too long (", $l, ")\n"; | ||
168 | } | ||
169 | |||
170 | $cursor->[0] += $l; | ||
171 | $cursor->[1] -= $l; | ||
172 | } | ||
173 | |||
174 | die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (", $len, ")\n" | ||
175 | if ($cursor->[1] < $len); | ||
176 | |||
177 | my $ret = [ $tag, [ $cursor->[0], $len, $cursor->[2] ] ]; | ||
178 | $cursor->[0] += $len; | ||
179 | $cursor->[1] -= $len; | ||
180 | |||
181 | return $ret; | ||
182 | } | ||
183 | |||
184 | ############################################################################### | ||
185 | # | ||
186 | # Retrieve the data referred to by a cursor | ||
187 | # | ||
188 | ############################################################################### | ||
189 | sub asn1_retrieve($) | ||
190 | { | ||
191 | my ($cursor) = @_; | ||
192 | my ($offset, $len, $data) = @$cursor; | ||
193 | return substr($$data, $offset, $len); | ||
194 | } | ||
195 | |||
196 | ############################################################################### | ||
197 | # | ||
198 | # Roughly parse the X.509 certificate | ||
199 | # | ||
200 | ############################################################################### | ||
201 | my $cursor = [ 0, length($x509_certificate), \$x509_certificate ]; | ||
202 | |||
203 | my $cert = asn1_extract($cursor, $UNIV | $CONS | $SEQUENCE); | ||
204 | my $tbs = asn1_extract($cert->[1], $UNIV | $CONS | $SEQUENCE); | ||
205 | my $version = asn1_extract($tbs->[1], $CONT | $CONS | 0, 1); | ||
206 | my $serial_number = asn1_extract($tbs->[1], $UNIV | $INTEGER); | ||
207 | my $sig_type = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
208 | my $issuer = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
209 | my $validity = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
210 | my $subject = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
211 | my $key = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
212 | my $issuer_uid = asn1_extract($tbs->[1], $CONT | $CONS | 1, 1); | ||
213 | my $subject_uid = asn1_extract($tbs->[1], $CONT | $CONS | 2, 1); | ||
214 | my $extension_list = asn1_extract($tbs->[1], $CONT | $CONS | 3, 1); | ||
215 | |||
216 | my $subject_key_id = (); | ||
217 | my $authority_key_id = (); | ||
218 | |||
219 | # | ||
220 | # Parse the extension list | ||
221 | # | ||
222 | if ($extension_list->[0] != -1) { | ||
223 | my $extensions = asn1_extract($extension_list->[1], $UNIV | $CONS | $SEQUENCE); | ||
224 | |||
225 | while ($extensions->[1]->[1] > 0) { | ||
226 | my $ext = asn1_extract($extensions->[1], $UNIV | $CONS | $SEQUENCE); | ||
227 | my $x_oid = asn1_extract($ext->[1], $UNIV | $OBJ_ID); | ||
228 | my $x_crit = asn1_extract($ext->[1], $UNIV | $BOOLEAN, 1); | ||
229 | my $x_val = asn1_extract($ext->[1], $UNIV | $OCTET_STRING); | ||
230 | |||
231 | my $raw_oid = asn1_retrieve($x_oid->[1]); | ||
232 | next if (!exists($OIDs{$raw_oid})); | ||
233 | my $x_type = $OIDs{$raw_oid}; | ||
234 | |||
235 | my $raw_value = asn1_retrieve($x_val->[1]); | ||
236 | |||
237 | if ($x_type eq "subjectKeyIdentifier") { | ||
238 | my $vcursor = [ 0, length($raw_value), \$raw_value ]; | ||
239 | |||
240 | $subject_key_id = asn1_extract($vcursor, $UNIV | $OCTET_STRING); | ||
241 | } | ||
242 | } | ||
243 | } | ||
244 | |||
245 | ############################################################################### | ||
246 | # | ||
247 | # Determine what we're going to use as the signer's name. In order of | ||
248 | # preference, take one of: commonName, organizationName or emailAddress. | ||
249 | # | ||
250 | ############################################################################### | ||
251 | my $org = ""; | ||
252 | my $cn = ""; | ||
253 | my $email = ""; | ||
254 | |||
255 | while ($subject->[1]->[1] > 0) { | ||
256 | my $rdn = asn1_extract($subject->[1], $UNIV | $CONS | $SET); | ||
257 | my $attr = asn1_extract($rdn->[1], $UNIV | $CONS | $SEQUENCE); | ||
258 | my $n_oid = asn1_extract($attr->[1], $UNIV | $OBJ_ID); | ||
259 | my $n_val = asn1_extract($attr->[1], -1); | ||
260 | |||
261 | my $raw_oid = asn1_retrieve($n_oid->[1]); | ||
262 | next if (!exists($OIDs{$raw_oid})); | ||
263 | my $n_type = $OIDs{$raw_oid}; | ||
264 | |||
265 | my $raw_value = asn1_retrieve($n_val->[1]); | ||
266 | |||
267 | if ($n_type eq "organizationName") { | ||
268 | $org = $raw_value; | ||
269 | } elsif ($n_type eq "commonName") { | ||
270 | $cn = $raw_value; | ||
271 | } elsif ($n_type eq "emailAddress") { | ||
272 | $email = $raw_value; | ||
273 | } | ||
274 | } | ||
275 | |||
276 | my $signers_name = $email; | ||
277 | |||
278 | if ($org && $cn) { | ||
279 | # Don't use the organizationName if the commonName repeats it | ||
280 | if (length($org) <= length($cn) && | ||
281 | substr($cn, 0, length($org)) eq $org) { | ||
282 | $signers_name = $cn; | ||
283 | goto got_id_name; | ||
284 | } | ||
285 | |||
286 | # Or a signifcant chunk of it | ||
287 | if (length($org) >= 7 && | ||
288 | length($cn) >= 7 && | ||
289 | substr($cn, 0, 7) eq substr($org, 0, 7)) { | ||
290 | $signers_name = $cn; | ||
291 | goto got_id_name; | ||
292 | } | ||
293 | |||
294 | $signers_name = $org . ": " . $cn; | ||
295 | } elsif ($org) { | ||
296 | $signers_name = $org; | ||
297 | } elsif ($cn) { | ||
298 | $signers_name = $cn; | ||
299 | } | ||
300 | |||
301 | got_id_name: | ||
302 | |||
303 | die $x509, ": ", "X.509: Couldn't find the Subject Key Identifier extension\n" | ||
304 | if (!$subject_key_id); | ||
305 | |||
306 | my $key_identifier = asn1_retrieve($subject_key_id->[1]); | ||
307 | |||
308 | ############################################################################### | ||
309 | # | ||
310 | # Create and attach the module signature | ||
311 | # | ||
312 | ############################################################################### | ||
42 | 313 | ||
43 | # | 314 | # |
44 | # Signature parameters | 315 | # Signature parameters |
45 | # | 316 | # |
46 | algo=1 # Public-key crypto algorithm: RSA | 317 | my $algo = 1; # Public-key crypto algorithm: RSA |
47 | hash= # Digest algorithm | 318 | my $hash = 0; # Digest algorithm |
48 | id_type=1 # Identifier type: X.509 | 319 | my $id_type = 1; # Identifier type: X.509 |
49 | 320 | ||
50 | # | 321 | # |
51 | # Digest the data | 322 | # Digest the data |
52 | # | 323 | # |
53 | dgst= | 324 | my ($dgst, $prologue) = (); |
54 | if [ "$CONFIG_MODULE_SIG_SHA1" = "y" ] | 325 | if (exists $config{"CONFIG_MODULE_SIG_SHA1"}) { |
55 | then | 326 | $prologue = pack("C*", |
56 | prologue="0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14" | 327 | 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, |
57 | dgst=-sha1 | 328 | 0x2B, 0x0E, 0x03, 0x02, 0x1A, |
58 | hash=2 | 329 | 0x05, 0x00, 0x04, 0x14); |
59 | elif [ "$CONFIG_MODULE_SIG_SHA224" = "y" ] | 330 | $dgst = "-sha1"; |
60 | then | 331 | $hash = 2; |
61 | prologue="0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1C" | 332 | } elsif (exists $config{"CONFIG_MODULE_SIG_SHA224"}) { |
62 | dgst=-sha224 | 333 | $prologue = pack("C*", |
63 | hash=7 | 334 | 0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, |
64 | elif [ "$CONFIG_MODULE_SIG_SHA256" = "y" ] | 335 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, |
65 | then | 336 | 0x05, 0x00, 0x04, 0x1C); |
66 | prologue="0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20" | 337 | $dgst = "-sha224"; |
67 | dgst=-sha256 | 338 | $hash = 7; |
68 | hash=4 | 339 | } elsif (exists $config{"CONFIG_MODULE_SIG_SHA256"}) { |
69 | elif [ "$CONFIG_MODULE_SIG_SHA384" = "y" ] | 340 | $prologue = pack("C*", |
70 | then | 341 | 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, |
71 | prologue="0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30" | 342 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, |
72 | dgst=-sha384 | 343 | 0x05, 0x00, 0x04, 0x20); |
73 | hash=5 | 344 | $dgst = "-sha256"; |
74 | elif [ "$CONFIG_MODULE_SIG_SHA512" = "y" ] | 345 | $hash = 4; |
75 | then | 346 | } elsif (exists $config{"CONFIG_MODULE_SIG_SHA384"}) { |
76 | prologue="0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40" | 347 | $prologue = pack("C*", |
77 | dgst=-sha512 | 348 | 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, |
78 | hash=6 | 349 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, |
79 | else | 350 | 0x05, 0x00, 0x04, 0x30); |
80 | echo "$0: Can't determine hash algorithm" >&2 | 351 | $dgst = "-sha384"; |
81 | exit 2 | 352 | $hash = 5; |
82 | fi | 353 | } elsif (exists $config{"CONFIG_MODULE_SIG_SHA512"}) { |
83 | 354 | $prologue = pack("C*", | |
84 | ( | 355 | 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, |
85 | perl -e "binmode STDOUT; print pack(\"C*\", $prologue)" || exit $? | 356 | 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, |
86 | openssl dgst $dgst -binary $src || exit $? | 357 | 0x05, 0x00, 0x04, 0x40); |
87 | ) >$src.dig || exit $? | 358 | $dgst = "-sha512"; |
359 | $hash = 6; | ||
360 | } else { | ||
361 | die "Can't determine hash algorithm"; | ||
362 | } | ||
363 | |||
364 | # | ||
365 | # Generate the digest and read from openssl's stdout | ||
366 | # | ||
367 | my $digest; | ||
368 | $digest = readpipe("openssl dgst $dgst -binary $module") || die "openssl dgst"; | ||
88 | 369 | ||
89 | # | 370 | # |
90 | # Generate the binary signature, which will be just the integer that comprises | 371 | # Generate the binary signature, which will be just the integer that comprises |
91 | # the signature with no metadata attached. | 372 | # the signature with no metadata attached. |
92 | # | 373 | # |
93 | openssl rsautl -sign -inkey $key -keyform PEM -in $src.dig -out $src.sig || exit $? | 374 | my $pid; |
94 | signerlen=`stat -c %s $x509.signer` | 375 | $pid = open2(*read_from, *write_to, |
95 | keyidlen=`stat -c %s $x509.keyid` | 376 | "openssl rsautl -sign -inkey $private_key -keyform PEM") || |
96 | siglen=`stat -c %s $src.sig` | 377 | die "openssl rsautl"; |
378 | binmode write_to; | ||
379 | print write_to $prologue . $digest || die "pipe to openssl rsautl"; | ||
380 | close(write_to) || die "pipe to openssl rsautl"; | ||
381 | |||
382 | binmode read_from; | ||
383 | my $signature; | ||
384 | read(read_from, $signature, 4096) || die "pipe from openssl rsautl"; | ||
385 | close(read_from) || die "pipe from openssl rsautl"; | ||
386 | $signature = pack("n", length($signature)) . $signature, | ||
387 | |||
388 | waitpid($pid, 0) || die; | ||
389 | die "openssl rsautl died: $?" if ($? >> 8); | ||
97 | 390 | ||
98 | # | 391 | # |
99 | # Build the signed binary | 392 | # Build the signed binary |
100 | # | 393 | # |
101 | ( | 394 | my $unsigned_module = read_file($module); |
102 | cat $src || exit $? | 395 | |
103 | echo '~Module signature appended~' || exit $? | 396 | my $magic_number = "~Module signature appended~\n"; |
104 | cat $x509.signer $x509.keyid || exit $? | 397 | |
398 | my $info = pack("CCCCCxxxN", | ||
399 | $algo, $hash, $id_type, | ||
400 | length($signers_name), | ||
401 | length($key_identifier), | ||
402 | length($signature)); | ||
105 | 403 | ||
106 | # Preface each signature integer with a 2-byte BE length | 404 | if ($verbose) { |
107 | perl -e "binmode STDOUT; print pack(\"n\", $siglen)" || exit $? | 405 | print "Size of unsigned module: ", length($unsigned_module), "\n"; |
108 | cat $src.sig || exit $? | 406 | print "Size of signer's name : ", length($signers_name), "\n"; |
407 | print "Size of key identifier : ", length($key_identifier), "\n"; | ||
408 | print "Size of signature : ", length($signature), "\n"; | ||
409 | print "Size of informaton : ", length($info), "\n"; | ||
410 | print "Size of magic number : ", length($magic_number), "\n"; | ||
411 | print "Signer's name : '", $signers_name, "'\n"; | ||
412 | print "Digest : $dgst\n"; | ||
413 | } | ||
109 | 414 | ||
110 | # Generate the information block | 415 | open(FD, ">$dest") || die $dest; |
111 | perl -e "binmode STDOUT; print pack(\"CCCCCxxxN\", $algo, $hash, $id_type, $signerlen, $keyidlen, $siglen + 2)" || exit $? | 416 | binmode FD; |
112 | ) >$dst~ || exit $? | 417 | print FD |
418 | $unsigned_module, | ||
419 | $signers_name, | ||
420 | $key_identifier, | ||
421 | $signature, | ||
422 | $info, | ||
423 | $magic_number | ||
424 | ; | ||
425 | close FD || die $dest; | ||
113 | 426 | ||
114 | # Permit in-place signing | 427 | if ($#ARGV != 3) { |
115 | mv $dst~ $dst || exit $? | 428 | rename($dest, $module) || die $module; |
429 | } | ||
diff --git a/scripts/sortextable.c b/scripts/sortextable.c index f19ddc47304c..1f10e89d15b4 100644 --- a/scripts/sortextable.c +++ b/scripts/sortextable.c | |||
@@ -248,6 +248,7 @@ do_file(char const *const fname) | |||
248 | case EM_S390: | 248 | case EM_S390: |
249 | custom_sort = sort_relative_table; | 249 | custom_sort = sort_relative_table; |
250 | break; | 250 | break; |
251 | case EM_ARM: | ||
251 | case EM_MIPS: | 252 | case EM_MIPS: |
252 | break; | 253 | break; |
253 | } /* end switch */ | 254 | } /* end switch */ |
diff --git a/scripts/tags.sh b/scripts/tags.sh index 79fdafb0d263..08f06c00745e 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh | |||
@@ -48,13 +48,14 @@ find_arch_sources() | |||
48 | for i in $archincludedir; do | 48 | for i in $archincludedir; do |
49 | prune="$prune -wholename $i -prune -o" | 49 | prune="$prune -wholename $i -prune -o" |
50 | done | 50 | done |
51 | find ${tree}arch/$1 $ignore $prune -name "$2" -print; | 51 | find ${tree}arch/$1 $ignore $subarchprune $prune -name "$2" -print; |
52 | } | 52 | } |
53 | 53 | ||
54 | # find sources in arch/$1/include | 54 | # find sources in arch/$1/include |
55 | find_arch_include_sources() | 55 | find_arch_include_sources() |
56 | { | 56 | { |
57 | include=$(find ${tree}arch/$1/ -name include -type d); | 57 | include=$(find ${tree}arch/$1/ $subarchprune \ |
58 | -name include -type d -print); | ||
58 | if [ -n "$include" ]; then | 59 | if [ -n "$include" ]; then |
59 | archincludedir="$archincludedir $include" | 60 | archincludedir="$archincludedir $include" |
60 | find $include $ignore -name "$2" -print; | 61 | find $include $ignore -name "$2" -print; |
@@ -95,6 +96,32 @@ all_sources() | |||
95 | find_other_sources '*.[chS]' | 96 | find_other_sources '*.[chS]' |
96 | } | 97 | } |
97 | 98 | ||
99 | all_compiled_sources() | ||
100 | { | ||
101 | for i in $(all_sources); do | ||
102 | case "$i" in | ||
103 | *.[cS]) | ||
104 | j=${i/\.[cS]/\.o} | ||
105 | if [ -e $j ]; then | ||
106 | echo $i | ||
107 | fi | ||
108 | ;; | ||
109 | *) | ||
110 | echo $i | ||
111 | ;; | ||
112 | esac | ||
113 | done | ||
114 | } | ||
115 | |||
116 | all_target_sources() | ||
117 | { | ||
118 | if [ -n "$COMPILED_SOURCE" ]; then | ||
119 | all_compiled_sources | ||
120 | else | ||
121 | all_sources | ||
122 | fi | ||
123 | } | ||
124 | |||
98 | all_kconfigs() | 125 | all_kconfigs() |
99 | { | 126 | { |
100 | for arch in $ALLSOURCE_ARCHS; do | 127 | for arch in $ALLSOURCE_ARCHS; do |
@@ -110,18 +137,18 @@ all_defconfigs() | |||
110 | 137 | ||
111 | docscope() | 138 | docscope() |
112 | { | 139 | { |
113 | (echo \-k; echo \-q; all_sources) > cscope.files | 140 | (echo \-k; echo \-q; all_target_sources) > cscope.files |
114 | cscope -b -f cscope.out | 141 | cscope -b -f cscope.out |
115 | } | 142 | } |
116 | 143 | ||
117 | dogtags() | 144 | dogtags() |
118 | { | 145 | { |
119 | all_sources | gtags -i -f - | 146 | all_target_sources | gtags -i -f - |
120 | } | 147 | } |
121 | 148 | ||
122 | exuberant() | 149 | exuberant() |
123 | { | 150 | { |
124 | all_sources | xargs $1 -a \ | 151 | all_target_sources | xargs $1 -a \ |
125 | -I __initdata,__exitdata,__acquires,__releases \ | 152 | -I __initdata,__exitdata,__acquires,__releases \ |
126 | -I __read_mostly,____cacheline_aligned \ | 153 | -I __read_mostly,____cacheline_aligned \ |
127 | -I ____cacheline_aligned_in_smp \ | 154 | -I ____cacheline_aligned_in_smp \ |
@@ -173,7 +200,7 @@ exuberant() | |||
173 | 200 | ||
174 | emacs() | 201 | emacs() |
175 | { | 202 | { |
176 | all_sources | xargs $1 -a \ | 203 | all_target_sources | xargs $1 -a \ |
177 | --regex='/^(ENTRY|_GLOBAL)(\([^)]*\)).*/\2/' \ | 204 | --regex='/^(ENTRY|_GLOBAL)(\([^)]*\)).*/\2/' \ |
178 | --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ | 205 | --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ |
179 | --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ | 206 | --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ |
@@ -220,11 +247,10 @@ xtags() | |||
220 | elif $1 --version 2>&1 | grep -iq emacs; then | 247 | elif $1 --version 2>&1 | grep -iq emacs; then |
221 | emacs $1 | 248 | emacs $1 |
222 | else | 249 | else |
223 | all_sources | xargs $1 -a | 250 | all_target_sources | xargs $1 -a |
224 | fi | 251 | fi |
225 | } | 252 | } |
226 | 253 | ||
227 | |||
228 | # Support um (which uses SUBARCH) | 254 | # Support um (which uses SUBARCH) |
229 | if [ "${ARCH}" = "um" ]; then | 255 | if [ "${ARCH}" = "um" ]; then |
230 | if [ "$SUBARCH" = "i386" ]; then | 256 | if [ "$SUBARCH" = "i386" ]; then |
@@ -234,6 +260,21 @@ if [ "${ARCH}" = "um" ]; then | |||
234 | else | 260 | else |
235 | archinclude=${SUBARCH} | 261 | archinclude=${SUBARCH} |
236 | fi | 262 | fi |
263 | elif [ "${SRCARCH}" = "arm" -a "${SUBARCH}" != "" ]; then | ||
264 | subarchdir=$(find ${tree}arch/$SRCARCH/ -name "mach-*" -type d -o \ | ||
265 | -name "plat-*" -type d); | ||
266 | for i in $subarchdir; do | ||
267 | case "$i" in | ||
268 | *"mach-"${SUBARCH}) | ||
269 | ;; | ||
270 | *"plat-"${SUBARCH}) | ||
271 | ;; | ||
272 | *) | ||
273 | subarchprune="$subarchprune \ | ||
274 | -wholename $i -prune -o" | ||
275 | ;; | ||
276 | esac | ||
277 | done | ||
237 | fi | 278 | fi |
238 | 279 | ||
239 | remove_structs= | 280 | remove_structs= |
diff --git a/scripts/x509keyid b/scripts/x509keyid deleted file mode 100755 index c8e91a4af385..000000000000 --- a/scripts/x509keyid +++ /dev/null | |||
@@ -1,268 +0,0 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | # | ||
3 | # Generate an identifier from an X.509 certificate that can be placed in a | ||
4 | # module signature to indentify the key to use. | ||
5 | # | ||
6 | # Format: | ||
7 | # | ||
8 | # ./scripts/x509keyid <x509-cert> <signer's-name> <key-id> | ||
9 | # | ||
10 | # We read the DER-encoded X509 certificate and parse it to extract the Subject | ||
11 | # name and Subject Key Identifier. The provide the data we need to build the | ||
12 | # certificate identifier. | ||
13 | # | ||
14 | # The signer's name part of the identifier is fabricated from the commonName, | ||
15 | # the organizationName or the emailAddress components of the X.509 subject | ||
16 | # name and written to the second named file. | ||
17 | # | ||
18 | # The subject key ID to select which of that signer's certificates we're | ||
19 | # intending to use to sign the module is written to the third named file. | ||
20 | # | ||
21 | use strict; | ||
22 | |||
23 | my $raw_data; | ||
24 | |||
25 | die "Need three filenames\n" if ($#ARGV != 2); | ||
26 | |||
27 | my $src = $ARGV[0]; | ||
28 | |||
29 | open(FD, "<$src") || die $src; | ||
30 | binmode FD; | ||
31 | my @st = stat(FD); | ||
32 | die $src if (!@st); | ||
33 | read(FD, $raw_data, $st[7]) || die $src; | ||
34 | close(FD); | ||
35 | |||
36 | my $UNIV = 0 << 6; | ||
37 | my $APPL = 1 << 6; | ||
38 | my $CONT = 2 << 6; | ||
39 | my $PRIV = 3 << 6; | ||
40 | |||
41 | my $CONS = 0x20; | ||
42 | |||
43 | my $BOOLEAN = 0x01; | ||
44 | my $INTEGER = 0x02; | ||
45 | my $BIT_STRING = 0x03; | ||
46 | my $OCTET_STRING = 0x04; | ||
47 | my $NULL = 0x05; | ||
48 | my $OBJ_ID = 0x06; | ||
49 | my $UTF8String = 0x0c; | ||
50 | my $SEQUENCE = 0x10; | ||
51 | my $SET = 0x11; | ||
52 | my $UTCTime = 0x17; | ||
53 | my $GeneralizedTime = 0x18; | ||
54 | |||
55 | my %OIDs = ( | ||
56 | pack("CCC", 85, 4, 3) => "commonName", | ||
57 | pack("CCC", 85, 4, 6) => "countryName", | ||
58 | pack("CCC", 85, 4, 10) => "organizationName", | ||
59 | pack("CCC", 85, 4, 11) => "organizationUnitName", | ||
60 | pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 1) => "rsaEncryption", | ||
61 | pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 5) => "sha1WithRSAEncryption", | ||
62 | pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 9, 1) => "emailAddress", | ||
63 | pack("CCC", 85, 29, 35) => "authorityKeyIdentifier", | ||
64 | pack("CCC", 85, 29, 14) => "subjectKeyIdentifier", | ||
65 | pack("CCC", 85, 29, 19) => "basicConstraints" | ||
66 | ); | ||
67 | |||
68 | ############################################################################### | ||
69 | # | ||
70 | # Extract an ASN.1 element from a string and return information about it. | ||
71 | # | ||
72 | ############################################################################### | ||
73 | sub asn1_extract($$@) | ||
74 | { | ||
75 | my ($cursor, $expected_tag, $optional) = @_; | ||
76 | |||
77 | return [ -1 ] | ||
78 | if ($cursor->[1] == 0 && $optional); | ||
79 | |||
80 | die $src, ": ", $cursor->[0], ": ASN.1 data underrun (elem ", $cursor->[1], ")\n" | ||
81 | if ($cursor->[1] < 2); | ||
82 | |||
83 | my ($tag, $len) = unpack("CC", substr(${$cursor->[2]}, $cursor->[0], 2)); | ||
84 | |||
85 | if ($expected_tag != -1 && $tag != $expected_tag) { | ||
86 | return [ -1 ] | ||
87 | if ($optional); | ||
88 | die $src, ": ", $cursor->[0], ": ASN.1 unexpected tag (", $tag, | ||
89 | " not ", $expected_tag, ")\n"; | ||
90 | } | ||
91 | |||
92 | $cursor->[0] += 2; | ||
93 | $cursor->[1] -= 2; | ||
94 | |||
95 | die $src, ": ", $cursor->[0], ": ASN.1 long tag\n" | ||
96 | if (($tag & 0x1f) == 0x1f); | ||
97 | die $src, ": ", $cursor->[0], ": ASN.1 indefinite length\n" | ||
98 | if ($len == 0x80); | ||
99 | |||
100 | if ($len > 0x80) { | ||
101 | my $l = $len - 0x80; | ||
102 | die $src, ": ", $cursor->[0], ": ASN.1 data underrun (len len $l)\n" | ||
103 | if ($cursor->[1] < $l); | ||
104 | |||
105 | if ($l == 0x1) { | ||
106 | $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)); | ||
107 | } elsif ($l = 0x2) { | ||
108 | $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0], 2)); | ||
109 | } elsif ($l = 0x3) { | ||
110 | $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)) << 16; | ||
111 | $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0] + 1, 2)); | ||
112 | } elsif ($l = 0x4) { | ||
113 | $len = unpack("N", substr(${$cursor->[2]}, $cursor->[0], 4)); | ||
114 | } else { | ||
115 | die $src, ": ", $cursor->[0], ": ASN.1 element too long (", $l, ")\n"; | ||
116 | } | ||
117 | |||
118 | $cursor->[0] += $l; | ||
119 | $cursor->[1] -= $l; | ||
120 | } | ||
121 | |||
122 | die $src, ": ", $cursor->[0], ": ASN.1 data underrun (", $len, ")\n" | ||
123 | if ($cursor->[1] < $len); | ||
124 | |||
125 | my $ret = [ $tag, [ $cursor->[0], $len, $cursor->[2] ] ]; | ||
126 | $cursor->[0] += $len; | ||
127 | $cursor->[1] -= $len; | ||
128 | |||
129 | return $ret; | ||
130 | } | ||
131 | |||
132 | ############################################################################### | ||
133 | # | ||
134 | # Retrieve the data referred to by a cursor | ||
135 | # | ||
136 | ############################################################################### | ||
137 | sub asn1_retrieve($) | ||
138 | { | ||
139 | my ($cursor) = @_; | ||
140 | my ($offset, $len, $data) = @$cursor; | ||
141 | return substr($$data, $offset, $len); | ||
142 | } | ||
143 | |||
144 | ############################################################################### | ||
145 | # | ||
146 | # Roughly parse the X.509 certificate | ||
147 | # | ||
148 | ############################################################################### | ||
149 | my $cursor = [ 0, length($raw_data), \$raw_data ]; | ||
150 | |||
151 | my $cert = asn1_extract($cursor, $UNIV | $CONS | $SEQUENCE); | ||
152 | my $tbs = asn1_extract($cert->[1], $UNIV | $CONS | $SEQUENCE); | ||
153 | my $version = asn1_extract($tbs->[1], $CONT | $CONS | 0, 1); | ||
154 | my $serial_number = asn1_extract($tbs->[1], $UNIV | $INTEGER); | ||
155 | my $sig_type = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
156 | my $issuer = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
157 | my $validity = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
158 | my $subject = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
159 | my $key = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE); | ||
160 | my $issuer_uid = asn1_extract($tbs->[1], $CONT | $CONS | 1, 1); | ||
161 | my $subject_uid = asn1_extract($tbs->[1], $CONT | $CONS | 2, 1); | ||
162 | my $extension_list = asn1_extract($tbs->[1], $CONT | $CONS | 3, 1); | ||
163 | |||
164 | my $subject_key_id = (); | ||
165 | my $authority_key_id = (); | ||
166 | |||
167 | # | ||
168 | # Parse the extension list | ||
169 | # | ||
170 | if ($extension_list->[0] != -1) { | ||
171 | my $extensions = asn1_extract($extension_list->[1], $UNIV | $CONS | $SEQUENCE); | ||
172 | |||
173 | while ($extensions->[1]->[1] > 0) { | ||
174 | my $ext = asn1_extract($extensions->[1], $UNIV | $CONS | $SEQUENCE); | ||
175 | my $x_oid = asn1_extract($ext->[1], $UNIV | $OBJ_ID); | ||
176 | my $x_crit = asn1_extract($ext->[1], $UNIV | $BOOLEAN, 1); | ||
177 | my $x_val = asn1_extract($ext->[1], $UNIV | $OCTET_STRING); | ||
178 | |||
179 | my $raw_oid = asn1_retrieve($x_oid->[1]); | ||
180 | next if (!exists($OIDs{$raw_oid})); | ||
181 | my $x_type = $OIDs{$raw_oid}; | ||
182 | |||
183 | my $raw_value = asn1_retrieve($x_val->[1]); | ||
184 | |||
185 | if ($x_type eq "subjectKeyIdentifier") { | ||
186 | my $vcursor = [ 0, length($raw_value), \$raw_value ]; | ||
187 | |||
188 | $subject_key_id = asn1_extract($vcursor, $UNIV | $OCTET_STRING); | ||
189 | } | ||
190 | } | ||
191 | } | ||
192 | |||
193 | ############################################################################### | ||
194 | # | ||
195 | # Determine what we're going to use as the signer's name. In order of | ||
196 | # preference, take one of: commonName, organizationName or emailAddress. | ||
197 | # | ||
198 | ############################################################################### | ||
199 | my $org = ""; | ||
200 | my $cn = ""; | ||
201 | my $email = ""; | ||
202 | |||
203 | while ($subject->[1]->[1] > 0) { | ||
204 | my $rdn = asn1_extract($subject->[1], $UNIV | $CONS | $SET); | ||
205 | my $attr = asn1_extract($rdn->[1], $UNIV | $CONS | $SEQUENCE); | ||
206 | my $n_oid = asn1_extract($attr->[1], $UNIV | $OBJ_ID); | ||
207 | my $n_val = asn1_extract($attr->[1], -1); | ||
208 | |||
209 | my $raw_oid = asn1_retrieve($n_oid->[1]); | ||
210 | next if (!exists($OIDs{$raw_oid})); | ||
211 | my $n_type = $OIDs{$raw_oid}; | ||
212 | |||
213 | my $raw_value = asn1_retrieve($n_val->[1]); | ||
214 | |||
215 | if ($n_type eq "organizationName") { | ||
216 | $org = $raw_value; | ||
217 | } elsif ($n_type eq "commonName") { | ||
218 | $cn = $raw_value; | ||
219 | } elsif ($n_type eq "emailAddress") { | ||
220 | $email = $raw_value; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | my $id_name = $email; | ||
225 | |||
226 | if ($org && $cn) { | ||
227 | # Don't use the organizationName if the commonName repeats it | ||
228 | if (length($org) <= length($cn) && | ||
229 | substr($cn, 0, length($org)) eq $org) { | ||
230 | $id_name = $cn; | ||
231 | goto got_id_name; | ||
232 | } | ||
233 | |||
234 | # Or a signifcant chunk of it | ||
235 | if (length($org) >= 7 && | ||
236 | length($cn) >= 7 && | ||
237 | substr($cn, 0, 7) eq substr($org, 0, 7)) { | ||
238 | $id_name = $cn; | ||
239 | goto got_id_name; | ||
240 | } | ||
241 | |||
242 | $id_name = $org . ": " . $cn; | ||
243 | } elsif ($org) { | ||
244 | $id_name = $org; | ||
245 | } elsif ($cn) { | ||
246 | $id_name = $cn; | ||
247 | } | ||
248 | |||
249 | got_id_name: | ||
250 | |||
251 | ############################################################################### | ||
252 | # | ||
253 | # Output the signer's name and the key identifier that we're going to include | ||
254 | # in module signatures. | ||
255 | # | ||
256 | ############################################################################### | ||
257 | die $src, ": ", "X.509: Couldn't find the Subject Key Identifier extension\n" | ||
258 | if (!$subject_key_id); | ||
259 | |||
260 | my $id_key_id = asn1_retrieve($subject_key_id->[1]); | ||
261 | |||
262 | open(OUTFD, ">$ARGV[1]") || die $ARGV[1]; | ||
263 | print OUTFD $id_name; | ||
264 | close OUTFD || die $ARGV[1]; | ||
265 | |||
266 | open(OUTFD, ">$ARGV[2]") || die $ARGV[2]; | ||
267 | print OUTFD $id_key_id; | ||
268 | close OUTFD || die $ARGV[2]; | ||