diff mbox series

crypto: akcipher - Move reqsize into tfm

Message ID Y3yed+w9F3Nmr9pi@gondor.apana.org.au (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: akcipher - Move reqsize into tfm | expand

Commit Message

Herbert Xu Nov. 22, 2022, 10:03 a.m. UTC
The value of reqsize cannot be determined in case of fallbacks.
Therefore it must be stored in the tfm and not the alg object.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

kernel test robot Nov. 23, 2022, 9:22 a.m. UTC | #1
Hi Herbert,

I love your patch! Perhaps something to improve:

[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master linus/master v6.1-rc6 next-20221123]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Herbert-Xu/crypto-akcipher-Move-reqsize-into-tfm/20221122-180421
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
patch link:    https://lore.kernel.org/r/Y3yed%2Bw9F3Nmr9pi%40gondor.apana.org.au
patch subject: [PATCH] crypto: akcipher - Move reqsize into tfm
config: s390-allyesconfig
compiler: s390-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/3472c4147c93536113334b6faf51d2f0f4b731a4
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Herbert-Xu/crypto-akcipher-Move-reqsize-into-tfm/20221122-180421
        git checkout 3472c4147c93536113334b6faf51d2f0f4b731a4
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash drivers/crypto/qat/qat_common/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/crypto/qat/qat_common/qat_asym_algs.c:1255:10: error: 'struct akcipher_alg' has no member named 'reqsize'
    1255 |         .reqsize = sizeof(struct qat_asym_request) + 64,
         |          ^~~~~~~
>> drivers/crypto/qat/qat_common/qat_asym_algs.c:1255:20: warning: initialization of 'struct list_head *' from 'long unsigned int' makes pointer from integer without a cast [-Wint-conversion]
    1255 |         .reqsize = sizeof(struct qat_asym_request) + 64,
         |                    ^~~~~~
   drivers/crypto/qat/qat_common/qat_asym_algs.c:1255:20: note: (near initialization for 'rsa.base.cra_list.next')
>> drivers/crypto/qat/qat_common/qat_asym_algs.c:1247:34: warning: missing braces around initializer [-Wmissing-braces]
    1247 | static struct akcipher_alg rsa = {
         |                                  ^
   ......
    1255 |         .reqsize = sizeof(struct qat_asym_request) + 64,
         |                    {{                                  }}
   drivers/crypto/qat/qat_common/qat_asym_algs.c:1256:17: warning: initialized field overwritten [-Woverride-init]
    1256 |         .base = {
         |                 ^
   drivers/crypto/qat/qat_common/qat_asym_algs.c:1256:17: note: (near initialization for 'rsa.base')
>> drivers/crypto/qat/qat_common/qat_asym_algs.c:1247:34: warning: missing braces around initializer [-Wmissing-braces]
    1247 | static struct akcipher_alg rsa = {
         |                                  ^
   ......
    1255 |         .reqsize = sizeof(struct qat_asym_request) + 64,
         |                    {{                                  }}


vim +1255 drivers/crypto/qat/qat_common/qat_asym_algs.c

a990532023b903 Tadeusz Struk       2015-07-15  1246  
a990532023b903 Tadeusz Struk       2015-07-15 @1247  static struct akcipher_alg rsa = {
a990532023b903 Tadeusz Struk       2015-07-15  1248  	.encrypt = qat_rsa_enc,
a990532023b903 Tadeusz Struk       2015-07-15  1249  	.decrypt = qat_rsa_dec,
22287b0b5988b6 Tadeusz Struk       2015-10-08  1250  	.set_pub_key = qat_rsa_setpubkey,
22287b0b5988b6 Tadeusz Struk       2015-10-08  1251  	.set_priv_key = qat_rsa_setprivkey,
22287b0b5988b6 Tadeusz Struk       2015-10-08  1252  	.max_size = qat_rsa_max_size,
a990532023b903 Tadeusz Struk       2015-07-15  1253  	.init = qat_rsa_init_tfm,
a990532023b903 Tadeusz Struk       2015-07-15  1254  	.exit = qat_rsa_exit_tfm,
c9839143ebbf5e Salvatore Benedetto 2016-07-07 @1255  	.reqsize = sizeof(struct qat_asym_request) + 64,
a990532023b903 Tadeusz Struk       2015-07-15  1256  	.base = {
a990532023b903 Tadeusz Struk       2015-07-15  1257  		.cra_name = "rsa",
a990532023b903 Tadeusz Struk       2015-07-15  1258  		.cra_driver_name = "qat-rsa",
a990532023b903 Tadeusz Struk       2015-07-15  1259  		.cra_priority = 1000,
a990532023b903 Tadeusz Struk       2015-07-15  1260  		.cra_module = THIS_MODULE,
a990532023b903 Tadeusz Struk       2015-07-15  1261  		.cra_ctxsize = sizeof(struct qat_rsa_ctx),
a990532023b903 Tadeusz Struk       2015-07-15  1262  	},
a990532023b903 Tadeusz Struk       2015-07-15  1263  };
a990532023b903 Tadeusz Struk       2015-07-15  1264
kernel test robot Nov. 23, 2022, 11:43 a.m. UTC | #2
Hi Herbert,

I love your patch! Yet something to improve:

[auto build test ERROR on herbert-cryptodev-2.6/master]
[also build test ERROR on herbert-crypto-2.6/master linus/master v6.1-rc6 next-20221123]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Herbert-Xu/crypto-akcipher-Move-reqsize-into-tfm/20221122-180421
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
patch link:    https://lore.kernel.org/r/Y3yed%2Bw9F3Nmr9pi%40gondor.apana.org.au
patch subject: [PATCH] crypto: akcipher - Move reqsize into tfm
config: s390-allmodconfig
compiler: s390-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/3472c4147c93536113334b6faf51d2f0f4b731a4
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Herbert-Xu/crypto-akcipher-Move-reqsize-into-tfm/20221122-180421
        git checkout 3472c4147c93536113334b6faf51d2f0f4b731a4
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   crypto/rsa-pkcs1pad.c: In function 'pkcs1pad_create':
>> crypto/rsa-pkcs1pad.c:677:18: error: 'struct akcipher_alg' has no member named 'reqsize'
     677 |         inst->alg.reqsize = sizeof(struct pkcs1pad_request) + rsa_alg->reqsize;
         |                  ^
   crypto/rsa-pkcs1pad.c:677:70: error: 'struct akcipher_alg' has no member named 'reqsize'
     677 |         inst->alg.reqsize = sizeof(struct pkcs1pad_request) + rsa_alg->reqsize;
         |                                                                      ^~
--
>> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:508:26: error: 'struct akcipher_alg' has no member named 'reqsize'
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                          ^~~~~~~
>> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:508:36: warning: initialization of 'struct list_head *' from 'long unsigned int' makes pointer from integer without a cast [-Wint-conversion]
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    ^~~~~~
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:508:36: note: (near initialization for 'virtio_crypto_akcipher_algs[0].algo.base.cra_list.next')
>> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:509:33: warning: initialized field overwritten [-Woverride-init]
     509 |                         .base = {
         |                                 ^
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:509:33: note: (near initialization for 'virtio_crypto_akcipher_algs[0].algo.base')
>> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
>> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:531:26: error: 'struct akcipher_alg' has no member named 'reqsize'
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                          ^~~~~~~
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:531:36: warning: initialization of 'struct list_head *' from 'long unsigned int' makes pointer from integer without a cast [-Wint-conversion]
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    ^~~~~~
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:531:36: note: (near initialization for 'virtio_crypto_akcipher_algs[1].algo.base.cra_list.next')
>> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   ......
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:532:33: warning: initialized field overwritten [-Woverride-init]
     532 |                         .base = {
         |                                 ^
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:532:33: note: (near initialization for 'virtio_crypto_akcipher_algs[1].algo.base')
>> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   ......
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
>> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   ......
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
>> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   ......
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}


vim +677 crypto/rsa-pkcs1pad.c

3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  600  
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  601  static int pkcs1pad_create(struct crypto_template *tmpl, struct rtattr **tb)
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  602  {
73bed26f73a120 Eric Biggers       2020-01-02  603  	u32 mask;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  604  	struct akcipher_instance *inst;
a49de377e051ea Tadeusz Struk      2016-03-03  605  	struct pkcs1pad_inst_ctx *ctx;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  606  	struct akcipher_alg *rsa_alg;
a49de377e051ea Tadeusz Struk      2016-03-03  607  	const char *hash_name;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  608  	int err;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  609  
7bcb2c99f8ed03 Eric Biggers       2020-07-09  610  	err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_AKCIPHER, &mask);
7bcb2c99f8ed03 Eric Biggers       2020-07-09  611  	if (err)
7bcb2c99f8ed03 Eric Biggers       2020-07-09  612  		return err;
73bed26f73a120 Eric Biggers       2020-01-02  613  
a49de377e051ea Tadeusz Struk      2016-03-03  614  	inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  615  	if (!inst)
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  616  		return -ENOMEM;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  617  
a49de377e051ea Tadeusz Struk      2016-03-03  618  	ctx = akcipher_instance_ctx(inst);
a49de377e051ea Tadeusz Struk      2016-03-03  619  
0708bb435354ae Eric Biggers       2020-02-25  620  	err = crypto_grab_akcipher(&ctx->spawn, akcipher_crypto_instance(inst),
0708bb435354ae Eric Biggers       2020-02-25  621  				   crypto_attr_alg_name(tb[1]), 0, mask);
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  622  	if (err)
0708bb435354ae Eric Biggers       2020-02-25  623  		goto err_free_inst;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  624  
0708bb435354ae Eric Biggers       2020-02-25  625  	rsa_alg = crypto_spawn_akcipher_alg(&ctx->spawn);
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  626  
9b30430ea356f2 Eric Biggers       2022-01-18  627  	if (strcmp(rsa_alg->base.cra_name, "rsa") != 0) {
9b30430ea356f2 Eric Biggers       2022-01-18  628  		err = -EINVAL;
9b30430ea356f2 Eric Biggers       2022-01-18  629  		goto err_free_inst;
9b30430ea356f2 Eric Biggers       2022-01-18  630  	}
9b30430ea356f2 Eric Biggers       2022-01-18  631  
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  632  	err = -ENAMETOOLONG;
0708bb435354ae Eric Biggers       2020-02-25  633  	hash_name = crypto_attr_alg_name(tb[2]);
0708bb435354ae Eric Biggers       2020-02-25  634  	if (IS_ERR(hash_name)) {
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  635  		if (snprintf(inst->alg.base.cra_name,
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  636  			     CRYPTO_MAX_ALG_NAME, "pkcs1pad(%s)",
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  637  			     rsa_alg->base.cra_name) >= CRYPTO_MAX_ALG_NAME)
0708bb435354ae Eric Biggers       2020-02-25  638  			goto err_free_inst;
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  639  
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  640  		if (snprintf(inst->alg.base.cra_driver_name,
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  641  			     CRYPTO_MAX_ALG_NAME, "pkcs1pad(%s)",
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  642  			     rsa_alg->base.cra_driver_name) >=
a49de377e051ea Tadeusz Struk      2016-03-03  643  			     CRYPTO_MAX_ALG_NAME)
0708bb435354ae Eric Biggers       2020-02-25  644  			goto err_free_inst;
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  645  	} else {
0708bb435354ae Eric Biggers       2020-02-25  646  		ctx->digest_info = rsa_lookup_asn1(hash_name);
0708bb435354ae Eric Biggers       2020-02-25  647  		if (!ctx->digest_info) {
0708bb435354ae Eric Biggers       2020-02-25  648  			err = -EINVAL;
0708bb435354ae Eric Biggers       2020-02-25  649  			goto err_free_inst;
0708bb435354ae Eric Biggers       2020-02-25  650  		}
0708bb435354ae Eric Biggers       2020-02-25  651  
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  652  		if (snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME,
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  653  			     "pkcs1pad(%s,%s)", rsa_alg->base.cra_name,
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  654  			     hash_name) >= CRYPTO_MAX_ALG_NAME)
0708bb435354ae Eric Biggers       2020-02-25  655  			goto err_free_inst;
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  656  
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  657  		if (snprintf(inst->alg.base.cra_driver_name,
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  658  			     CRYPTO_MAX_ALG_NAME, "pkcs1pad(%s,%s)",
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  659  			     rsa_alg->base.cra_driver_name,
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  660  			     hash_name) >= CRYPTO_MAX_ALG_NAME)
0708bb435354ae Eric Biggers       2020-02-25  661  			goto err_free_inst;
b3a8c8a5ebb5b4 Denis Kenzior      2018-10-09  662  	}
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  663  
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  664  	inst->alg.base.cra_priority = rsa_alg->base.cra_priority;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  665  	inst->alg.base.cra_ctxsize = sizeof(struct pkcs1pad_ctx);
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  666  
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  667  	inst->alg.init = pkcs1pad_init_tfm;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  668  	inst->alg.exit = pkcs1pad_exit_tfm;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  669  
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  670  	inst->alg.encrypt = pkcs1pad_encrypt;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  671  	inst->alg.decrypt = pkcs1pad_decrypt;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  672  	inst->alg.sign = pkcs1pad_sign;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  673  	inst->alg.verify = pkcs1pad_verify;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  674  	inst->alg.set_pub_key = pkcs1pad_set_pub_key;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  675  	inst->alg.set_priv_key = pkcs1pad_set_priv_key;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  676  	inst->alg.max_size = pkcs1pad_get_max_size;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05 @677  	inst->alg.reqsize = sizeof(struct pkcs1pad_request) + rsa_alg->reqsize;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  678  
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  679  	inst->free = pkcs1pad_free;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  680  
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  681  	err = akcipher_register_instance(tmpl, inst);
0708bb435354ae Eric Biggers       2020-02-25  682  	if (err) {
0708bb435354ae Eric Biggers       2020-02-25  683  err_free_inst:
0708bb435354ae Eric Biggers       2020-02-25  684  		pkcs1pad_free(inst);
0708bb435354ae Eric Biggers       2020-02-25  685  	}
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  686  	return err;
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  687  }
3d5b1ecdea6fb9 Andrzej Zaborowski 2015-12-05  688
kernel test robot Nov. 23, 2022, 12:14 p.m. UTC | #3
Hi Herbert,

I love your patch! Perhaps something to improve:

[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master linus/master v6.1-rc6 next-20221123]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Herbert-Xu/crypto-akcipher-Move-reqsize-into-tfm/20221122-180421
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
patch link:    https://lore.kernel.org/r/Y3yed%2Bw9F3Nmr9pi%40gondor.apana.org.au
patch subject: [PATCH] crypto: akcipher - Move reqsize into tfm
config: powerpc-allmodconfig
compiler: powerpc-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/3472c4147c93536113334b6faf51d2f0f4b731a4
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Herbert-Xu/crypto-akcipher-Move-reqsize-into-tfm/20221122-180421
        git checkout 3472c4147c93536113334b6faf51d2f0f4b731a4
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/crypto/qat/qat_common/ drivers/crypto/virtio/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:508:26: error: 'struct akcipher_alg' has no member named 'reqsize'
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                          ^~~~~~~
>> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:508:36: warning: initialization of 'struct list_head *' from 'unsigned int' makes pointer from integer without a cast [-Wint-conversion]
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    ^~~~~~
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:508:36: note: (near initialization for 'virtio_crypto_akcipher_algs[0].algo.base.cra_list.next')
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:509:33: warning: initialized field overwritten [-Woverride-init]
     509 |                         .base = {
         |                                 ^
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:509:33: note: (near initialization for 'virtio_crypto_akcipher_algs[0].algo.base')
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:531:26: error: 'struct akcipher_alg' has no member named 'reqsize'
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                          ^~~~~~~
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:531:36: warning: initialization of 'struct list_head *' from 'unsigned int' makes pointer from integer without a cast [-Wint-conversion]
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    ^~~~~~
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:531:36: note: (near initialization for 'virtio_crypto_akcipher_algs[1].algo.base.cra_list.next')
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   ......
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:532:33: warning: initialized field overwritten [-Woverride-init]
     532 |                         .base = {
         |                                 ^
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:532:33: note: (near initialization for 'virtio_crypto_akcipher_algs[1].algo.base')
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   ......
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   ......
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c:496:75: warning: missing braces around initializer [-Wmissing-braces]
     496 | static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
         |                                                                           ^
   ......
     508 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
   ......
     531 |                         .reqsize = sizeof(struct virtio_crypto_akcipher_request),
         |                                    {{                                           }}
--
   drivers/crypto/qat/qat_common/qat_asym_algs.c:1255:10: error: 'struct akcipher_alg' has no member named 'reqsize'
    1255 |         .reqsize = sizeof(struct qat_asym_request) + 64,
         |          ^~~~~~~
>> drivers/crypto/qat/qat_common/qat_asym_algs.c:1255:20: warning: initialization of 'struct list_head *' from 'unsigned int' makes pointer from integer without a cast [-Wint-conversion]
    1255 |         .reqsize = sizeof(struct qat_asym_request) + 64,
         |                    ^~~~~~
   drivers/crypto/qat/qat_common/qat_asym_algs.c:1255:20: note: (near initialization for 'rsa.base.cra_list.next')
   drivers/crypto/qat/qat_common/qat_asym_algs.c:1247:34: warning: missing braces around initializer [-Wmissing-braces]
    1247 | static struct akcipher_alg rsa = {
         |                                  ^
   ......
    1255 |         .reqsize = sizeof(struct qat_asym_request) + 64,
         |                    {{                                  }}
   drivers/crypto/qat/qat_common/qat_asym_algs.c:1256:17: warning: initialized field overwritten [-Woverride-init]
    1256 |         .base = {
         |                 ^
   drivers/crypto/qat/qat_common/qat_asym_algs.c:1256:17: note: (near initialization for 'rsa.base')
   drivers/crypto/qat/qat_common/qat_asym_algs.c:1247:34: warning: missing braces around initializer [-Wmissing-braces]
    1247 | static struct akcipher_alg rsa = {
         |                                  ^
   ......
    1255 |         .reqsize = sizeof(struct qat_asym_request) + 64,
         |                    {{                                  }}


vim +508 drivers/crypto/virtio/virtio_crypto_akcipher_algs.c

59ca6c93387d32 zhenwei pi 2022-03-02  495  
59ca6c93387d32 zhenwei pi 2022-03-02  496  static struct virtio_crypto_akcipher_algo virtio_crypto_akcipher_algs[] = {
59ca6c93387d32 zhenwei pi 2022-03-02  497  	{
59ca6c93387d32 zhenwei pi 2022-03-02  498  		.algonum = VIRTIO_CRYPTO_AKCIPHER_RSA,
59ca6c93387d32 zhenwei pi 2022-03-02  499  		.service = VIRTIO_CRYPTO_SERVICE_AKCIPHER,
59ca6c93387d32 zhenwei pi 2022-03-02  500  		.algo = {
59ca6c93387d32 zhenwei pi 2022-03-02  501  			.encrypt = virtio_crypto_rsa_encrypt,
59ca6c93387d32 zhenwei pi 2022-03-02  502  			.decrypt = virtio_crypto_rsa_decrypt,
59ca6c93387d32 zhenwei pi 2022-03-02  503  			.set_pub_key = virtio_crypto_rsa_raw_set_pub_key,
59ca6c93387d32 zhenwei pi 2022-03-02  504  			.set_priv_key = virtio_crypto_rsa_raw_set_priv_key,
59ca6c93387d32 zhenwei pi 2022-03-02  505  			.max_size = virtio_crypto_rsa_max_size,
59ca6c93387d32 zhenwei pi 2022-03-02  506  			.init = virtio_crypto_rsa_init_tfm,
59ca6c93387d32 zhenwei pi 2022-03-02  507  			.exit = virtio_crypto_rsa_exit_tfm,
59ca6c93387d32 zhenwei pi 2022-03-02 @508  			.reqsize = sizeof(struct virtio_crypto_akcipher_request),
59ca6c93387d32 zhenwei pi 2022-03-02  509  			.base = {
59ca6c93387d32 zhenwei pi 2022-03-02  510  				.cra_name = "rsa",
59ca6c93387d32 zhenwei pi 2022-03-02  511  				.cra_driver_name = "virtio-crypto-rsa",
59ca6c93387d32 zhenwei pi 2022-03-02  512  				.cra_priority = 150,
59ca6c93387d32 zhenwei pi 2022-03-02  513  				.cra_module = THIS_MODULE,
59ca6c93387d32 zhenwei pi 2022-03-02  514  				.cra_ctxsize = sizeof(struct virtio_crypto_akcipher_ctx),
59ca6c93387d32 zhenwei pi 2022-03-02  515  			},
59ca6c93387d32 zhenwei pi 2022-03-02  516  		},
59ca6c93387d32 zhenwei pi 2022-03-02  517  	},
59ca6c93387d32 zhenwei pi 2022-03-02  518  	{
59ca6c93387d32 zhenwei pi 2022-03-02  519  		.algonum = VIRTIO_CRYPTO_AKCIPHER_RSA,
59ca6c93387d32 zhenwei pi 2022-03-02  520  		.service = VIRTIO_CRYPTO_SERVICE_AKCIPHER,
59ca6c93387d32 zhenwei pi 2022-03-02  521  		.algo = {
59ca6c93387d32 zhenwei pi 2022-03-02  522  			.encrypt = virtio_crypto_rsa_encrypt,
59ca6c93387d32 zhenwei pi 2022-03-02  523  			.decrypt = virtio_crypto_rsa_decrypt,
59ca6c93387d32 zhenwei pi 2022-03-02  524  			.sign = virtio_crypto_rsa_sign,
59ca6c93387d32 zhenwei pi 2022-03-02  525  			.verify = virtio_crypto_rsa_verify,
59ca6c93387d32 zhenwei pi 2022-03-02  526  			.set_pub_key = virtio_crypto_p1pad_rsa_sha1_set_pub_key,
59ca6c93387d32 zhenwei pi 2022-03-02  527  			.set_priv_key = virtio_crypto_p1pad_rsa_sha1_set_priv_key,
59ca6c93387d32 zhenwei pi 2022-03-02  528  			.max_size = virtio_crypto_rsa_max_size,
59ca6c93387d32 zhenwei pi 2022-03-02  529  			.init = virtio_crypto_rsa_init_tfm,
59ca6c93387d32 zhenwei pi 2022-03-02  530  			.exit = virtio_crypto_rsa_exit_tfm,
59ca6c93387d32 zhenwei pi 2022-03-02  531  			.reqsize = sizeof(struct virtio_crypto_akcipher_request),
59ca6c93387d32 zhenwei pi 2022-03-02  532  			.base = {
59ca6c93387d32 zhenwei pi 2022-03-02  533  				.cra_name = "pkcs1pad(rsa,sha1)",
59ca6c93387d32 zhenwei pi 2022-03-02  534  				.cra_driver_name = "virtio-pkcs1-rsa-with-sha1",
59ca6c93387d32 zhenwei pi 2022-03-02  535  				.cra_priority = 150,
59ca6c93387d32 zhenwei pi 2022-03-02  536  				.cra_module = THIS_MODULE,
59ca6c93387d32 zhenwei pi 2022-03-02  537  				.cra_ctxsize = sizeof(struct virtio_crypto_akcipher_ctx),
59ca6c93387d32 zhenwei pi 2022-03-02  538  			},
59ca6c93387d32 zhenwei pi 2022-03-02  539  		},
59ca6c93387d32 zhenwei pi 2022-03-02  540  	},
59ca6c93387d32 zhenwei pi 2022-03-02  541  };
59ca6c93387d32 zhenwei pi 2022-03-02  542
diff mbox series

Patch

diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
index 5764b46bd1ec..734c213918bd 100644
--- a/include/crypto/akcipher.h
+++ b/include/crypto/akcipher.h
@@ -43,9 +43,12 @@  struct akcipher_request {
  * struct crypto_akcipher - user-instantiated objects which encapsulate
  * algorithms and core processing logic
  *
+ * @reqsize:	Request context size required by algorithm implementation
  * @base:	Common crypto API algorithm data structure
  */
 struct crypto_akcipher {
+	unsigned int reqsize;
+
 	struct crypto_tfm base;
 };
 
@@ -86,7 +89,6 @@  struct crypto_akcipher {
  *		counterpart to @init, used to remove various changes set in
  *		@init.
  *
- * @reqsize:	Request context size required by algorithm implementation
  * @base:	Common crypto API algorithm data structure
  */
 struct akcipher_alg {
@@ -102,7 +104,6 @@  struct akcipher_alg {
 	int (*init)(struct crypto_akcipher *tfm);
 	void (*exit)(struct crypto_akcipher *tfm);
 
-	unsigned int reqsize;
 	struct crypto_alg base;
 };
 
@@ -155,7 +156,7 @@  static inline struct akcipher_alg *crypto_akcipher_alg(
 
 static inline unsigned int crypto_akcipher_reqsize(struct crypto_akcipher *tfm)
 {
-	return crypto_akcipher_alg(tfm)->reqsize;
+	return tfm->reqsize;
 }
 
 static inline void akcipher_request_set_tfm(struct akcipher_request *req,
diff --git a/include/crypto/internal/akcipher.h b/include/crypto/internal/akcipher.h
index 8d3220c9ab77..1474a2d890fc 100644
--- a/include/crypto/internal/akcipher.h
+++ b/include/crypto/internal/akcipher.h
@@ -36,7 +36,7 @@  static inline void *akcipher_request_ctx(struct akcipher_request *req)
 static inline void akcipher_set_reqsize(struct crypto_akcipher *akcipher,
 					unsigned int reqsize)
 {
-	crypto_akcipher_alg(akcipher)->reqsize = reqsize;
+	akcipher->reqsize = reqsize;
 }
 
 static inline void *akcipher_tfm_ctx(struct crypto_akcipher *tfm)