]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
dm-pcache: reject option groups without values
authorSamuel Moelius <sam.moelius@trailofbits.com>
Mon, 29 Jun 2026 15:47:40 +0000 (15:47 +0000)
committerMikulas Patocka <mpatocka@redhat.com>
Wed, 8 Jul 2026 20:33:34 +0000 (22:33 +0200)
commitd9c631e3fbd44246a2be781d26cfacbb9b8ec127
tree70cf75ae0984e3015cea10e76db6b8b06207e514
parent5bcd4d3058ebaf46ad2e163829d87dd4870c7a45
dm-pcache: reject option groups without values

The pcache target parses optional arguments as name/value pairs.  A
table that advertises one optional argument and supplies only a
recognized option name, for example "cache_mode", reaches
parse_cache_opts() with argc == 1.  The parser consumes the name,
decrements argc to zero, then calls dm_shift_arg() again for the value.
dm_shift_arg() returns NULL when no arguments remain, and the following
strcmp() dereferences that NULL pointer.

Check that each recognized option has a value before consuming it.  This
keeps valid "cache_mode writeback" and "data_crc true/false" tables
unchanged while making malformed tables fail during target construction
with a precise missing-value error.

Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
Reviewed-by: Zheng Gu <cengku@gmail.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: 1d57628ff95b ("dm-pcache: add persistent cache target in device-mapper")
Cc: stable@vger.kernel.org
drivers/md/dm-pcache/dm_pcache.c