Skip to content

Commit a7423e6

Browse files
committed
Merge tag 'modules-7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux
Pull module updates from Sami Tolvanen: "Module signing: - Remove SHA-1 support for signing modules. SHA-1 is no longer considered secure for signatures due to vulnerabilities that can lead to hash collisions. None of the major distributions use SHA-1 anymore, and the kernel has defaulted to SHA-512 since v6.11. Note that loading SHA-1 signed modules is still supported. - Update scripts/sign-file to use only the OpenSSL CMS API for signing. As SHA-1 support is gone, we can drop the legacy PKCS#7 API which was limited to SHA-1. This also cleans up support for legacy OpenSSL versions. Cleanups and fixes: - Use system_dfl_wq instead of the per-cpu system_wq following the ongoing workqueue API refactoring. - Avoid open-coded kvrealloc() in module decompression logic by using the standard helper. - Improve section annotations by replacing the custom __modinit with __init_or_module and removing several unused __INIT*_OR_MODULE macros. - Fix kernel-doc warnings in include/linux/moduleparam.h. - Ensure set_module_sig_enforced is only declared when module signing is enabled. - Fix gendwarfksyms build failures on 32-bit hosts. MAINTAINERS: - Update the module subsystem entry to reflect the maintainer rotation and update the git repository link" * tag 'modules-7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux: modules: moduleparam.h: fix kernel-doc comments module: Only declare set_module_sig_enforced when CONFIG_MODULE_SIG=y module/decompress: Avoid open-coded kvrealloc() gendwarfksyms: Fix build on 32-bit hosts sign-file: Use only the OpenSSL CMS API for signing module: Remove SHA-1 support for module signing module: replace use of system_wq with system_dfl_wq params: Replace __modinit with __init_or_module module: Remove unused __INIT*_OR_MODULE macros MAINTAINERS: Update module subsystem maintainers and repository
2 parents b63c907 + b68758e commit a7423e6

10 files changed

Lines changed: 35 additions & 106 deletions

File tree

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17636,12 +17636,12 @@ MODULE SUPPORT
1763617636
M: Luis Chamberlain <mcgrof@kernel.org>
1763717637
M: Petr Pavlu <petr.pavlu@suse.com>
1763817638
M: Daniel Gomez <da.gomez@kernel.org>
17639-
R: Sami Tolvanen <samitolvanen@google.com>
17639+
M: Sami Tolvanen <samitolvanen@google.com>
1764017640
R: Aaron Tomlin <atomlin@atomlin.com>
1764117641
L: linux-modules@vger.kernel.org
1764217642
L: linux-kernel@vger.kernel.org
1764317643
S: Maintained
17644-
T: git git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git modules-next
17644+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux.git modules-next
1764517645
F: include/linux/kmod.h
1764617646
F: include/linux/module*.h
1764717647
F: kernel/module/

include/linux/module.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,10 @@ extern void cleanup_module(void);
151151
#define __init_or_module
152152
#define __initdata_or_module
153153
#define __initconst_or_module
154-
#define __INIT_OR_MODULE .text
155-
#define __INITDATA_OR_MODULE .data
156-
#define __INITRODATA_OR_MODULE .section ".rodata","a",%progbits
157154
#else
158155
#define __init_or_module __init
159156
#define __initdata_or_module __initdata
160157
#define __initconst_or_module __initconst
161-
#define __INIT_OR_MODULE __INIT
162-
#define __INITDATA_OR_MODULE __INITDATA
163-
#define __INITRODATA_OR_MODULE __INITRODATA
164158
#endif /*CONFIG_MODULES*/
165159

166160
struct module_kobject *lookup_or_create_module_kobject(const char *name);
@@ -770,8 +764,6 @@ static inline bool is_livepatch_module(struct module *mod)
770764
#endif
771765
}
772766

773-
void set_module_sig_enforced(void);
774-
775767
void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data);
776768

777769
#else /* !CONFIG_MODULES... */
@@ -866,10 +858,6 @@ static inline bool module_requested_async_probing(struct module *module)
866858
}
867859

868860

869-
static inline void set_module_sig_enforced(void)
870-
{
871-
}
872-
873861
/* Dereference module function descriptor */
874862
static inline
875863
void *dereference_module_function_descriptor(struct module *mod, void *ptr)
@@ -925,6 +913,8 @@ static inline bool retpoline_module_ok(bool has_retpoline)
925913
#ifdef CONFIG_MODULE_SIG
926914
bool is_module_sig_enforced(void);
927915

916+
void set_module_sig_enforced(void);
917+
928918
static inline bool module_sig_ok(struct module *module)
929919
{
930920
return module->sig_ok;
@@ -935,6 +925,10 @@ static inline bool is_module_sig_enforced(void)
935925
return false;
936926
}
937927

