netdev
[Top] [All Lists]

Re: patch2: del/get byid

To: jamal <hadi@xxxxxxxxxx>
Subject: Re: patch2: del/get byid
From: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 30 Apr 2005 09:49:52 +1000
Cc: Alexey Kuznetsov <kuznet@xxxxxxxxxxxxx>, netdev@xxxxxxxxxxx, "David S. Miller" <davem@xxxxxxxxxxxxx>
In-reply-to: <1114816846.8929.6.camel@xxxxxxxxxxxxxxxxxxxxx>
References: <20050428022549.GA23556@xxxxxxxxxxxxxxxxxxx> <1114655980.7663.76.camel@xxxxxxxxxxxxxxxxxxxxx> <20050428024253.GA23695@xxxxxxxxxxxxxxxxxxx> <1114656932.7663.88.camel@xxxxxxxxxxxxxxxxxxxxx> <20050428030325.GB23823@xxxxxxxxxxxxxxxxxxx> <1114658657.7663.110.camel@xxxxxxxxxxxxxxxxxxxxx> <1114698033.7663.197.camel@xxxxxxxxxxxxxxxxxxxxx> <20050428231154.GA14215@xxxxxxxxxxxxxxxxxxx> <1114779104.7800.22.camel@xxxxxxxxxxxxxxxxxxxxx> <1114816846.8929.6.camel@xxxxxxxxxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.5.6+20040907i
On Fri, Apr 29, 2005 at 07:20:46PM -0400, jamal wrote:
>
> @@ -341,17 +341,35 @@
>  {
>       struct xfrm_policy *pol, **p;
>       struct xfrm_policy *delpol = NULL;
> +     struct xfrm_policy *delpol2 = NULL;
> +     struct xfrm_policy *delp = NULL;
>       struct xfrm_policy **newpos = NULL;
> +     int ret = -EINVAL;
> +
> +     if (policy->index)
> +             delpol = xfrm_policy_byid(dir, policy->index, 0);
> +     delpol2 = xfrm_policy_bysel(dir, &policy->selector, 0);
> +
> +     /* must be unique in both index and selector */
> +     if (delpol && delpol2) 
> +             if (delpol != delpol2) 
> +                     goto pol_err;
>  
> +     if (delpol) 
> +             delp = delpol;
> +     else 
> +             delp = delpol2;
> +                     
> +     if (delp && excl) { 
> +             ret = -EEXIST;
> +             goto pol_err;
> +     }
> +
> +     /* insert, sorted by prio*/
>       write_lock_bh(&xfrm_policy_lock);

...

>       write_unlock_bh(&xfrm_policy_lock);
>  
> -     if (delpol) {
> -             xfrm_policy_kill(delpol);
> +     if (delp) {
> +             xfrm_policy_kill(delp);
>       }

This is racy.  The policy could be killed by the timer in the middle.

This is also getting pretty hairy for something that nobody has needed so
far.  Which user-space application is going to use this index thing?

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

<Prev in Thread] Current Thread [Next in Thread>