]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
xfrm: do not leak ESRCH to user space
authorfernando@oss.ntt.co <fernando@oss.ntt.co>
Thu, 23 Oct 2008 04:27:19 +0000 (04:27 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 31 Oct 2008 07:06:03 +0000 (00:06 -0700)
I noticed that, under certain conditions, ESRCH can be leaked from the
xfrm layer to user space through sys_connect. In particular, this seems
to happen reliably when the kernel fails to resolve a template either
because the AF_KEY receive buffer being used by racoon is full or
because the SA entry we are trying to use is in XFRM_STATE_EXPIRED
state.

However, since this could be a transient issue it could be argued that
EAGAIN would be more appropriate. Besides this error code is not even
documented in the man page for sys_connect (as of man-pages 3.07).

Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/xfrm/xfrm_policy.c

index 832b47c1de8065c8626d5ce40d39b2d313f7199c..25872747762ca76b7ccd889d72549db0f6a694a3 100644 (file)
@@ -1251,6 +1251,8 @@ xfrm_tmpl_resolve_one(struct xfrm_policy *policy, struct flowi *fl,
                                 -EINVAL : -EAGAIN);
                        xfrm_state_put(x);
                }
+               else if (error == -ESRCH)
+                       error = -EAGAIN;
 
                if (!tmpl->optional)
                        goto fail;