netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: herbert.xu@redhat.com
Cc: vyekkirala@trustedcs.com, jmorris@namei.org,
	netdev@vger.kernel.org, paul.moore@hp.com
Subject: Re: [IPSEC] flow: Cache negative results
Date: Wed, 10 Jan 2007 22:06:05 -0800 (PST)	[thread overview]
Message-ID: <20070110.220605.38709282.davem@davemloft.net> (raw)
In-Reply-To: <20070110232713.GA13180@gondor.apana.org.au>

From: Herbert Xu <herbert.xu@redhat.com>
Date: Thu, 11 Jan 2007 10:27:13 +1100

> On Wed, Jan 10, 2007 at 03:08:55PM -0600, Venkat Yekkirala wrote:
> > 
> > I was talking about this (the latter) as well. Currently, on a proper
> > "negative", -ESRCH is returned by security_xfrm_policy_lookup(), and
> > this comes back up as a 0 from resolver(), correctly indicating NO
> > applicable
> > xfrm policy (after taking security into account). But if
> > security_xfrm_policy_lookup()
> > were to return anything other than a zero or -ESRCH, such as -ENOMEM,
> > you will see it come back up as such (as -ENOMEM) from resolver(),
> > and in this case, it's neither a positive nor a negative, just an error.
> > Hence a full lookup would be in order, the next time round.
> 
> OK, I see that now.  The EACCES error is translated to ESRCH in
> the security layer.
> 
> > Also, I would fix the other bug you had noted, by something like:
> 
> I agree.
> 
> [IPSEC] flow: Fix potential memory leak
> 
> When old flow cache entries that are not at the head of their chain
> trigger a transient security error they get unlinked along with all
> the entries preceding them in the chain.  The preceding entries are
> not freed correctly.
> 
> This patch fixes this by simply leaving the entry around.  It's based
> on a suggestion by Venkat Yekkirala.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

This version of the fix looks good, I'll apply it, thanks Herbert.

>  
> > I am planning to test and submit a patch to SELinux
> > to invoke flow_cache_flush() on policy reloads tomorrow.
> 
> flow_cache_flush() shouldn't be used by SELinux.  You probably
> want to increase the genid instead.

That's what I recommend too.  Active flushes are very bad for
performance, passive garbage collection of stale entries should
be used for coherency whenever possible.

> BTW, we should probably add some code to deal with overflows in
> genid.  With the recent improvements in policy update speeds, it
> could be conceivable for an overflow to occur.

Even if you had a very powerful computer, doing nothing but
inserting and deleting policies, it'd take around 90 days for
the generation count to overflow.

But of course it could happen.

One thing we could do is force a full flow cache flush when some
percentage before the generation count would overflow.  Say every
%80 of the generation ID space?  That gives enough space to ensure
the flush tasklet runs before the ID really does wrap.

  reply	other threads:[~2007-01-11  6:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-10  7:22 [IPSEC] flow: Cache negative results Herbert Xu
2007-01-10  9:24 ` David Miller
2007-01-10 14:15 ` James Morris
2007-01-10 15:26   ` Venkat Yekkirala
2007-01-10 17:41   ` Venkat Yekkirala
2007-01-10 20:49     ` Herbert Xu
2007-01-10 21:08       ` Venkat Yekkirala
2007-01-10 23:27         ` Herbert Xu
2007-01-11  6:06           ` David Miller [this message]
2007-01-11 11:29             ` Herbert Xu
2007-01-10 16:11 ` Paul Moore
2007-01-10 23:27   ` Herbert Xu

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=20070110.220605.38709282.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=herbert.xu@redhat.com \
    --cc=jmorris@namei.org \
    --cc=netdev@vger.kernel.org \
    --cc=paul.moore@hp.com \
    --cc=vyekkirala@trustedcs.com \
    /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).