928+
static inline void set_module_sig_enforced(void)
929+
{
930+
}
931+
938932
static inline bool module_sig_ok(struct module *module)
939933
{
940934
return true;

include/linux/moduleparam.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ static inline void kernel_param_unlock(struct module *mod)
355355
/**
356356
* __core_param_cb - similar like core_param, with a set/get ops instead of type.
357357
* @name: the name of the cmdline and sysfs parameter (often the same as var)
358-
* @var: the variable
359358
* @ops: the set & get operations for this parameter.
359+
* @arg: the variable
360360
* @perm: visibility in sysfs
361361
*
362362
* Ideally this should be called 'core_param_cb', but the name has been
@@ -390,7 +390,7 @@ static inline void kernel_param_unlock(struct module *mod)
390390
* @name1: parameter name 1
391391
* @name2: parameter name 2
392392
*
393-
* Returns true if the two parameter names are equal.
393+
* Returns: true if the two parameter names are equal.
394394
* Dashes (-) are considered equal to underscores (_).
395395
*/
396396
extern bool parameq(const char *name1, const char *name2);
@@ -402,6 +402,10 @@ extern bool parameq(const char *name1, const char *name2);
402402
* @n: the length to compare
403403
*
404404
* Similar to parameq(), except it compares @n characters.
405+
*
406+
* Returns: true if the first @n characters of the two parameter names
407+
* are equal.
408+
* Dashes (-) are considered equal to underscores (_).
405409
*/
406410
extern bool parameqn(const char *name1, const char *name2, size_t n);
407411

kernel/module/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,6 @@ choice
299299
possible to load a signed module containing the algorithm to check
300300
the signature on that module.
301301

302-
config MODULE_SIG_SHA1
303-
bool "SHA-1"
304-
select CRYPTO_SHA1
305-
306302
config MODULE_SIG_SHA256
307303
bool "SHA-256"
308304
select CRYPTO_SHA256
@@ -332,7 +328,6 @@ endchoice
332328
config MODULE_SIG_HASH
333329
string
334330
depends on MODULE_SIG || IMA_APPRAISE_MODSIG
335-
default "sha1" if MODULE_SIG_SHA1
336331
default "sha256" if MODULE_SIG_SHA256
337332
default "sha384" if MODULE_SIG_SHA384
338333
default "sha512" if MODULE_SIG_SHA512

kernel/module/decompress.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
static int module_extend_max_pages(struct load_info *info, unsigned int extent)
1818
{
1919
struct page **new_pages;
20+
unsigned int new_max = info->max_pages + extent;
2021

21-
new_pages = kvmalloc_array(info->max_pages + extent,
22-
sizeof(info->pages), GFP_KERNEL);
22+
new_pages = kvrealloc(info->pages,
23+
size_mul(new_max, sizeof(*info->pages)),
24+
GFP_KERNEL);
2325
if (!new_pages)
2426
return -ENOMEM;
2527

26-
memcpy(new_pages, info->pages, info->max_pages * sizeof(info->pages));
27-
kvfree(info->pages);
2828
info->pages = new_pages;
29-
info->max_pages += extent;
29+
info->max_pages = new_max;
3030

3131
return 0;
3232
}

kernel/module/dups.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static void kmod_dup_request_complete(struct work_struct *work)
113113
* let this linger forever as this is just a boot optimization for
114114
* possible abuses of vmalloc() incurred by finit_module() thrashing.
115115
*/
116-
queue_delayed_work(system_wq, &kmod_req->delete_work, 60 * HZ);
116+
queue_delayed_work(system_dfl_wq, &kmod_req->delete_work, 60 * HZ);
117117
}
118118

119119
bool kmod_dup_request_exists_wait(char *module_name, bool wait, int *dup_ret)
@@ -240,7 +240,7 @@ void kmod_dup_request_announce(char *module_name, int ret)
240240
* There is no rush. But we also don't want to hold the
241241
* caller up forever or introduce any boot delays.
242242
*/
243-
queue_work(system_wq, &kmod_req->complete_work);
243+
queue_work(system_dfl_wq, &kmod_req->complete_work);
244244

245245
out:
246246
mutex_unlock(&kmod_dup_mutex);

kernel/params.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -596,12 +596,6 @@ static ssize_t param_attr_store(const struct module_attribute *mattr,
596596
}
597597
#endif
598598

