]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sysctl: fix uninitialized variable in proc_do_large_bitmap
authorMarc Buerg <buermarc@googlemail.com>
Wed, 25 Mar 2026 22:29:50 +0000 (23:29 +0100)
committerJoel Granados <joel.granados@kernel.org>
Thu, 26 Mar 2026 08:32:19 +0000 (09:32 +0100)
proc_do_large_bitmap() does not initialize variable c, which is expected
to be set to a trailing character by proc_get_long().

However, proc_get_long() only sets c when the input buffer contains a
trailing character after the parsed value.

If c is not initialized it may happen to contain a '-'. If this is the
case proc_do_large_bitmap() expects to be able to parse a second part of
the input buffer. If there is no second part an unjustified -EINVAL will
be returned.

Initialize c to 0 to prevent returning -EINVAL on valid input.

Fixes: 9f977fb7ae9d ("sysctl: add proc_do_large_bitmap")
Signed-off-by: Marc Buerg <buermarc@googlemail.com>
Reviewed-by: Joel Granados <joel.granados@kernel.org>
Signed-off-by: Joel Granados <joel.granados@kernel.org>
kernel/sysctl.c

index 9d3a666ffde1dd29b6bf07e3a5846406f21e29ed..c9efb17cc255cffee08b5299c3e7bb947adf3f2b 100644 (file)
@@ -1118,7 +1118,7 @@ int proc_do_large_bitmap(const struct ctl_table *table, int dir,
        unsigned long bitmap_len = table->maxlen;
        unsigned long *bitmap = *(unsigned long **) table->data;
        unsigned long *tmp_bitmap = NULL;
-       char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
+       char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c = 0;
 
        if (!bitmap || !bitmap_len || !left || (*ppos && SYSCTL_KERN_TO_USER(dir))) {
                *lenp = 0;