netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kazunori MIYAZAWA <kazunori@miyazawa.org>
To: David Miller <davem@davemloft.net>
Cc: miika@iki.fi, Diego.Beltrami@hiit.fi,
	herbert@gondor.apana.org.au, netdev@vger.kernel.org,
	usagi-core@linux-ipv6.org
Subject: Re: [PATCH][IPSEC][4/7] inter address family ipsec tunnel
Date: Thu, 07 Dec 2006 20:23:48 +0900	[thread overview]
Message-ID: <4577F9C4.2020301@miyazawa.org> (raw)
In-Reply-To: <20061206.234857.70203259.davem@davemloft.net>

David Miller wrote:
> From: David Miller <davem@davemloft.net>
> Date: Wed, 06 Dec 2006 23:37:49 -0800 (PST)
> 
>> From: Kazunori MIYAZAWA <kazunori@miyazawa.org>
>> Date: Wed, 6 Dec 2006 20:35:37 +0900
>>
>>> BTW, I have a question about descrementing the reference count of
>>> rt->peer.  The reference cound in normal "dst" structure is
>>> decremented by calling inet_putpeer from ipv4_dst_destroy. But
>>> xfrm4_dst_destroy does not call inet_putpeer.  Where do we decrement
>>> the count? Should xfrm4_dst_destroy do that?
>> Indeed, it is a real leak.  And yes, I believe that xfrm4_dst_destroy()
>> should release it.  I will make this fix, thank you.
> 
> For reference, this is the fix I checked in.
> 
> Thanks again for spotting this problem.
> 

Thank you for making the patch.
Will it be merged to 2.6.19.x?

> I suppose your patch will need to add an address family check for this
> too.  Actually... I think address family check is needed for 'idev'
> release in xfrm4_dst_destroy() too, if you agree please also add that
> fix to your patch.
> 

Yes, I will add address family check for your patch.

Umm, I guess we don't need address family check because xdst
is allocated with xfrm4_dst_ops and the family of rt0 is
always equal to the original address family.
They are always AF_INET in this case.

I will try to fix the unresolved symbol issue.

> It is very complicated, using IPV6 route in xfrm4 code, because now
> all "X->u.rt" references need to be audited.
> 
> commit 26db167702756d0022f8ea5f1f30cad3018cfe31
> Author: David S. Miller <davem@sunset.davemloft.net>
> Date:   Wed Dec 6 23:45:15 2006 -0800
> 
>     [IPSEC]: Fix inetpeer leak in ipv4 xfrm dst entries.
>     
>     We grab a reference to the route's inetpeer entry but
>     forget to release it in xfrm4_dst_destroy().
>     
>     Bug discovered by Kazunori MIYAZAWA <kazunori@miyazawa.org>
>     
>     Signed-off-by: David S. Miller <davem@davemloft.net>
> 
> diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
> index d4107bb..fb9f69c 100644
> --- a/net/ipv4/xfrm4_policy.c
> +++ b/net/ipv4/xfrm4_policy.c
> @@ -274,6 +274,8 @@ static void xfrm4_dst_destroy(struct dst
>  
>  	if (likely(xdst->u.rt.idev))
>  		in_dev_put(xdst->u.rt.idev);
> +	if (likely(xdst->u.rt.peer))
> +		inet_putpeer(xdst->u.rt.peer);
>  	xfrm_dst_destroy(xdst);
>  }
>  
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Kazunori Miyazawa

  reply	other threads:[~2006-12-07 11:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-24  5:38 [PATCH][IPSEC][4/7] inter address family ipsec tunnel Kazunori MIYAZAWA
2006-12-01  0:48 ` David Miller
2006-12-01  4:41   ` Kazunori MIYAZAWA
2006-12-06 11:35     ` Kazunori MIYAZAWA
2006-12-07  7:37       ` David Miller
2006-12-07  7:40         ` David Miller
2006-12-07  7:48         ` David Miller
2006-12-07 11:23           ` Kazunori MIYAZAWA [this message]
2006-12-07 22:03             ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4577F9C4.2020301@miyazawa.org \
    --to=kazunori@miyazawa.org \
    --cc=Diego.Beltrami@hiit.fi \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=miika@iki.fi \
    --cc=netdev@vger.kernel.org \
    --cc=usagi-core@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).