Skip to content

Commit f8ce1fa

Browse files
committed
Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull mudule updates from Rusty Russell: "We get rid of the general module prefix confusion with a binary config option, fix a remove/insert race which Never Happens, and (my favorite) handle the case when we have too many modules for a single commandline. Seriously, the kernel is full, please go away!" * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: modpost: fix unwanted VMLINUX_SYMBOL_STR expansion X.509: Support parse long form of length octets in Authority Key Identifier module: don't unlink the module until we've removed all exposure. kernel: kallsyms: memory override issue, need check destination buffer length MODSIGN: do not send garbage to stderr when enabling modules signature modpost: handle huge numbers of modules. modpost: add -T option to read module names from file/stdin. modpost: minor cleanup. genksyms: pass symbol-prefix instead of arch module: fix symbol versioning with symbol prefixes CONFIG_SYMBOL_PREFIX: cleanup.
2 parents 24d0c25 + a53a11f commit f8ce1fa

23 files changed

Lines changed: 201 additions & 139 deletions

File tree

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))
13991399
# Run depmod only if we have System.map and depmod is executable
14001400
quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
14011401
cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
1402-
$(KERNELRELEASE) "$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))"
1402+
$(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))"
14031403

14041404
# Create temporary dir for module support files
14051405
# clean it up only when building all modules

‎arch/Kconfig‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,12 @@ config MODULES_USE_ELF_REL
381381
Modules only use ELF REL relocations. Modules with ELF RELA
382382
relocations will give an error.
383383

384+
config HAVE_UNDERSCORE_SYMBOL_PREFIX
385+
bool
386+
help
387+
Some architectures generate an _ in front of C symbols; things like
388+
module loading and assembly files need to know about this.
389+
384390
#
385391
# ABI hall of shame
386392
#

‎arch/blackfin/Kconfig‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
config SYMBOL_PREFIX
2-
string
3-
default "_"
4-
51
config MMU
62
def_bool n
73

@@ -33,6 +29,7 @@ config BLACKFIN
3329
select ARCH_HAVE_CUSTOM_GPIO_H
3430
select ARCH_WANT_OPTIONAL_GPIOLIB
3531
select HAVE_UID16
32+
select HAVE_UNDERSCORE_SYMBOL_PREFIX
3633
select VIRT_TO_BUS
3734
select ARCH_WANT_IPC_PARSE_VERSION
3835
select HAVE_GENERIC_HARDIRQS

‎arch/h8300/Kconfig‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ config H8300
1212
select MODULES_USE_ELF_RELA
1313
select OLD_SIGSUSPEND3
1414
select OLD_SIGACTION
15-
16-
config SYMBOL_PREFIX
17-
string
18-
default "_"
15+
select HAVE_UNDERSCORE_SYMBOL_PREFIX
1916

2017
config MMU
2118
bool

‎arch/metag/Kconfig‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
config SYMBOL_PREFIX
2-
string
3-
default "_"
4-
51
config METAG
62
def_bool y
73
select EMBEDDED
@@ -28,6 +24,7 @@ config METAG
2824
select HAVE_OPROFILE
2925
select HAVE_PERF_EVENTS
3026
select HAVE_SYSCALL_TRACEPOINTS
27+
select HAVE_UNDERSCORE_SYMBOL_PREFIX
3128
select IRQ_DOMAIN
3229
select MODULES_USE_ELF_RELA
3330
select OF

‎crypto/asymmetric_keys/x509_cert_parser.c‎

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,9 @@ int rsa_extract_mpi(void *context, size_t hdrlen,
373373
return 0;
374374
}
375375

376+
/* The keyIdentifier in AuthorityKeyIdentifier SEQUENCE is tag(CONT,PRIM,0) */
377+
#define SEQ_TAG_KEYID (ASN1_CONT << 6)
378+
376379
/*
377380
* Process certificate extensions that are used to qualify the certificate.
378381
*/
@@ -407,21 +410,57 @@ int x509_process_extension(void *context, size_t hdrlen,
407410
}
408411

