linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taehee Yoo <ap420073@gmail.com>
To: "Elliott, Robert (Servers)" <elliott@hpe.com>,
	"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
	"herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"richard@nod.at" <richard@nod.at>,
	"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
	"sathyanarayanan.kuppuswamy@linux.intel.com" 
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	"jpoimboe@kernel.org" <jpoimboe@kernel.org>,
	"x86@kernel.org" <x86@kernel.org>,
	"jussi.kivilinna@iki.fi" <jussi.kivilinna@iki.fi>
Subject: Re: [PATCH v3 2/4] crypto: aria: do not use magic number offsets of aria_ctx
Date: Fri, 11 Nov 2022 15:45:00 +0900	[thread overview]
Message-ID: <318ca852-4962-be3a-fd60-499bbc4a0546@gmail.com> (raw)
In-Reply-To: <MW5PR84MB18422C6DB5DDFAE158BAF459AB019@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM>

Hi Elliott,
Thank you so much for your review!

On 2022. 11. 10. 오후 12:55, Elliott, Robert (Servers) wrote:
 >
 >
 >> -----Original Message-----
 >> From: Taehee Yoo <ap420073@gmail.com>
 >> Sent: Sunday, November 6, 2022 8:36 AM
 >> To: linux-crypto@vger.kernel.org; herbert@gondor.apana.org.au;
 >> davem@davemloft.net; tglx@linutronix.de; mingo@redhat.com; bp@alien8.de;
 >> dave.hansen@linux.intel.com; hpa@zytor.com;
 >> kirill.shutemov@linux.intel.com; richard@nod.at; 
viro@zeniv.linux.org.uk;
 >> sathyanarayanan.kuppuswamy@linux.intel.com; jpoimboe@kernel.org; 
Elliott,
 >> Robert (Servers) <elliott@hpe.com>; x86@kernel.org; 
jussi.kivilinna@iki.fi
 >> Cc: ap420073@gmail.com
 >> Subject: [PATCH v3 2/4] crypto: aria: do not use magic number offsets of
 >> aria_ctx
 >>
 >> aria-avx assembly code accesses members of aria_ctx with magic number
 >> offset. If the shape of struct aria_ctx is changed carelessly,
 >> aria-avx will not work.
 >> So, we need to ensure accessing members of aria_ctx with correct
 >> offset values, not with magic numbers.
 >>
 >> It adds ARIA_CTX_enc_key, ARIA_CTX_dec_key, and ARIA_CTX_rounds in the
 >> asm-offsets.c So, correct offset definitions will be generated.
 >> aria-avx assembly code can access members of aria_ctx safely with
 >> these definitions.
 >>
 >> diff --git a/arch/x86/crypto/aria-aesni-avx-asm_64.S
 > ...
 >>
 >>   #include <linux/linkage.h>
 >>   #include <asm/frame.h>
 >> -
 >> -/* struct aria_ctx: */
 >> -#define enc_key 0
 >> -#define dec_key 272
 >> -#define rounds 544
 >
 > That structure also has a key_length field after the rounds field.
 > aria_set_key() sets it, but no function ever seems to use it.
 > Perhaps that field should be removed?

Okay, I will remove that fields in a separate patch.

 >
 >> +#include <asm/asm-offsets.h>
 >
 > That makes the offsets flexible, which is good.
 >
 > The assembly code also implicitly assumes the size of each of those 
fields
 > (e.g., enc_key is 272 bytes, dec_key is 272 bytes, and rounds is 4 
bytes).
 > A BUILD_BUG_ON confirming those assumptions might be worthwhile.

You're right,
I didn't consider the size of the fields.
I will contain BUILD_BUG_ON() to check the size.

 >
 >> diff --git a/arch/x86/kernel/asm-offsets.c 
b/arch/x86/kernel/asm-offsets.c
 >> index cb50589a7102..32192a91c65b 100644
 >> --- a/arch/x86/kernel/asm-offsets.c
 >> +++ b/arch/x86/kernel/asm-offsets.c
 >> @@ -7,6 +7,7 @@
 >>   #define COMPILE_OFFSETS
 >>
 >>   #include <linux/crypto.h>
 >> +#include <crypto/aria.h>
 >
 > Is it safe to include .h files for a large number of crypto modules
 > in one C file? It seems like they could easily include naming conflicts.
 >
 > However, this set does seem to compile cleanly:
 >

Thanks for this check.
Sorry, I'm not sure about the side effects of a large number of header 
in .c file.

 > +// no .h for aegis, but ctx is simple
 > +#include <crypto/aes.h>
 > +#include <crypto/aria.h>
 > +#include <crypto/blake2s.h>
 > +#include <crypto/blowfish.h>
 > +// no .h for camellia in crypto; it is in arch/x86/crypto
 > +#include <crypto/cast5.h>
 > +#include <crypto/cast6.h>
 > +#include <crypto/chacha.h>
 > +// no .h for crc32c, crc32, crct10dif, but no ctx structure to worry 
about
 > +#include <crypto/curve25519.h>
 > +#include <crypto/des.h>
 > +#include <crypto/ghash.h>
 > +#include <crypto/nhpoly1305.h>
 > +#include <crypto/poly1305.h>
 > +#include <crypto/polyval.h>
 > +#include <crypto/serpent.h>
 > +#include <crypto/sha1.h>
 > +#include <crypto/sha2.h>
 > +#include <crypto/sm3.h>
 > +#include <crypto/twofish.h>
 >

Thanks a lot!
Taehee Yoo

  reply	other threads:[~2022-11-11  6:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-06 14:36 [PATCH v3 0/4] crypto: aria: implement aria-avx2 and aria-avx512 Taehee Yoo
2022-11-06 14:36 ` [PATCH v3 1/4] crypto: aria: add keystream array into struct aria_ctx Taehee Yoo
2022-11-07  8:48   ` Herbert Xu
2022-11-07 11:39     ` Taehee Yoo
2022-11-09 13:16     ` Taehee Yoo
2022-11-10  3:19       ` Herbert Xu
2022-11-11  9:59       ` crypto: cryptd - Use request context instead of stack for sub-request Herbert Xu
2022-11-11 10:05         ` crypto: skcipher - Allow sync algorithms with large request contexts Herbert Xu
2022-11-11 15:43         ` crypto: cryptd - Use request context instead of stack for sub-request Taehee Yoo
2022-11-06 14:36 ` [PATCH v3 2/4] crypto: aria: do not use magic number offsets of aria_ctx Taehee Yoo
2022-11-10  3:55   ` Elliott, Robert (Servers)
2022-11-11  6:45     ` Taehee Yoo [this message]
2022-11-06 14:36 ` [PATCH v3 3/4] crypto: aria: implement aria-avx2 Taehee Yoo
2022-11-06 14:36 ` [PATCH v3 4/4] crypto: aria: implement aria-avx512 Taehee Yoo

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=318ca852-4962-be3a-fd60-499bbc4a0546@gmail.com \
    --to=ap420073@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=elliott@hpe.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@kernel.org \
    --cc=jussi.kivilinna@iki.fi \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=richard@nod.at \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.org \
    /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).