Skip to content

Commit 6f81a44

Browse files
committed
Merge tag 'modules-6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux
Pull module updates from Luis Chamberlain: "There are a few fixes / cleanups from Vincent, Chunhui, and Petr, but the most important part of this pull request is the Rust community stepping up to help maintain both C / Rust code for future Rust module support. We grow the set of modules maintainers by three now, and with this hope to scale to help address what's needed to properly support future Rust module support. A lot of exciting stuff coming in future kernel releases. This has been on linux-next for ~ 3 weeks now with no issues" * tag 'modules-6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux: module: Refine kmemleak scanned areas module: abort module loading when sysfs setup suffer errors MAINTAINERS: scale modules with more reviewers module: Clean up the description of MODULE_SIG_<type> module: Split modules_install compression and in-kernel decompression
2 parents f95c139 + b319cea commit 6f81a44

File tree

5 files changed

+90
-73
lines changed

5 files changed

+90
-73
lines changed

MAINTAINERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15678,6 +15678,9 @@ F: include/dt-bindings/clock/mobileye,eyeq5-clk.h
1567815678

1567915679
MODULE SUPPORT
1568015680
M: Luis Chamberlain <mcgrof@kernel.org>
15681+
R: Petr Pavlu <petr.pavlu@suse.com>
15682+
R: Sami Tolvanen <samitolvanen@google.com>
15683+
R: Daniel Gomez <da.gomez@samsung.com>
1568115684
L: linux-modules@vger.kernel.org
1568215685
L: linux-kernel@vger.kernel.org
1568315686
S: Maintained

kernel/module/Kconfig

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ comment "Do not forget to sign required modules with scripts/sign-file"
229229
depends on MODULE_SIG_FORCE && !MODULE_SIG_ALL
230230

231231
choice
232-
prompt "Which hash algorithm should modules be signed with?"
232+
prompt "Hash algorithm to sign modules"
233233
depends on MODULE_SIG || IMA_APPRAISE_MODSIG
234234
help
235235
This determines which sort of hashing algorithm will be used during
@@ -239,31 +239,31 @@ choice
239239
the signature on that module.
240240

241241
config MODULE_SIG_SHA1
242-
bool "Sign modules with SHA-1"
242+
bool "SHA-1"
243243
select CRYPTO_SHA1
244244

245245
config MODULE_SIG_SHA256
246-
bool "Sign modules with SHA-256"
246+
bool "SHA-256"
247247
select CRYPTO_SHA256
248248

249249
config MODULE_SIG_SHA384
250-
bool "Sign modules with SHA-384"
250+
bool "SHA-384"
251251
select CRYPTO_SHA512
252252

253253
config MODULE_SIG_SHA512
254-
bool "Sign modules with SHA-512"
254+
bool "SHA-512"
255255
select CRYPTO_SHA512
256256

257257
config MODULE_SIG_SHA3_256
258-
bool "Sign modules with SHA3-256"
258+
bool "SHA3-256"
259259
select CRYPTO_SHA3
260260

261261
config MODULE_SIG_SHA3_384
262-
bool "Sign modules with SHA3-384"
262+
bool "SHA3-384"
263263
select CRYPTO_SHA3
264264

265265
config MODULE_SIG_SHA3_512
266-
bool "Sign modules with SHA3-512"
266+
bool "SHA3-512"
267267
select CRYPTO_SHA3
268268

269269
endchoice
@@ -279,64 +279,65 @@ config MODULE_SIG_HASH
279279
default "sha3-384" if MODULE_SIG_SHA3_384
280280
default "sha3-512" if MODULE_SIG_SHA3_512
281281

282-
choice
283-
prompt "Module compression mode"
282+
config MODULE_COMPRESS
283+
bool "Module compression"
284284
help
285-
This option allows you to choose the algorithm which will be used to
286-
compress modules when 'make modules_install' is run. (or, you can
287-
choose to not compress modules at all.)
288-
289-
External modules will also be compressed in the same way during the
290-
installation.
291-
292-
For modules inside an initrd or initramfs, it's more efficient to
293-
compress the whole initrd or initramfs instead.
294-
285+
Enable module compression to reduce on-disk size of module binaries.
295286
This is fully compatible with signed modules.
296287

297-
Please note that the tool used to load modules needs to support the
298-
corresponding algorithm. module-init-tools MAY support gzip, and kmod
299-
MAY support gzip, xz and zstd.
288+
The tool used to work with modules needs to support the selected
289+
compression type. kmod MAY support gzip, xz and zstd. Other tools
290+
might have a limited selection of the supported types.
300291

301-
Your build system needs to provide the appropriate compression tool
302-
to compress the modules.
292+
Note that for modules inside an initrd or initramfs, it's more
293+
efficient to compress the whole ramdisk instead.
303294

304-
If in doubt, select 'None'.
295+
If unsure, say N.
305296

