Skip to contentSkip to conversation

key: Free dumping state on socket close

PATCH Timo Teräs 2 participants 2 messages Sep 26, 2008 – Oct 4, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Fix a xfrm_{state,policy}_walk leak if pfkey socket is closed while dumping is on-going.

---
Checked netlink code and the dumper clean up is done in there in netlink_sock_destruct.

I'll update the "put dumpers on dump list" patch by making the state release a function since there's the skb to free too.

 net/key/af_key.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
net/key/af_key.c +8 -0
index d628df9..97007de 100644
@@ -89,6 +89,14 @@ static int pfkey_do_dump(struct pfkey_sock *pfk)
 
 static void pfkey_sock_destruct(struct sock *sk)
 {
+	struct pfkey_sock *pfk = pfkey_sk(sk);
+
+	if (pfk->dump.dump) {
+		pfk->dump.done(pfk);
+		pfk->dump.dump = NULL;
+		pfk->dump.done = NULL;
+	}
+
 	skb_queue_purge(&sk->sk_receive_queue);
 
 	if (!sock_flag(sk, SOCK_DEAD)) {
Signature · 1 line
1.5.4.3
maintainer Acked-by
#1 lore raw
Quoted 23 lines · Timo Ter??s

Fix a xfrm_{state,policy}_walk leak if pfkey socket is closed while dumping is on-going.

---
Checked netlink code and the dumper clean up is done in there in netlink_sock_destruct.

I'll update the "put dumpers on dump list" patch by making the state release a function since there's the skb to free too.

net/key/af_key.c | 8 ++++++++

1 files changed, 8 insertions(+), 0 deletions(-)
net/key/af_key.c +1 -0
index d628df9..97007de 100644
@@ -89,6 +89,14 @@ static int pfkey_do_dump(struct pfkey_sock *pfk)
 
 static void pfkey_sock_destruct(struct sock *sk)
 {
+       struct pfkey_sock *pfk = pfkey_sk(sk);

net/key/af_key.c static int pfkey_do_dump(struct pfkey_sock *pfk) · line 102

Quoted 10 lines
net/key/af_key.c +7 -0
+
+       if (pfk->dump.dump) {
+               pfk->dump.done(pfk);
+               pfk->dump.dump = NULL;
+               pfk->dump.done = NULL;
+       }
+
       skb_queue_purge(&sk->sk_receive_queue);
 
       if (!sock_flag(sk, SOCK_DEAD)) {

Thanks,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt