Patch "netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc" has been added to the 5.10-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

    netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc

to the 5.10-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:
     netdevsim-zero-initialize-memory-for-new-map-s-value.patch
and it can be found in the queue-5.10 subdirectory.

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



commit f184e3b03f699bc4f1f7de6cb57d2dbc95d2ace6
Author: Haimin Zhang <tcs.kernel@xxxxxxxxx>
Date:   Wed Dec 15 19:15:30 2021 +0800

    netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc
    
    [ Upstream commit 481221775d53d6215a6e5e9ce1cce6d2b4ab9a46 ]
    
    Zero-initialize memory for new map's value in function nsim_bpf_map_alloc
    since it may cause a potential kernel information leak issue, as follows:
    1. nsim_bpf_map_alloc calls nsim_map_alloc_elem to allocate elements for
    a new map.
    2. nsim_map_alloc_elem uses kmalloc to allocate map's value, but doesn't
    zero it.
    3. A user application can use IOCTL BPF_MAP_LOOKUP_ELEM to get specific
    element's information in the map.
    4. The kernel function map_lookup_elem will call bpf_map_copy_value to get
    the information allocated at step-2, then use copy_to_user to copy to the
    user buffer.
    This can only leak information for an array map.
    
    Fixes: 395cacb5f1a0 ("netdevsim: bpf: support fake map offload")
    Suggested-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Acked-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Haimin Zhang <tcs.kernel@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20211215111530.72103-1-tcs.kernel@xxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c
index 90aafb56f1409..a438202129323 100644
--- a/drivers/net/netdevsim/bpf.c
+++ b/drivers/net/netdevsim/bpf.c
@@ -514,6 +514,7 @@ nsim_bpf_map_alloc(struct netdevsim *ns, struct bpf_offloaded_map *offmap)
 				goto err_free;
 			key = nmap->entry[i].key;
 			*key = i;
+			memset(nmap->entry[i].value, 0, offmap->map.value_size);
 		}
 	}
 



[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