306-
config MODULE_COMPRESS_NONE
307-
bool "None"
297+
choice
298+
prompt "Module compression type"
299+
depends on MODULE_COMPRESS
308300
help
309-
Do not compress modules. The installed modules are suffixed
310-
with .ko.
301+
Choose the supported algorithm for module compression.
311302

312303
config MODULE_COMPRESS_GZIP
313304
bool "GZIP"
314305
help
315-
Compress modules with GZIP. The installed modules are suffixed
316-
with .ko.gz.
306+
Support modules compressed with GZIP. The installed modules are
307+
suffixed with .ko.gz.
317308

318309
config MODULE_COMPRESS_XZ
319310
bool "XZ"
320311
help
321-
Compress modules with XZ. The installed modules are suffixed
322-
with .ko.xz.
312+
Support modules compressed with XZ. The installed modules are
313+
suffixed with .ko.xz.
323314

324315
config MODULE_COMPRESS_ZSTD
325316
bool "ZSTD"
326317
help
327-
Compress modules with ZSTD. The installed modules are suffixed
328-
with .ko.zst.
318+
Support modules compressed with ZSTD. The installed modules are
319+
suffixed with .ko.zst.
329320

330321
endchoice
331322

323+
config MODULE_COMPRESS_ALL
324+
bool "Automatically compress all modules"
325+
default y
326+
depends on MODULE_COMPRESS
327+
help
328+
Compress all modules during 'make modules_install'.
329+
330+
Your build system needs to provide the appropriate compression tool
331+
for the selected compression type. External modules will also be
332+
compressed in the same way during the installation.
333+
332334
config MODULE_DECOMPRESS
333335
bool "Support in-kernel module decompression"
334-
depends on MODULE_COMPRESS_GZIP || MODULE_COMPRESS_XZ || MODULE_COMPRESS_ZSTD
336+
depends on MODULE_COMPRESS
335337
select ZLIB_INFLATE if MODULE_COMPRESS_GZIP
336338
select XZ_DEC if MODULE_COMPRESS_XZ
337339
select ZSTD_DECOMPRESS if MODULE_COMPRESS_ZSTD
338340
help
339-
340341
Support for decompressing kernel modules by the kernel itself
341342
instead of relying on userspace to perform this task. Useful when
342343
load pinning security policy is enabled.

kernel/module/debug_kmemleak.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,9 @@
1212
void kmemleak_load_module(const struct module *mod,
1313
const struct load_info *info)
1414
{
15-
unsigned int i;
16-
17-
/* only scan the sections containing data */
18-
kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL);
19-
20-
for (i = 1; i < info->hdr->e_shnum; i++) {
21-
/* Scan all writable sections that's not executable */
22-
if (!(info->sechdrs[i].sh_flags & SHF_ALLOC) ||
23-
!(info->sechdrs[i].sh_flags & SHF_WRITE) ||
24-
(info->sechdrs[i].sh_flags & SHF_EXECINSTR))
25-
continue;
26-
27-
kmemleak_scan_area((void *)info->sechdrs[i].sh_addr,
28-
info->sechdrs[i].sh_size, GFP_KERNEL);
15+
/* only scan writable, non-executable sections */
16+
for_each_mod_mem_type(type) {
17+
if (type != MOD_DATA && type != MOD_INIT_DATA)
18+
kmemleak_no_scan(mod->mem[type].base);
2919
}
3020
}

kernel/module/sysfs.c

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
6969
kfree(sect_attrs);
7070
}
7171

72-
static void add_sect_attrs(struct module *mod, const struct load_info *info)
72+
static int add_sect_attrs(struct module *mod, const struct load_info *info)
7373
{
7474
unsigned int nloaded = 0, i, size[2];
7575
struct module_sect_attrs *sect_attrs;
7676
struct module_sect_attr *sattr;
7777
struct bin_attribute **gattr;
78+
int ret;
7879

7980
/* Count loaded sections and allocate structures */
8081
for (i = 0; i < info->hdr->e_shnum; i++)
@@ -85,7 +86,7 @@ static void add_sect_attrs(struct module *mod, const struct load_info *info)
8586
size[1] = (nloaded + 1) * sizeof(sect_attrs->grp.bin_attrs[0]);
8687
sect_attrs = kzalloc(size[0] + size[1], GFP_KERNEL);
8788
if (!sect_attrs)
88-
return;
89+
return -ENOMEM;
8990

9091
/* Setup section attributes. */
9192
sect_attrs->grp.name = "sections";
@@ -103,8 +104,10 @@ static void add_sect_attrs(struct module *mod, const struct load_info *info)
103104
sattr->address = sec->sh_addr;
104105
sattr->battr.attr.name =
105106
kstrdup(info->secstrings + sec->sh_name, GFP_KERNEL);
106-
if (!sattr->battr.attr.name)
107+
if (!sattr->battr.attr.name) {
108+
ret = -ENOMEM;
107109
goto out;
110+
}
108111
sect_attrs->nsections++;
109112
sattr->battr.read = module_sect_read;
110113
sattr->battr.size = MODULE_SECT_READ_SIZE;
@@ -113,13 +116,15 @@ static void add_sect_attrs(struct module *mod, const struct load_info *info)
113116
}
114117
*gattr = NULL;
115118