409412
if (ctx->last_oid == OID_authorityKeyIdentifier) {
413+
size_t key_len;
414+
410415
/* Get hold of the CA key fingerprint */
411416
if (vlen < 5)
412417
return -EBADMSG;
413-
if (v[0] != (ASN1_SEQ | (ASN1_CONS << 5)) ||
414-
v[1] != vlen - 2 ||
415-
v[2] != (ASN1_CONT << 6) ||
416-
v[3] != vlen - 4)
418+
419+
/* Authority Key Identifier must be a Constructed SEQUENCE */
420+
if (v[0] != (ASN1_SEQ | (ASN1_CONS << 5)))
417421
return -EBADMSG;
418-
v += 4;
419-
vlen -= 4;
420422

421-
f = kmalloc(vlen * 2 + 1, GFP_KERNEL);
423+
/* Authority Key Identifier is not indefinite length */
424+
if (unlikely(vlen == ASN1_INDEFINITE_LENGTH))
425+
return -EBADMSG;
426+
427+
if (vlen < ASN1_INDEFINITE_LENGTH) {
428+
/* Short Form length */
429+
if (v[1] != vlen - 2 ||
430+
v[2] != SEQ_TAG_KEYID ||
431+
v[3] > vlen - 4)
432+
return -EBADMSG;
433+
434+
key_len = v[3];
435+
v += 4;
436+
} else {
437+
/* Long Form length */
438+
size_t seq_len = 0;
439+
size_t sub = v[1] - ASN1_INDEFINITE_LENGTH;
440+
441+
if (sub > 2)
442+
return -EBADMSG;
443+
444+
/* calculate the length from subsequent octets */
445+
v += 2;
446+
for (i = 0; i < sub; i++) {
447+
seq_len <<= 8;
448+
seq_len |= v[i];
449+
}
450+
451+
if (seq_len != vlen - 2 - sub ||
452+
v[sub] != SEQ_TAG_KEYID ||
453+
v[sub + 1] > vlen - 4 - sub)
454+
return -EBADMSG;
455+
456+
key_len = v[sub + 1];
457+
v += (sub + 2);
458+
}
459+
460+
f = kmalloc(key_len * 2 + 1, GFP_KERNEL);
422461
if (!f)
423462
return -ENOMEM;
424-
for (i = 0; i < vlen; i++)
463+
for (i = 0; i < key_len; i++)
425464
sprintf(f + i * 2, "%02x", v[i]);
426465
pr_debug("authority %s\n", f);
427466
ctx->cert->authority = f;

‎drivers/mtd/chips/gen_probe.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,16 @@ static inline struct mtd_info *cfi_cmdset_unknown(struct map_info *map,
204204
struct cfi_private *cfi = map->fldrv_priv;
205205
__u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID;
206206
#ifdef CONFIG_MODULES
207-
char probename[16+sizeof(MODULE_SYMBOL_PREFIX)];
207+
char probename[sizeof(VMLINUX_SYMBOL_STR(cfi_cmdset_%4.4X))];
208208
cfi_cmdset_fn_t *probe_function;
209209

210-
sprintf(probename, MODULE_SYMBOL_PREFIX "cfi_cmdset_%4.4X", type);
210+
sprintf(probename, VMLINUX_SYMBOL_STR(cfi_cmdset_%4.4X), type);
211211

212212
probe_function = __symbol_get(probename);
213213
if (!probe_function) {
214-
request_module(probename + sizeof(MODULE_SYMBOL_PREFIX) - 1);
214+
char modname[sizeof("cfi_cmdset_%4.4X")];
215+
sprintf(modname, "cfi_cmdset_%4.4X", type);
216+
request_module(modname);
215217
probe_function = __symbol_get(probename);
216218
}
217219

‎include/asm-generic/unistd.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <uapi/asm-generic/unistd.h>
2+
#include <linux/export.h>
23

34
/*
45
* These are required system calls, we should

‎include/asm-generic/vmlinux.lds.h‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,7 @@
5252
#define LOAD_OFFSET 0
5353
#endif
5454

55-
#ifndef SYMBOL_PREFIX
56-
#define VMLINUX_SYMBOL(sym) sym
57-
#else
58-
#define PASTE2(x,y) x##y
59-
#define PASTE(x,y) PASTE2(x,y)
60-
#define VMLINUX_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym)
61-
#endif
55+
#include <linux/export.h>
6256

6357
/* Align . to a 8 byte boundary equals to maximum function alignment. */
6458
#define ALIGN_FUNCTION() . = ALIGN(8)

‎include/linux/export.h‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,24 @@
55
* to reduce the amount of pointless cruft we feed to gcc when only
66
* exporting a simple symbol or two.
77
*
8-
* If you feel the need to add #include <linux/foo.h> to this file
9-
* then you are doing something wrong and should go away silently.
8+
* Try not to add #includes here. It slows compilation and makes kernel
9+
* hackers place grumpy comments in header files.
1010
*/
1111

1212
/* Some toolchains use a `_' prefix for all user symbols. */
13-
#ifdef CONFIG_SYMBOL_PREFIX
14-
#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
13+
#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
14+
#define __VMLINUX_SYMBOL(x) _##x
15+
#define __VMLINUX_SYMBOL_STR(x) "_" #x
1516
#else
16-
#define MODULE_SYMBOL_PREFIX ""
17+
#define __VMLINUX_SYMBOL(x) x
18+
#define __VMLINUX_SYMBOL_STR(x) #x
1719
#endif
1820

21+
/* Indirect, so macros are expanded before pasting. */
22+
#define VMLINUX_SYMBOL(x) __VMLINUX_SYMBOL(x)
23+
#define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
24+
25+
#ifndef __ASSEMBLY__
1926
struct kernel_symbol
2027
{
2128
unsigned long value;
@@ -51,7 +58,7 @@ extern struct module __this_module;
5158
__CRC_SYMBOL(sym, sec) \
5259
static const char __kstrtab_##sym[] \
5360
__attribute__((section("__ksymtab_strings"), aligned(1))) \
54-
= MODULE_SYMBOL_PREFIX #sym; \
61+
= VMLINUX_SYMBOL_STR(sym); \
5562
static const struct kernel_symbol __ksymtab_##sym \
5663
__used \
5764
__attribute__((section("___ksymtab" sec "+" #sym), unused)) \
@@ -85,5 +92,6 @@ extern struct module __this_module;
8592
#define EXPORT_UNUSED_SYMBOL_GPL(sym)
8693

8794
#endif /* CONFIG_MODULES */
95+
#endif /* !__ASSEMBLY__ */
8896

8997
#endif /* _LINUX_EXPORT_H */

0 commit comments

Comments
 (0)