Re: [PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-02-27 Thread Stephan Mueller
Am Freitag, 27. Februar 2015, 10:34:37 schrieb Tadeusz Struk:

Hi Tadeusz,

> On 02/27/2015 02:26 AM, Stephan Mueller wrote:
>  This patch adds the AEAD support for AF_ALG.
>  
>  >> > The implementation is based on algif_skcipher, but contains heavy
>  >> > modifications to streamline the interface for AEAD uses.
>  >> > 
>  >> > To use AEAD, the user space consumer has to use the salg_type
>  >> > named
>  >> > "aead".
> >>> >> 
> >>> >> I just saw Al Viro's patch to use the iov_iter API in
> >>> >> algif_skcipher.c. I looked at it but lacked documentation for using
> >>> >> it properly. Now I have a template that I will incorporate into
> >>> >> algif_aead.c
> >> >
> >> >Please resubmit once you have done this.
> > 
> > I have done that, but as indicated with an email to Al, I cannot get his
> > patch for skcipher and hash to work. Similarly, my modification for the
> > AEAD does not work either. So, I do not see that Al's patch can be
> > merged as is.
> > 
> > Therefore, I have not submitted my patch as Al mentioned he wanted to
> > look into his patchset.
> 
> Hi Stephan,
> There was a problem with the iov_iter changes, but it has been fixed on
> netdev during merging window. The algif_skcipher works fine for me on the
> latest (4.0.0-rc1+) cryptodev.

Great, thanks for the hint. I will check my implementation and release it 
shortly.
> 
> Regards,
> Tadeusz


-- 
Ciao
Stephan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-02-27 Thread Tadeusz Struk
On 02/27/2015 02:26 AM, Stephan Mueller wrote:
 This patch adds the AEAD support for AF_ALG.
 >> > 
 >> > The implementation is based on algif_skcipher, but contains heavy
 >> > modifications to streamline the interface for AEAD uses.
 >> > 
 >> > To use AEAD, the user space consumer has to use the salg_type named
 >> > "aead".
>>> >> 
>>> >> I just saw Al Viro's patch to use the iov_iter API in
>>> >> algif_skcipher.c. I looked at it but lacked documentation for using
>>> >> it properly. Now I have a template that I will incorporate into
>>> >> algif_aead.c
>> >
>> >Please resubmit once you have done this.
> I have done that, but as indicated with an email to Al, I cannot get his 
> patch for skcipher and hash to work. Similarly, my modification for the 
> AEAD does not work either. So, I do not see that Al's patch can be 
> merged as is.
> 
> Therefore, I have not submitted my patch as Al mentioned he wanted to 
> look into his patchset.

Hi Stephan,
There was a problem with the iov_iter changes, but it has been fixed on netdev 
during merging window.
The algif_skcipher works fine for me on the latest (4.0.0-rc1+) cryptodev.

Regards,
Tadeusz
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-02-27 Thread Stephan Mueller
Am Freitag, 27. Februar 2015, 22:49:44 schrieb Herbert Xu:

Hi Herbert,

>On Thu, Feb 05, 2015 at 04:10:58PM +0100, Stephan Mueller wrote:
>> Am Donnerstag, 29. Januar 2015, 21:24:45 schrieb Stephan Mueller:
>> 
>> Hi Herbert,
>> 
>> > This patch adds the AEAD support for AF_ALG.
>> > 
>> > The implementation is based on algif_skcipher, but contains heavy
>> > modifications to streamline the interface for AEAD uses.
>> > 
>> > To use AEAD, the user space consumer has to use the salg_type named
>> > "aead".
>> 
>> I just saw Al Viro's patch to use the iov_iter API in
>> algif_skcipher.c. I looked at it but lacked documentation for using
>> it properly. Now I have a template that I will incorporate into
>> algif_aead.c
>
>Please resubmit once you have done this.

I have done that, but as indicated with an email to Al, I cannot get his 
patch for skcipher and hash to work. Similarly, my modification for the 
AEAD does not work either. So, I do not see that Al's patch can be 
merged as is.

Therefore, I have not submitted my patch as Al mentioned he wanted to 
look into his patchset.
>
>Thanks,


Ciao
Stephan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-02-27 Thread Herbert Xu
On Thu, Feb 05, 2015 at 04:10:58PM +0100, Stephan Mueller wrote:
> Am Donnerstag, 29. Januar 2015, 21:24:45 schrieb Stephan Mueller:
> 
> Hi Herbert,
> 
> > This patch adds the AEAD support for AF_ALG.
> > 
> > The implementation is based on algif_skcipher, but contains heavy
> > modifications to streamline the interface for AEAD uses.
> > 
> > To use AEAD, the user space consumer has to use the salg_type named
> > "aead".
> 
> I just saw Al Viro's patch to use the iov_iter API in algif_skcipher.c. I 
> looked at it but lacked documentation for using it properly. Now I have a 
> template that I will incorporate into algif_aead.c

Please resubmit once you have done this.

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-02-27 Thread Tadeusz Struk
On 02/27/2015 02:26 AM, Stephan Mueller wrote:
 This patch adds the AEAD support for AF_ALG.
   
   The implementation is based on algif_skcipher, but contains heavy
   modifications to streamline the interface for AEAD uses.
   
   To use AEAD, the user space consumer has to use the salg_type named
   aead.
  
  I just saw Al Viro's patch to use the iov_iter API in
  algif_skcipher.c. I looked at it but lacked documentation for using
  it properly. Now I have a template that I will incorporate into
  algif_aead.c
 
 Please resubmit once you have done this.
 I have done that, but as indicated with an email to Al, I cannot get his 
 patch for skcipher and hash to work. Similarly, my modification for the 
 AEAD does not work either. So, I do not see that Al's patch can be 
 merged as is.
 
 Therefore, I have not submitted my patch as Al mentioned he wanted to 
 look into his patchset.

Hi Stephan,
There was a problem with the iov_iter changes, but it has been fixed on netdev 
during merging window.
The algif_skcipher works fine for me on the latest (4.0.0-rc1+) cryptodev.

Regards,
Tadeusz
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-02-27 Thread Stephan Mueller
Am Freitag, 27. Februar 2015, 10:34:37 schrieb Tadeusz Struk:

Hi Tadeusz,

 On 02/27/2015 02:26 AM, Stephan Mueller wrote:
  This patch adds the AEAD support for AF_ALG.
  
The implementation is based on algif_skcipher, but contains heavy
modifications to streamline the interface for AEAD uses.

To use AEAD, the user space consumer has to use the salg_type
named
aead.
   
   I just saw Al Viro's patch to use the iov_iter API in
   algif_skcipher.c. I looked at it but lacked documentation for using
   it properly. Now I have a template that I will incorporate into
   algif_aead.c
  
  Please resubmit once you have done this.
  
  I have done that, but as indicated with an email to Al, I cannot get his
  patch for skcipher and hash to work. Similarly, my modification for the
  AEAD does not work either. So, I do not see that Al's patch can be
  merged as is.
  
  Therefore, I have not submitted my patch as Al mentioned he wanted to
  look into his patchset.
 
 Hi Stephan,
 There was a problem with the iov_iter changes, but it has been fixed on
 netdev during merging window. The algif_skcipher works fine for me on the
 latest (4.0.0-rc1+) cryptodev.

Great, thanks for the hint. I will check my implementation and release it 
shortly.
 
 Regards,
 Tadeusz


-- 
Ciao
Stephan
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-02-27 Thread Herbert Xu
On Thu, Feb 05, 2015 at 04:10:58PM +0100, Stephan Mueller wrote:
 Am Donnerstag, 29. Januar 2015, 21:24:45 schrieb Stephan Mueller:
 
 Hi Herbert,
 
  This patch adds the AEAD support for AF_ALG.
  
  The implementation is based on algif_skcipher, but contains heavy
  modifications to streamline the interface for AEAD uses.
  
  To use AEAD, the user space consumer has to use the salg_type named
  aead.
 
 I just saw Al Viro's patch to use the iov_iter API in algif_skcipher.c. I 
 looked at it but lacked documentation for using it properly. Now I have a 
 template that I will incorporate into algif_aead.c

Please resubmit once you have done this.

Thanks,
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-02-27 Thread Stephan Mueller
Am Freitag, 27. Februar 2015, 22:49:44 schrieb Herbert Xu:

Hi Herbert,

On Thu, Feb 05, 2015 at 04:10:58PM +0100, Stephan Mueller wrote:
 Am Donnerstag, 29. Januar 2015, 21:24:45 schrieb Stephan Mueller:
 
 Hi Herbert,
 
  This patch adds the AEAD support for AF_ALG.
  
  The implementation is based on algif_skcipher, but contains heavy
  modifications to streamline the interface for AEAD uses.
  
  To use AEAD, the user space consumer has to use the salg_type named
  aead.
 
 I just saw Al Viro's patch to use the iov_iter API in
 algif_skcipher.c. I looked at it but lacked documentation for using
 it properly. Now I have a template that I will incorporate into
 algif_aead.c

Please resubmit once you have done this.

I have done that, but as indicated with an email to Al, I cannot get his 
patch for skcipher and hash to work. Similarly, my modification for the 
AEAD does not work either. So, I do not see that Al's patch can be 
merged as is.

Therefore, I have not submitted my patch as Al mentioned he wanted to 
look into his patchset.

Thanks,


Ciao
Stephan
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-02-05 Thread Stephan Mueller
Am Donnerstag, 29. Januar 2015, 21:24:45 schrieb Stephan Mueller:

Hi Herbert,

> This patch adds the AEAD support for AF_ALG.
> 
> The implementation is based on algif_skcipher, but contains heavy
> modifications to streamline the interface for AEAD uses.
> 
> To use AEAD, the user space consumer has to use the salg_type named
> "aead".

I just saw Al Viro's patch to use the iov_iter API in algif_skcipher.c. I 
looked at it but lacked documentation for using it properly. Now I have a 
template that I will incorporate into algif_aead.c

-- 
Ciao
Stephan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-02-05 Thread Stephan Mueller
Am Donnerstag, 29. Januar 2015, 21:24:45 schrieb Stephan Mueller:

Hi Herbert,

 This patch adds the AEAD support for AF_ALG.
 
 The implementation is based on algif_skcipher, but contains heavy
 modifications to streamline the interface for AEAD uses.
 
 To use AEAD, the user space consumer has to use the salg_type named
 aead.

I just saw Al Viro's patch to use the iov_iter API in algif_skcipher.c. I 
looked at it but lacked documentation for using it properly. Now I have a 
template that I will incorporate into algif_aead.c

-- 
Ciao
Stephan
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-01-29 Thread Stephan Mueller
This patch adds the AEAD support for AF_ALG.

The implementation is based on algif_skcipher, but contains heavy
modifications to streamline the interface for AEAD uses.

To use AEAD, the user space consumer has to use the salg_type named
"aead".

The AEAD implementation includes some overhead to calculate the size of
the ciphertext, because the AEAD implementation of the kernel crypto API
makes implied assumption on the location of the authentication tag. When
performing an encryption, the tag will be added to the created
ciphertext (note, the tag is placed adjacent to the ciphertext). For
decryption, the caller must hand in the ciphertext with the tag appended
to the ciphertext. Therefore, the selection of the used memory
needs to add/subtract the tag size from the source/destination buffers
depending on the encryption type. The code is provided with comments
explaining when and how that operation is performed.

A fully working example using all aspects of AEAD is provided at
http://www.chronox.de/libkcapi.html

Signed-off-by: Stephan Mueller 
---
 crypto/algif_aead.c | 666 
 1 file changed, 666 insertions(+)
 create mode 100644 crypto/algif_aead.c

diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
new file mode 100644
index 000..fe3dfdd
--- /dev/null
+++ b/crypto/algif_aead.c
@@ -0,0 +1,666 @@
+/*
+ * algif_aead: User-space interface for AEAD algorithms
+ *
+ * Copyright (C) 2014, Stephan Mueller 
+ *
+ * This file provides the user-space API for AEAD ciphers.
+ *
+ * This file is derived from algif_skcipher.c.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct aead_sg_list {
+   unsigned int cur;
+   struct scatterlist sg[ALG_MAX_PAGES];
+};
+
+struct aead_ctx {
+   struct aead_sg_list tsgl;
+   /*
+* RSGL_MAX_ENTRIES is an artificial limit where user space at maximum
+* can cause the kernel to allocate RSGL_MAX_ENTRIES * ALG_MAX_PAGES
+* bytes
+*/
+#define RSGL_MAX_ENTRIES ALG_MAX_PAGES
+   struct af_alg_sgl rsgl[RSGL_MAX_ENTRIES];
+
+   void *iv;
+
+   struct af_alg_completion completion;
+
+   unsigned long used;
+
+   unsigned int len;
+   bool more;
+   bool merge;
+   bool enc;
+
+   size_t aead_assoclen;
+   struct aead_request aead_req;
+};
+
+static inline int aead_sndbuf(struct sock *sk)
+{
+   struct alg_sock *ask = alg_sk(sk);
+   struct aead_ctx *ctx = ask->private;
+
+   return max_t(int, max_t(int, sk->sk_sndbuf & PAGE_MASK, PAGE_SIZE) -
+ ctx->used, 0);
+}
+
+static inline bool aead_writable(struct sock *sk)
+{
+   return PAGE_SIZE <= aead_sndbuf(sk);
+}
+
+static inline bool aead_sufficient_data(struct aead_ctx *ctx)
+{
+   unsigned as = crypto_aead_authsize(crypto_aead_reqtfm(>aead_req));
+
+   return (ctx->used >= (ctx->aead_assoclen + (ctx->enc ? 0 : as)));
+}
+
+static void aead_put_sgl(struct sock *sk)
+{
+   struct alg_sock *ask = alg_sk(sk);
+   struct aead_ctx *ctx = ask->private;
+   struct aead_sg_list *sgl = >tsgl;
+   struct scatterlist *sg = sgl->sg;
+   unsigned int i;
+
+   for (i = 0; i < sgl->cur; i++) {
+   if (!sg_page(sg + i))
+   continue;
+
+   put_page(sg_page(sg + i));
+   sg_assign_page(sg + i, NULL);
+   }
+   sgl->cur = 0;
+   ctx->used = 0;
+   ctx->more = 0;
+   ctx->merge = 0;
+}
+
+static void aead_wmem_wakeup(struct sock *sk)
+{
+   struct socket_wq *wq;
+
+   if (!aead_writable(sk))
+   return;
+
+   rcu_read_lock();
+   wq = rcu_dereference(sk->sk_wq);
+   if (wq_has_sleeper(wq))
+   wake_up_interruptible_sync_poll(>wait, POLLIN |
+  POLLRDNORM |
+  POLLRDBAND);
+   sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
+   rcu_read_unlock();
+}
+
+static int aead_wait_for_data(struct sock *sk, unsigned flags)
+{
+   struct alg_sock *ask = alg_sk(sk);
+   struct aead_ctx *ctx = ask->private;
+   long timeout;
+   DEFINE_WAIT(wait);
+   int err = -ERESTARTSYS;
+
+   if (flags & MSG_DONTWAIT)
+   return -EAGAIN;
+
+   set_bit(SOCK_ASYNC_WAITDATA, >sk_socket->flags);
+
+   for (;;) {
+   if (signal_pending(current))
+   break;
+   prepare_to_wait(sk_sleep(sk), , TASK_INTERRUPTIBLE);
+   timeout = MAX_SCHEDULE_TIMEOUT;
+   if (sk_wait_event(sk, , !ctx->more)) {
+   

[PATCH v12 1/2] crypto: AF_ALG: add AEAD support

2015-01-29 Thread Stephan Mueller
This patch adds the AEAD support for AF_ALG.

The implementation is based on algif_skcipher, but contains heavy
modifications to streamline the interface for AEAD uses.

To use AEAD, the user space consumer has to use the salg_type named
aead.

The AEAD implementation includes some overhead to calculate the size of
the ciphertext, because the AEAD implementation of the kernel crypto API
makes implied assumption on the location of the authentication tag. When
performing an encryption, the tag will be added to the created
ciphertext (note, the tag is placed adjacent to the ciphertext). For
decryption, the caller must hand in the ciphertext with the tag appended
to the ciphertext. Therefore, the selection of the used memory
needs to add/subtract the tag size from the source/destination buffers
depending on the encryption type. The code is provided with comments
explaining when and how that operation is performed.

A fully working example using all aspects of AEAD is provided at
http://www.chronox.de/libkcapi.html

Signed-off-by: Stephan Mueller smuel...@chronox.de
---
 crypto/algif_aead.c | 666 
 1 file changed, 666 insertions(+)
 create mode 100644 crypto/algif_aead.c

diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
new file mode 100644
index 000..fe3dfdd
--- /dev/null
+++ b/crypto/algif_aead.c
@@ -0,0 +1,666 @@
+/*
+ * algif_aead: User-space interface for AEAD algorithms
+ *
+ * Copyright (C) 2014, Stephan Mueller smuel...@chronox.de
+ *
+ * This file provides the user-space API for AEAD ciphers.
+ *
+ * This file is derived from algif_skcipher.c.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include crypto/scatterwalk.h
+#include crypto/if_alg.h
+#include linux/init.h
+#include linux/list.h
+#include linux/kernel.h
+#include linux/mm.h
+#include linux/module.h
+#include linux/net.h
+#include net/sock.h
+
+struct aead_sg_list {
+   unsigned int cur;
+   struct scatterlist sg[ALG_MAX_PAGES];
+};
+
+struct aead_ctx {
+   struct aead_sg_list tsgl;
+   /*
+* RSGL_MAX_ENTRIES is an artificial limit where user space at maximum
+* can cause the kernel to allocate RSGL_MAX_ENTRIES * ALG_MAX_PAGES
+* bytes
+*/
+#define RSGL_MAX_ENTRIES ALG_MAX_PAGES
+   struct af_alg_sgl rsgl[RSGL_MAX_ENTRIES];
+
+   void *iv;
+
+   struct af_alg_completion completion;
+
+   unsigned long used;
+
+   unsigned int len;
+   bool more;
+   bool merge;
+   bool enc;
+
+   size_t aead_assoclen;
+   struct aead_request aead_req;
+};
+
+static inline int aead_sndbuf(struct sock *sk)
+{
+   struct alg_sock *ask = alg_sk(sk);
+   struct aead_ctx *ctx = ask-private;
+
+   return max_t(int, max_t(int, sk-sk_sndbuf  PAGE_MASK, PAGE_SIZE) -
+ ctx-used, 0);
+}
+
+static inline bool aead_writable(struct sock *sk)
+{
+   return PAGE_SIZE = aead_sndbuf(sk);
+}
+
+static inline bool aead_sufficient_data(struct aead_ctx *ctx)
+{
+   unsigned as = crypto_aead_authsize(crypto_aead_reqtfm(ctx-aead_req));
+
+   return (ctx-used = (ctx-aead_assoclen + (ctx-enc ? 0 : as)));
+}
+
+static void aead_put_sgl(struct sock *sk)
+{
+   struct alg_sock *ask = alg_sk(sk);
+   struct aead_ctx *ctx = ask-private;
+   struct aead_sg_list *sgl = ctx-tsgl;
+   struct scatterlist *sg = sgl-sg;
+   unsigned int i;
+
+   for (i = 0; i  sgl-cur; i++) {
+   if (!sg_page(sg + i))
+   continue;
+
+   put_page(sg_page(sg + i));
+   sg_assign_page(sg + i, NULL);
+   }
+   sgl-cur = 0;
+   ctx-used = 0;
+   ctx-more = 0;
+   ctx-merge = 0;
+}
+
+static void aead_wmem_wakeup(struct sock *sk)
+{
+   struct socket_wq *wq;
+
+   if (!aead_writable(sk))
+   return;
+
+   rcu_read_lock();
+   wq = rcu_dereference(sk-sk_wq);
+   if (wq_has_sleeper(wq))
+   wake_up_interruptible_sync_poll(wq-wait, POLLIN |
+  POLLRDNORM |
+  POLLRDBAND);
+   sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
+   rcu_read_unlock();
+}
+
+static int aead_wait_for_data(struct sock *sk, unsigned flags)
+{
+   struct alg_sock *ask = alg_sk(sk);
+   struct aead_ctx *ctx = ask-private;
+   long timeout;
+   DEFINE_WAIT(wait);
+   int err = -ERESTARTSYS;
+
+   if (flags  MSG_DONTWAIT)
+   return -EAGAIN;
+
+   set_bit(SOCK_ASYNC_WAITDATA, sk-sk_socket-flags);
+
+   for (;;) {
+   if (signal_pending(current))
+   break;
+   prepare_to_wait(sk_sleep(sk), wait,