Patch "cpumap: Avoid warning when CONFIG_DEBUG_PER_CPU_MAPS is enabled" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    cpumap: Avoid warning when CONFIG_DEBUG_PER_CPU_MAPS is enabled

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     cpumap-avoid-warning-when-config_debug_per_cpu_maps-.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 06c09e7d869798ea565f34d308acf2a2d327a872
Author: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>
Date:   Thu Apr 16 10:31:20 2020 +0200

    cpumap: Avoid warning when CONFIG_DEBUG_PER_CPU_MAPS is enabled
    
    commit bc23d0e3f717ced21fbfacab3ab887d55e5ba367 upstream.
    
    When the kernel is built with CONFIG_DEBUG_PER_CPU_MAPS, the cpumap code
    can trigger a spurious warning if CONFIG_CPUMASK_OFFSTACK is also set. This
    happens because in this configuration, NR_CPUS can be larger than
    nr_cpumask_bits, so the initial check in cpu_map_alloc() is not sufficient
    to guard against hitting the warning in cpumask_check().
    
    Fix this by explicitly checking the supplied key against the
    nr_cpumask_bits variable before calling cpu_possible().
    
    Fixes: 6710e1126934 ("bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP")
    Reported-by: Xiumei Mu <xmu@xxxxxxxxxx>
    Signed-off-by: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>
    Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
    Tested-by: Xiumei Mu <xmu@xxxxxxxxxx>
    Acked-by: Jesper Dangaard Brouer <brouer@xxxxxxxxxx>
    Acked-by: Song Liu <songliubraving@xxxxxx>
    Link: https://lore.kernel.org/bpf/20200416083120.453718-1-toke@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index ef49e17ae47cb..a367fc8503933 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c
@@ -486,7 +486,7 @@ static int cpu_map_update_elem(struct bpf_map *map, void *key, void *value,
 		return -EOVERFLOW;
 
 	/* Make sure CPU is a valid possible cpu */
-	if (!cpu_possible(key_cpu))
+	if (key_cpu >= nr_cpumask_bits || !cpu_possible(key_cpu))
 		return -ENODEV;
 
 	if (qsize == 0) {



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux