Patch "bpf: Do not copy spin lock field from user in bpf_selem_alloc" has been added to the 6.0-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

    bpf: Do not copy spin lock field from user in bpf_selem_alloc

to the 6.0-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:
     bpf-do-not-copy-spin-lock-field-from-user-in-bpf_sel.patch
and it can be found in the queue-6.0 subdirectory.

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



commit 5b23a646df0c3aa531d2396dc414155428a8bb38
Author: Xu Kuohai <xukuohai@xxxxxxxxxx>
Date:   Mon Nov 14 08:47:19 2022 -0500

    bpf: Do not copy spin lock field from user in bpf_selem_alloc
    
    [ Upstream commit 836e49e103dfeeff670c934b7d563cbd982fce87 ]
    
    bpf_selem_alloc function is used by inode_storage, sk_storage and
    task_storage maps to set map value, for these map types, there may
    be a spin lock in the map value, so if we use memcpy to copy the whole
    map value from user, the spin lock field may be initialized incorrectly.
    
    Since the spin lock field is zeroed by kzalloc, call copy_map_value
    instead of memcpy to skip copying the spin lock field to fix it.
    
    Fixes: 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage")
    Signed-off-by: Xu Kuohai <xukuohai@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221114134720.1057939-2-xukuohai@xxxxxxxxxx
    Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/bpf/bpf_local_storage.c b/kernel/bpf/bpf_local_storage.c
index d13ffb00e981..cbe918ba9035 100644
--- a/kernel/bpf/bpf_local_storage.c
+++ b/kernel/bpf/bpf_local_storage.c
@@ -74,7 +74,7 @@ bpf_selem_alloc(struct bpf_local_storage_map *smap, void *owner,
 				gfp_flags | __GFP_NOWARN);
 	if (selem) {
 		if (value)
-			memcpy(SDATA(selem)->data, value, smap->map.value_size);
+			copy_map_value(&smap->map, SDATA(selem)->data, value);
 		return selem;
 	}
 



[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