Skip to content

Commit

Permalink
af_key: Fix heap information leak
Browse files Browse the repository at this point in the history
Since x->encap of pfkey_msg2xfrm_state() is not
initialized to 0, kernel heap data can be leaked.

Fix with kzalloc() to prevent this.

Signed-off-by: Hyunwoo Kim <v4bel@theori.io>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Hyunwoo Kim authored and David S. Miller committed Feb 13, 2023
1 parent 20ab843 commit 2f47965
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/key/af_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
const struct sadb_x_nat_t_type* n_type;
struct xfrm_encap_tmpl *natt;

x->encap = kmalloc(sizeof(*x->encap), GFP_KERNEL);
x->encap = kzalloc(sizeof(*x->encap), GFP_KERNEL);
if (!x->encap) {
err = -ENOMEM;
goto out;
Expand Down

0 comments on commit 2f47965

Please sign in to comment.