599-
#ifdef CONFIG_MODULES
600-
#define __modinit
601-
#else
602-
#define __modinit __init
603-
#endif
604-
605599
#ifdef CONFIG_SYSFS
606600
void kernel_param_lock(struct module *mod)
607601
{
@@ -626,9 +620,9 @@ EXPORT_SYMBOL(kernel_param_unlock);
626620
* create file in sysfs. Returns an error on out of memory. Always cleans up
627621
* if there's an error.
628622
*/
629-
static __modinit int add_sysfs_param(struct module_kobject *mk,
630-
const struct kernel_param *kp,
631-
const char *name)
623+
static __init_or_module int add_sysfs_param(struct module_kobject *mk,
624+
const struct kernel_param *kp,
625+
const char *name)
632626
{
633627
struct module_param_attrs *new_mp;
634628
struct attribute **new_attrs;
@@ -761,7 +755,8 @@ void destroy_params(const struct kernel_param *params, unsigned num)
761755
params[i].ops->free(params[i].arg);
762756
}
763757

764-
struct module_kobject __modinit * lookup_or_create_module_kobject(const char *name)
758+
struct module_kobject * __init_or_module
759+
lookup_or_create_module_kobject(const char *name)
765760
{
766761
struct module_kobject *mk;
767762
struct kobject *kobj;

scripts/gendwarfksyms/dwarf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ static void process_enumerator_type(struct state *state, struct die *cache,
750750
Dwarf_Die *die)
751751
{
752752
bool overridden = false;
753+
unsigned long override;
753754
Dwarf_Word value;
754755

755756
if (stable) {
@@ -761,7 +762,8 @@ static void process_enumerator_type(struct state *state, struct die *cache,
761762
return;
762763

763764
overridden = kabi_get_enumerator_value(
764-
state->expand.current_fqn, cache->fqn, &value);
765+
state->expand.current_fqn, cache->fqn, &override);
766+
value = override;
765767
}
766768

767769
process_list_comma(state, cache);

scripts/gendwarfksyms/symbols.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (C) 2024 Google LLC
44
*/
55

6+
#include <inttypes.h>
67
#include "gendwarfksyms.h"
78

89
#define SYMBOL_HASH_BITS 12
@@ -242,7 +243,7 @@ static void elf_for_each_global(int fd, elf_symbol_callback_t func, void *arg)
242243
error("elf_getdata failed: %s", elf_errmsg(-1));
243244

244245
if (shdr->sh_entsize != sym_size)
245-
error("expected sh_entsize (%lu) to be %zu",
246+
error("expected sh_entsize (%" PRIu64 ") to be %zu",
246247
shdr->sh_entsize, sym_size);
247248

248249
nsyms = shdr->sh_size / shdr->sh_entsize;
@@ -292,7 +293,7 @@ static void set_symbol_addr(struct symbol *sym, void *arg)
292293
hash_add(symbol_addrs, &sym->addr_hash,
293294
symbol_addr_hash(&sym->addr));
294295

295-
debug("%s -> { %u, %lx }", sym->name, sym->addr.section,
296+
debug("%s -> { %u, %" PRIx64 " }", sym->name, sym->addr.section,
296297
sym->addr.address);
297298
} else if (sym->addr.section != addr->section ||
298299
sym->addr.address != addr->address) {

scripts/sign-file.c

Lines changed: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <arpa/inet.h>
2525
#include <openssl/opensslv.h>
2626
#include <openssl/bio.h>
27+
#include <openssl/cms.h>
2728
#include <openssl/evp.h>
2829
#include <openssl/pem.h>
2930
#include <openssl/err.h>
@@ -39,29 +40,6 @@
3940
#endif
4041
#include "ssl-common.h"
4142

42-
/*
43-
* Use CMS if we have openssl-1.0.0 or newer available - otherwise we have to
44-
* assume that it's not available and its header file is missing and that we
45-
* should use PKCS#7 instead. Switching to the older PKCS#7 format restricts
46-
* the options we have on specifying the X.509 certificate we want.
47-
*
48-
* Further, older versions of OpenSSL don't support manually adding signers to
49-
* the PKCS#7 message so have to accept that we get a certificate included in
50-
* the signature message. Nor do such older versions of OpenSSL support
51-
* signing with anything other than SHA1 - so we're stuck with that if such is
52-
* the case.
53-
*/
54-
#if defined(LIBRESSL_VERSION_NUMBER) || \
55-
OPENSSL_VERSION_NUMBER < 0x10000000L || \
56-
defined(OPENSSL_NO_CMS)
57-
#define USE_PKCS7
58-
#endif
59-
#ifndef USE_PKCS7
60-
#include <openssl/cms.h>
61-
#else
62-
#include <openssl/pkcs7.h>
63-
#endif
64-
6543
struct module_signature {
6644
uint8_t algo; /* Public-key crypto algorithm [0] */
6745
uint8_t hash; /* Digest algorithm [0] */
@@ -228,15 +206,10 @@ int main(int argc, char **argv)
228206
bool raw_sig = false;
229207
unsigned char buf[4096];
230208
unsigned long module_size, sig_size;
231-
unsigned int use_signed_attrs;
232209
const EVP_MD *digest_algo;
233210
EVP_PKEY *private_key;
234-
#ifndef USE_PKCS7
235211
CMS_ContentInfo *cms = NULL;
236212
unsigned int use_keyid = 0;
237-
#else
238-
PKCS7 *pkcs7 = NULL;
239-
#endif
240213
X509 *x509;
241214
BIO *bd, *bm;
242215
int opt, n;
@@ -246,21 +219,13 @@ int main(int argc, char **argv)
246219

247220
key_pass = getenv("KBUILD_SIGN_PIN");
248221

249-
#ifndef USE_PKCS7
250-
use_signed_attrs = CMS_NOATTR;
251-
#else
252-
use_signed_attrs = PKCS7_NOATTR;
253-
#endif
254-
255222
do {
256223
opt = getopt(argc, argv, "sdpk");
257224
switch (opt) {
258225
case 's': raw_sig = true; break;
259226
case 'p': save_sig = true; break;
260227
case 'd': sign_only = true; save_sig = true; break;
261-
#ifndef USE_PKCS7
262228
case 'k': use_keyid = CMS_USE_KEYID; break;
263-
#endif
264229
case -1: break;
265230
default: format();
266231
}
@@ -289,14 +254,6 @@ int main(int argc, char **argv)
289254
replace_orig = true;
290255
}
291256

292-
#ifdef USE_PKCS7
293-
if (strcmp(hash_algo, "sha1") != 0) {
294-
fprintf(stderr, "sign-file: %s only supports SHA1 signing\n",
295-
OPENSSL_VERSION_TEXT);
296-
exit(3);
297-
}
298-
#endif
299-
300257
/* Open the module file */
301258
bm = BIO_new_file(module_name, "rb");
302259
ERR(!bm, "%s", module_name);
@@ -314,10 +271,9 @@ int main(int argc, char **argv)
314271
digest_algo = EVP_get_digestbyname(hash_algo);
315272
ERR(!digest_algo, "EVP_get_digestbyname");
316273

317-
#ifndef USE_PKCS7
318-
319274
unsigned int flags =
320275
CMS_NOCERTS |
276+
CMS_NOATTR |
321277
CMS_PARTIAL |
322278
CMS_BINARY |
323279
CMS_DETACHED |
@@ -335,12 +291,10 @@ int main(int argc, char **argv)
335291
/* ML-DSA + CMS_NOATTR is not supported in openssl-3.5
336292
* and before.
337293
*/
338-
use_signed_attrs = 0;
294+
flags &= ~CMS_NOATTR;
339295
}
340296
#endif
341297

342-
flags |= use_signed_attrs;
343-
344298
/* Load the signature message from the digest buffer. */
345299
cms = CMS_sign(NULL, NULL, NULL, NULL, flags);
346300
ERR(!cms, "CMS_sign");
@@ -350,13 +304,6 @@ int main(int argc, char **argv)
350304
ERR(CMS_final(cms, bm, NULL, flags) != 1,
351305
"CMS_final");
352306

353-
#else
354-
pkcs7 = PKCS7_sign(x509, private_key, NULL, bm,
355-
PKCS7_NOCERTS | PKCS7_BINARY |
356-
PKCS7_DETACHED | use_signed_attrs);
357-
ERR(!pkcs7, "PKCS7_sign");
358-
#endif
359-
360307
if (save_sig) {
361308
char *sig_file_name;
362309
BIO *b;
@@ -365,13 +312,8 @@ int main(int argc, char **argv)
365312
"asprintf");
366313
b = BIO_new_file(sig_file_name, "wb");
367314
ERR(!b, "%s", sig_file_name);
368-
#ifndef USE_PKCS7
369315
ERR(i2d_CMS_bio_stream(b, cms, NULL, 0) != 1,
370316
"%s", sig_file_name);
371-
#else
372-
ERR(i2d_PKCS7_bio(b, pkcs7) != 1,
373-
"%s", sig_file_name);
374-
#endif
375317
BIO_free(b);
376318
}
377319

@@ -398,11 +340,7 @@ int main(int argc, char **argv)
398340
module_size = BIO_number_written(bd);
399341

400342
if (!raw_sig) {
401-
#ifndef USE_PKCS7
402343
ERR(i2d_CMS_bio_stream(bd, cms, NULL, 0) != 1, "%s", dest_name);
403-
#else
404-
ERR(i2d_PKCS7_bio(bd, pkcs7) != 1, "%s", dest_name);
405-
#endif
406344
} else {
407345
BIO *b;
408346

0 commit comments

Comments
 (0)