xfrm: do not leak ESRCH to user space

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>

authored by fernando@oss.ntt.co and committed by David S. Miller a4322266 3a8af722

+2
+2
net/xfrm/xfrm_policy.c
··· 1251 1251 -EINVAL : -EAGAIN); 1252 1252 xfrm_state_put(x); 1253 1253 } 1254 + else if (error == -ESRCH) 1255 + error = -EAGAIN; 1254 1256 1255 1257 if (!tmpl->optional) 1256 1258 goto fail;