* [PATCH v4] netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc
@ 2021-12-15 11:15 Haimin Zhang
2021-12-16 2:50 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Haimin Zhang @ 2021-12-15 11:15 UTC (permalink / raw)
To: Greg KH, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Jakub Kicinski
Cc: Haimin Zhang, security, elijahbai, netdev
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@kernel.org>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Haimin Zhang <tcs.kernel@gmail.com>
---
drivers/net/netdevsim/bpf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c
index 90aafb56f140..a43820212932 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);
}
}
--
2.30.1 (Apple Git-130)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v4] netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc
2021-12-15 11:15 [PATCH v4] netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc Haimin Zhang
@ 2021-12-16 2:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-16 2:50 UTC (permalink / raw)
To: Haimin Zhang; +Cc: greg, ast, daniel, andrii, kuba, security, elijahbai, netdev
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 15 Dec 2021 19:15:30 +0800 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [v4] netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc
https://git.kernel.org/netdev/net/c/481221775d53
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-16 2:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-15 11:15 [PATCH v4] netdevsim: Zero-initialize memory for new map's value in function nsim_bpf_map_alloc Haimin Zhang
2021-12-16 2:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).