* [PATCH] bpf: don't kfree an uninitialized im_node
@ 2017-01-24 14:16 Colin King
2017-01-24 17:53 ` Alexei Starovoitov
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2017-01-24 14:16 UTC (permalink / raw)
To: Alexei Starovoitov, netdev; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
There are some error exit paths to the label 'out' that end up
kfree'ing an uninitialized im_node. Fix this by inititializing
im_node to NULL to avoid kfree'ing a garbage address.
Issue found by CoverityScan, CID#1398022 ("Uninitialized pointer read")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
kernel/bpf/lpm_trie.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c
index ba19241d..144e976 100644
--- a/kernel/bpf/lpm_trie.c
+++ b/kernel/bpf/lpm_trie.c
@@ -262,7 +262,7 @@ static int trie_update_elem(struct bpf_map *map,
void *_key, void *value, u64 flags)
{
struct lpm_trie *trie = container_of(map, struct lpm_trie, map);
- struct lpm_trie_node *node, *im_node, *new_node = NULL;
+ struct lpm_trie_node *node, *im_node = NULL, *new_node = NULL;
struct lpm_trie_node __rcu **slot;
struct bpf_lpm_trie_key *key = _key;
unsigned long irq_flags;
--
2.10.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bpf: don't kfree an uninitialized im_node
2017-01-24 14:16 [PATCH] bpf: don't kfree an uninitialized im_node Colin King
@ 2017-01-24 17:53 ` Alexei Starovoitov
0 siblings, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2017-01-24 17:53 UTC (permalink / raw)
To: Colin King, Daniel Borkmann, David S. Miller
Cc: Alexei Starovoitov, netdev, kernel-janitors, linux-kernel
On Tue, Jan 24, 2017 at 6:16 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> There are some error exit paths to the label 'out' that end up
> kfree'ing an uninitialized im_node. Fix this by inititializing
> im_node to NULL to avoid kfree'ing a garbage address.
this fix already landed. See:
commit d140199af510 ("bpf, lpm: fix kfree of im_node in trie_update_elem")
> Issue found by CoverityScan, CID#1398022 ("Uninitialized pointer read")
Nice. Good to know that static analysis can do such checks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bpf: don't kfree an uninitialized im_node
@ 2017-01-24 17:53 ` Alexei Starovoitov
0 siblings, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2017-01-24 17:53 UTC (permalink / raw)
To: Colin King, Daniel Borkmann, David S. Miller
Cc: Alexei Starovoitov, netdev, kernel-janitors, linux-kernel
On Tue, Jan 24, 2017 at 6:16 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> There are some error exit paths to the label 'out' that end up
> kfree'ing an uninitialized im_node. Fix this by inititializing
> im_node to NULL to avoid kfree'ing a garbage address.
this fix already landed. See:
commit d140199af510 ("bpf, lpm: fix kfree of im_node in trie_update_elem")
> Issue found by CoverityScan, CID#1398022 ("Uninitialized pointer read")
Nice. Good to know that static analysis can do such checks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-24 17:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24 14:16 [PATCH] bpf: don't kfree an uninitialized im_node Colin King
2017-01-24 17:53 ` Alexei Starovoitov
2017-01-24 17:53 ` Alexei Starovoitov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.