Re: Why care about signal when instantiate an crypt template

2014-04-17 Thread Herbert Xu
Fan Du fan...@windriver.com wrote:
 Hi,
 
 I recently bump into a issue, ike daemon got interrupted(EINTR),
 after looking at the code, it seems there are places in crypto code
 where returning EINTR when current tasks has signal pending.
 
 For example:
 crypto_alloc_base and crypto_alloc_tfm
 
 435 err:
 436 if (err != -EAGAIN)
 437 break;
 438 if (signal_pending(current)) {
 439 err = -EINTR;
 440 break;
 441 }
 442 }
 
 I can't understand why the codes here needs to care about signals?

Because otherwise you may end up with something that you can't
kill from user-space.  You should fix your app.

Cheers,
-- 
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-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Why care about signal when instantiate an crypt template

2014-04-17 Thread Fan Du

Hi Herbert

On 2014年04月17日 15:44, Herbert Xu wrote:

Fan Dufan...@windriver.com  wrote:

Hi,

I recently bump into a issue, ike daemon got interrupted(EINTR),
after looking at the code, it seems there are places in crypto code
where returning EINTR when current tasks has signal pending.

For example:
crypto_alloc_base and crypto_alloc_tfm

435 err:
436 if (err != -EAGAIN)
437 break;
438 if (signal_pending(current)) {
439 err = -EINTR;
440 break;
441 }
442 }

I can't understand why the codes here needs to care about signals?


Because otherwise you may end up with something that you can't
kill from user-space.  You should fix your app.

Ok, I'm starting to follow your meaning.

The signal checking is only to bail out from the infinite loop, it shouldn't
override original err code -EAGAIN with -EINTR.

With -EAGAIN, user space app can try again, what do you think?

@@ -550,12 +550,8 @@ void *crypto_alloc_tfm(const char *alg_name,
err = PTR_ERR(tfm);

 err:
-   if (err != -EAGAIN)
+   if ((err != -EAGAIN) || signal_pending(current))
break;
-   if (signal_pending(current)) {
-   err = -EINTR;
-   break;
-   }
}




--
浮沉随浪只记今朝笑

--fan
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Why care about signal when instantiate an crypt template

2014-04-17 Thread Herbert Xu
On Thu, Apr 17, 2014 at 05:20:34PM +0800, Fan Du wrote:
 
 The signal checking is only to bail out from the infinite loop, it shouldn't
 override original err code -EAGAIN with -EINTR.
 
 With -EAGAIN, user space app can try again, what do you think?

EAGAIN makes no sense when we bail out due to a signal.

Cheers,
-- 
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-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: sha{256,512}_ssse3 - remove asmlinkage from static functions

2014-04-17 Thread Marek Vasut
On Wednesday, April 16, 2014 at 06:19:50 PM, Jianyu Zhan wrote:
 Commit 128ea04a9885(lto: Make asmlinkage __visible) restricts
 asmlinkage to externally_visible, this causes compilation warnings:
 
 arch/x86/crypto/sha256_ssse3_glue.c:56:1:
 warning: ‘externally_visible’ attribute have effect only on public
 objects [-Wattributes]
 
 static asmlinkage void (*sha256_transform_asm)(const char *, u32 *,
 u64); ^
 
 arch/x86/crypto/sha512_ssse3_glue.c:55:1:
 warning: ‘externally_visible’ attribute have effect only on public
 objects [-Wattributes] static asmlinkage void
 (*sha512_transform_asm)(const char *, u64 *, ^
 
 Drop asmlinkage here to avoid such warnings.
 
 Also see Commit 8783dd3a37a5853689e1(irqchip: Remove asmlinkage from
 static functions)
 
 Signed-off-by: Jianyu Zhan nasa4...@gmail.com

Makes sense, please add my humble

Reviewed-by: Marek Vasut ma...@denx.de

Best regards,
Marek Vasut
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: sha{256,512}_ssse3 - remove asmlinkage from static functions

2014-04-17 Thread H. Peter Anvin
On 04/17/2014 08:28 AM, Marek Vasut wrote:
 On Wednesday, April 16, 2014 at 06:19:50 PM, Jianyu Zhan wrote:
 Commit 128ea04a9885(lto: Make asmlinkage __visible) restricts
 asmlinkage to externally_visible, this causes compilation warnings:

 arch/x86/crypto/sha256_ssse3_glue.c:56:1:
 warning: ‘externally_visible’ attribute have effect only on public
 objects [-Wattributes]

 static asmlinkage void (*sha256_transform_asm)(const char *, u32 *,
 u64); ^

 arch/x86/crypto/sha512_ssse3_glue.c:55:1:
 warning: ‘externally_visible’ attribute have effect only on public
 objects [-Wattributes] static asmlinkage void
 (*sha512_transform_asm)(const char *, u64 *, ^

 Drop asmlinkage here to avoid such warnings.

 Also see Commit 8783dd3a37a5853689e1(irqchip: Remove asmlinkage from
 static functions)

 Signed-off-by: Jianyu Zhan nasa4...@gmail.com
 
 Makes sense, please add my humble
 
 Reviewed-by: Marek Vasut ma...@denx.de
 

It doesn't make sense, sorry.  The right thing to drop here is not
asmlinkage, it is static: this is an external declaration.

-hpa


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: sha{256,512}_ssse3 - remove asmlinkage from static functions

2014-04-17 Thread Herbert Xu
On Thu, Apr 17, 2014 at 09:49:56PM -0700, H. Peter Anvin wrote:
 On 04/17/2014 08:28 AM, Marek Vasut wrote:
  On Wednesday, April 16, 2014 at 06:19:50 PM, Jianyu Zhan wrote:
  Commit 128ea04a9885(lto: Make asmlinkage __visible) restricts
  asmlinkage to externally_visible, this causes compilation warnings:
 
  arch/x86/crypto/sha256_ssse3_glue.c:56:1:
  warning: ‘externally_visible’ attribute have effect only on public
  objects [-Wattributes]
 
  static asmlinkage void (*sha256_transform_asm)(const char *, u32 *,
  u64); ^
 
  arch/x86/crypto/sha512_ssse3_glue.c:55:1:
  warning: ‘externally_visible’ attribute have effect only on public
  objects [-Wattributes] static asmlinkage void
  (*sha512_transform_asm)(const char *, u64 *, ^
 
  Drop asmlinkage here to avoid such warnings.
 
  Also see Commit 8783dd3a37a5853689e1(irqchip: Remove asmlinkage from
  static functions)
 
  Signed-off-by: Jianyu Zhan nasa4...@gmail.com
  
  Makes sense, please add my humble
  
  Reviewed-by: Marek Vasut ma...@denx.de
  
 
 It doesn't make sense, sorry.  The right thing to drop here is not
 asmlinkage, it is static: this is an external declaration.

It's a function pointer that's static, not the function that
it's pointing to.

Cheers,
-- 
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-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: sha{256,512}_ssse3 - remove asmlinkage from static functions

2014-04-17 Thread H. Peter Anvin
On 04/17/2014 09:58 PM, Herbert Xu wrote:

 It doesn't make sense, sorry.  The right thing to drop here is not
 asmlinkage, it is static: this is an external declaration.
 
 It's a function pointer that's static, not the function that
 it's pointing to.
 

{facepalm} Right, function *pointer*.

Duh.

-hpa


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html