116-
if (sysfs_create_group(&mod->mkobj.kobj, &sect_attrs->grp))
119+
ret = sysfs_create_group(&mod->mkobj.kobj, &sect_attrs->grp);
120+
if (ret)
117121
goto out;
118122

119123
mod->sect_attrs = sect_attrs;
120-
return;
124+
return 0;
121125
out:
122126
free_sect_attrs(sect_attrs);
127+
return ret;
123128
}
124129

125130
static void remove_sect_attrs(struct module *mod)
@@ -158,15 +163,12 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs,
158163
kfree(notes_attrs);
159164
}
160165

161-
static void add_notes_attrs(struct module *mod, const struct load_info *info)
166+
static int add_notes_attrs(struct module *mod, const struct load_info *info)
162167
{
163168
unsigned int notes, loaded, i;
164169
struct module_notes_attrs *notes_attrs;
165170
struct bin_attribute *nattr;
166-
167-
/* failed to create section attributes, so can't create notes */
168-
if (!mod->sect_attrs)
169-
return;
171+
int ret;
170172

171173
/* Count notes sections and allocate structures. */
172174
notes = 0;
@@ -176,12 +178,12 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
176178
++notes;
177179

178180
if (notes == 0)
179-
return;
181+
return 0;
180182

181183
notes_attrs = kzalloc(struct_size(notes_attrs, attrs, notes),
182184
GFP_KERNEL);
183185
if (!notes_attrs)
184-
return;
186+
return -ENOMEM;
185187

186188
notes_attrs->notes = notes;
187189
nattr = &notes_attrs->attrs[0];
@@ -201,19 +203,23 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
201203
}
202204

203205
notes_attrs->dir = kobject_create_and_add("notes", &mod->mkobj.kobj);
204-
if (!notes_attrs->dir)
206+
if (!notes_attrs->dir) {
207+
ret = -ENOMEM;
205208
goto out;
209+
}
206210

207-
for (i = 0; i < notes; ++i)
208-
if (sysfs_create_bin_file(notes_attrs->dir,
209-
&notes_attrs->attrs[i]))
211+
for (i = 0; i < notes; ++i) {
212+
ret = sysfs_create_bin_file(notes_attrs->dir, &notes_attrs->attrs[i]);
213+
if (ret)
210214
goto out;
215+
}
211216

212217
mod->notes_attrs = notes_attrs;
213-
return;
218+
return 0;
214219

215220
out:
216221
free_notes_attrs(notes_attrs, i);
222+
return ret;
217223
}
218224

219225
static void remove_notes_attrs(struct module *mod)
@@ -223,9 +229,15 @@ static void remove_notes_attrs(struct module *mod)
223229
}
224230

225231
#else /* !CONFIG_KALLSYMS */
226-
static inline void add_sect_attrs(struct module *mod, const struct load_info *info) { }
232+
static inline int add_sect_attrs(struct module *mod, const struct load_info *info)
233+
{
234+
return 0;
235+
}
227236
static inline void remove_sect_attrs(struct module *mod) { }
228-
static inline void add_notes_attrs(struct module *mod, const struct load_info *info) { }
237+
static inline int add_notes_attrs(struct module *mod, const struct load_info *info)
238+
{
239+
return 0;
240+
}
229241
static inline void remove_notes_attrs(struct module *mod) { }
230242
#endif /* CONFIG_KALLSYMS */
231243

@@ -385,11 +397,20 @@ int mod_sysfs_setup(struct module *mod,
385397
if (err)
386398
goto out_unreg_modinfo_attrs;
387399

388-
add_sect_attrs(mod, info);
389-
add_notes_attrs(mod, info);
400+
err = add_sect_attrs(mod, info);
401+
if (err)
402+
goto out_del_usage_links;
403+
404+
err = add_notes_attrs(mod, info);
405+
if (err)
406+
goto out_unreg_sect_attrs;
390407

391408
return 0;
392409

410+
out_unreg_sect_attrs:
411+
remove_sect_attrs(mod);
412+
out_del_usage_links:
413+
del_usage_links(mod);
393414
out_unreg_modinfo_attrs:
394415
module_remove_modinfo_attrs(mod, -1);
395416
out_unreg_param:

scripts/Makefile.modinst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ $(foreach x, % :, $(if $(findstring $x, $(dst)), \
5353
$(error module installation path cannot contain '$x')))
5454

5555
suffix-y :=
56+
ifdef CONFIG_MODULE_COMPRESS_ALL
5657
suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz
5758
suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz
5859
suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst
60+
endif
5961

6062
modules := $(patsubst $(extmod_prefix)%.o, $(dst)/%.ko$(suffix-y), $(modules))
6163
install-$(CONFIG_MODULES) += $(modules)

0 commit comments

Comments
 (0)