Skip to content

Commit 137f8cf

Browse files
keestorvalds
authored andcommitted
mm/zpool: use prefixed module loading
To avoid potential format string expansion via module parameters, do not use the zpool type directly in request_module() without a format string. Additionally, to avoid arbitrary modules being loaded via zpool API (e.g. via the zswap_zpool_type module parameter) add a "zpool-" prefix to the requested module, as well as module aliases for the existing zpool types (zbud and zsmalloc). Signed-off-by: Kees Cook <[email protected]> Cc: Seth Jennings <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Nitin Gupta <[email protected]> Acked-by: Dan Streetman <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 0cf1e9d commit 137f8cf

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

mm/zbud.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ static struct zpool_driver zbud_zpool_driver = {
195195
.total_size = zbud_zpool_total_size,
196196
};
197197

198+
MODULE_ALIAS("zpool-zbud");
198199
#endif /* CONFIG_ZPOOL */
199200

200201
/*****************

mm/zpool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ struct zpool *zpool_create_pool(char *type, gfp_t gfp, struct zpool_ops *ops)
150150
driver = zpool_get_driver(type);
151151

152152
if (!driver) {
153-
request_module(type);
153+
request_module("zpool-%s", type);
154154
driver = zpool_get_driver(type);
155155
}
156156

mm/zsmalloc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ static struct zpool_driver zs_zpool_driver = {
315315
.total_size = zs_zpool_total_size,
316316
};
317317

318+
MODULE_ALIAS("zpool-zsmalloc");
318319
#endif /* CONFIG_ZPOOL */
319320

320321
/* per-cpu VM mapping areas for zspage accesses that cross page boundaries */

0 commit comments

Comments
 (0)