Skip to content

Commit c107785

Browse files
committed
Merge tag 'modules-7.0-rc3.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux
Pull module fixes from Sami Tolvanen: - Fix a potential kernel panic in the module loader by adding a bounds check for the ELF section index. This prevents crashes if attempting to load a module that uses SHN_XINDEX or is corrupted. - Fix the Kconfig menu layout for module versioning, signing, and compression options so they correctly appear as submenus in menuconfig. - Remove a redundant lockdep_free_key_range() call in the load_module() error path. This is already handled by module_deallocate() calling free_mod_mem() since the module_memory rework. * tag 'modules-7.0-rc3.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux: module: Fix kernel panic when a symbol st_shndx is out of bounds module: Fix the modversions and signing submenus module: Remove duplicate freeing of lockdep classes
2 parents 0b3bb20 + f9d69d5 commit c107785

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

kernel/module/Kconfig

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ config MODVERSIONS
169169
make them incompatible with the kernel you are running. If
170170
unsure, say N.
171171

172+
if MODVERSIONS
173+
172174
choice
173175
prompt "Module versioning implementation"
174-
depends on MODVERSIONS
175176
help
176177
Select the tool used to calculate symbol versions for modules.
177178

@@ -206,15 +207,14 @@ endchoice
206207

207208
config ASM_MODVERSIONS
208209
bool
209-
default HAVE_ASM_MODVERSIONS && MODVERSIONS
210+
default HAVE_ASM_MODVERSIONS
210211
help
211212
This enables module versioning for exported symbols also from
212213
assembly. This can be enabled only when the target architecture
213214
supports it.
214215

215216
config EXTENDED_MODVERSIONS
216217
bool "Extended Module Versioning Support"
217-
depends on MODVERSIONS
218218
help
219219
This enables extended MODVERSIONs support, allowing long symbol
220220
names to be versioned.
@@ -224,7 +224,6 @@ config EXTENDED_MODVERSIONS
224224

225225
config BASIC_MODVERSIONS
226226
bool "Basic Module Versioning Support"
227-
depends on MODVERSIONS
228227
default y
229228
help
230229
This enables basic MODVERSIONS support, allowing older tools or
@@ -237,6 +236,8 @@ config BASIC_MODVERSIONS
237236
This is enabled by default when MODVERSIONS are enabled.
238237
If unsure, say Y.
239238

239+
endif # MODVERSIONS
240+
240241
config MODULE_SRCVERSION_ALL
241242
bool "Source checksum for all modules"
242243
help
@@ -277,10 +278,11 @@ config MODULE_SIG_FORCE
277278
Reject unsigned modules or signed modules for which we don't have a
278279
key. Without this, such modules will simply taint the kernel.
279280

281+
if MODULE_SIG || IMA_APPRAISE_MODSIG
282+
280283
config MODULE_SIG_ALL
281284
bool "Automatically sign all modules"
282285
default y
283-
depends on MODULE_SIG || IMA_APPRAISE_MODSIG
284286
help
285287
Sign all modules during make modules_install. Without this option,
286288
modules must be signed manually, using the scripts/sign-file tool.
@@ -290,7 +292,6 @@ comment "Do not forget to sign required modules with scripts/sign-file"
290292

291293
choice
292294
prompt "Hash algorithm to sign modules"
293-
depends on MODULE_SIG || IMA_APPRAISE_MODSIG
294295
default MODULE_SIG_SHA512
295296
help
296297
This determines which sort of hashing algorithm will be used during
@@ -327,14 +328,15 @@ endchoice
327328

328329
config MODULE_SIG_HASH
329330
string
330-
depends on MODULE_SIG || IMA_APPRAISE_MODSIG
331331
default "sha256" if MODULE_SIG_SHA256
332332
default "sha384" if MODULE_SIG_SHA384
333333
default "sha512" if MODULE_SIG_SHA512
334334
default "sha3-256" if MODULE_SIG_SHA3_256
335335
default "sha3-384" if MODULE_SIG_SHA3_384
336336
default "sha3-512" if MODULE_SIG_SHA3_512
337337

338+
endif # MODULE_SIG || IMA_APPRAISE_MODSIG
339+
338340
config MODULE_COMPRESS
339341
bool "Module compression"
340342
help
@@ -350,9 +352,10 @@ config MODULE_COMPRESS
350352

351353
If unsure, say N.
352354

355+
if MODULE_COMPRESS
356+
353357
choice
354358
prompt "Module compression type"
355-
depends on MODULE_COMPRESS
356359
help
357360
Choose the supported algorithm for module compression.
358361

@@ -379,7 +382,6 @@ endchoice
379382
config MODULE_COMPRESS_ALL
380383
bool "Automatically compress all modules"
381384
default y
382-
depends on MODULE_COMPRESS
383385
help
384386
Compress all modules during 'make modules_install'.
385387

@@ -389,7 +391,6 @@ config MODULE_COMPRESS_ALL
389391

390392
config MODULE_DECOMPRESS
391393
bool "Support in-kernel module decompression"
392-
depends on MODULE_COMPRESS
393394
select ZLIB_INFLATE if MODULE_COMPRESS_GZIP
394395
select XZ_DEC if MODULE_COMPRESS_XZ
395396
select ZSTD_DECOMPRESS if MODULE_COMPRESS_ZSTD
@@ -400,6 +401,8 @@ config MODULE_DECOMPRESS
400401

401402
If unsure, say N.
402403

404+
endif # MODULE_COMPRESS
405+
403406
config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS
404407
bool "Allow loading of modules with missing namespace imports"
405408
help

kernel/module/main.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,13 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
15681568
break;
15691569

15701570
default:
1571+
if (sym[i].st_shndx >= info->hdr->e_shnum) {
1572+
pr_err("%s: Symbol %s has an invalid section index %u (max %u)\n",
1573+
mod->name, name, sym[i].st_shndx, info->hdr->e_shnum - 1);
1574+
ret = -ENOEXEC;
1575+
break;
1576+
}
1577+
15711578
/* Divert to percpu allocation if a percpu var. */
15721579
if (sym[i].st_shndx == info->index.pcpu)
15731580
secbase = (unsigned long)mod_percpu(mod);
@@ -3544,12 +3551,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
35443551
mutex_unlock(&module_mutex);
35453552
free_module:
35463553
mod_stat_bump_invalid(info, flags);
3547-
/* Free lock-classes; relies on the preceding sync_rcu() */
3548-
for_class_mod_mem_type(type, core_data) {
3549-
lockdep_free_key_range(mod->mem[type].base,
3550-
mod->mem[type].size);
3551-
}
3552-
35533554
module_memory_restore_rox(mod);
35543555
module_deallocate(mod, info);
35553556
free_copy:

0 commit comments

Comments
 (0)