public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [jarkko-tpmdd:tpm2_key-2 8/8] crypto/asymmetric_keys/tpm2_key_rsa.c:500:12: warning: stack frame size (1184) exceeds limit (1024) in 'tpm2_key_rsa_query'
@ 2024-05-20 10:19 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-05-20 10:19 UTC (permalink / raw)
  To: James Prestwood; +Cc: llvm, oe-kbuild-all, Jarkko Sakkinen

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git tpm2_key-2
head:   65954d4732015cf1fda0517aeb7fff7174ccd9fc
commit: ca8f7136e4751b9a1b07875567202c25746dc028 [8/8] keys: asymmetric: ASYMMETRIC_TPM2_KEY_RSA_SUBTYPE
config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20240520/202405201847.dE3Cn5Jz-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project fa9b1be45088dce1e4b602d451f118128b94237b)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240520/202405201847.dE3Cn5Jz-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405201847.dE3Cn5Jz-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from crypto/asymmetric_keys/tpm2_key_rsa.c:19:
   In file included from include/linux/scatterlist.h:8:
   In file included from include/linux/mm.h:2210:
   include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     522 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from crypto/asymmetric_keys/tpm2_key_rsa.c:19:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     547 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     560 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from crypto/asymmetric_keys/tpm2_key_rsa.c:19:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     573 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from crypto/asymmetric_keys/tpm2_key_rsa.c:19:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     584 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     594 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     604 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
>> crypto/asymmetric_keys/tpm2_key_rsa.c:500:12: warning: stack frame size (1184) exceeds limit (1024) in 'tpm2_key_rsa_query' [-Wframe-larger-than]
     500 | static int tpm2_key_rsa_query(const struct kernel_pkey_params *params,
         |            ^
>> crypto/asymmetric_keys/tpm2_key_rsa.c:421:12: warning: stack frame size (1320) exceeds limit (1024) in 'tpm2_key_rsa_eds_op' [-Wframe-larger-than]
     421 | static int tpm2_key_rsa_eds_op(struct kernel_pkey_params *params,
         |            ^
>> crypto/asymmetric_keys/tpm2_key_rsa.c:442:12: warning: stack frame size (1304) exceeds limit (1024) in 'tpm2_key_rsa_verify' [-Wframe-larger-than]
     442 | static int tpm2_key_rsa_verify(const struct key *key,
         |            ^
   10 warnings generated.


vim +/tpm2_key_rsa_query +500 crypto/asymmetric_keys/tpm2_key_rsa.c

   420	
 > 421	static int tpm2_key_rsa_eds_op(struct kernel_pkey_params *params,
   422				       const void *in, void *out)
   423	{
   424		struct tpm2_key *key = params->key->payload.data[asym_crypto];
   425		struct tpm_chip *chip = tpm_default_chip();
   426	
   427		if (!chip)
   428			return -ENODEV;
   429	
   430		switch (params->op) {
   431		case kernel_pkey_encrypt:
   432			return tpm2_key_rsa_encrypt(key, params, in, out);
   433		case kernel_pkey_decrypt:
   434			return tpm2_key_rsa_decrypt(chip, key, params, in, out);
   435		case kernel_pkey_sign:
   436			return tpm2_key_rsa_sign(chip, key, params, in, out);
   437		default:
   438			return -EOPNOTSUPP;
   439		}
   440	}
   441	
 > 442	static int tpm2_key_rsa_verify(const struct key *key,
   443				       const struct public_key_signature *sig)
   444	{
   445		const struct tpm2_key *tk = key->payload.data[asym_crypto];
   446		char alg_name[CRYPTO_MAX_ALG_NAME];
   447		u8 enc_pub_key[PUB_KEY_BUF_SIZE];
   448		struct akcipher_request *req;
   449		struct scatterlist src_sg[2];
   450		struct crypto_akcipher *tfm;
   451		struct crypto_wait cwait;
   452		u32 enc_pub_key_len;
   453		int rc;
   454	
   455		if (WARN_ON(!tk || !sig || !sig->s))
   456			return -EINVAL;
   457	
   458		if (!sig->digest)
   459			return -ENOPKG;
   460	
   461		rc = tpm2_key_get_akcipher(sig->encoding, sig->hash_algo, alg_name);
   462		if (rc < 0)
   463			return rc;
   464	
   465		tfm = crypto_alloc_akcipher(alg_name, 0, 0);
   466		if (IS_ERR(tfm))
   467			return PTR_ERR(tfm);
   468	
   469		enc_pub_key_len = tpm2_key_rsa_encode(tk->pub, tk->pub_len, enc_pub_key);
   470	
   471		rc = crypto_akcipher_set_pub_key(tfm, enc_pub_key, enc_pub_key_len);
   472		if (rc < 0)
   473			goto err_tfm;
   474	
   475		rc = -ENOMEM;
   476		req = akcipher_request_alloc(tfm, GFP_KERNEL);
   477		if (!req)
   478			goto err_tfm;
   479	
   480		sg_init_table(src_sg, 2);
   481		sg_set_buf(&src_sg[0], sig->s, sig->s_size);
   482		sg_set_buf(&src_sg[1], sig->digest, sig->digest_size);
   483		akcipher_request_set_crypt(req, src_sg, NULL, sig->s_size,
   484					   sig->digest_size);
   485		crypto_init_wait(&cwait);
   486		akcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG |
   487					      CRYPTO_TFM_REQ_MAY_SLEEP,
   488					      crypto_req_done, &cwait);
   489		rc = crypto_wait_req(crypto_akcipher_verify(req), &cwait);
   490	
   491		akcipher_request_free(req);
   492	err_tfm:
   493		crypto_free_akcipher(tfm);
   494		pr_devel("<=%s() = %d\n", __func__, rc);
   495		if (WARN_ON_ONCE(rc > 0))
   496			rc = -EINVAL;
   497		return rc;
   498	}
   499	
 > 500	static int tpm2_key_rsa_query(const struct kernel_pkey_params *params,
   501				      struct kernel_pkey_query *info)
   502	{
   503		struct tpm2_key *tk = params->key->payload.data[asym_crypto];
   504		char alg_name[CRYPTO_MAX_ALG_NAME];
   505		u8 enc_pub_key[PUB_KEY_BUF_SIZE];
   506		struct crypto_akcipher *tfm;
   507		u32 enc_pub_key_len = 0;
   508		unsigned int len;
   509		int ret;
   510	
   511		ret = tpm2_key_get_akcipher(params->encoding, params->hash_algo, alg_name);
   512		if (ret < 0)
   513			return ret;
   514	
   515		tfm = crypto_alloc_akcipher(alg_name, 0, 0);
   516		if (IS_ERR(tfm))
   517			return PTR_ERR(tfm);
   518	
   519		enc_pub_key_len = tpm2_key_rsa_encode(tk->pub, tk->pub_len, enc_pub_key);
   520	
   521		pr_info("%u %u\n", tk->pub_len, enc_pub_key_len);
   522	
   523		ret = crypto_akcipher_set_pub_key(tfm, enc_pub_key, enc_pub_key_len);
   524		if (ret < 0)
   525			goto err_tfm;
   526	
   527		len = crypto_akcipher_maxsize(tfm);
   528	
   529		info->key_size = tk->pub_len * 8;
   530		info->max_data_size = tk->pub_len;
   531		info->max_sig_size = len;
   532		info->max_enc_size = len;
   533		info->max_dec_size = tk->pub_len;
   534	
   535		info->supported_ops = KEYCTL_SUPPORTS_ENCRYPT |
   536				      KEYCTL_SUPPORTS_DECRYPT |
   537				      KEYCTL_SUPPORTS_VERIFY |
   538				      KEYCTL_SUPPORTS_SIGN;
   539	
   540	err_tfm:
   541		crypto_free_akcipher(tfm);
   542		return ret;
   543	}
   544	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-20 10:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-20 10:19 [jarkko-tpmdd:tpm2_key-2 8/8] crypto/asymmetric_keys/tpm2_key_rsa.c:500:12: warning: stack frame size (1184) exceeds limit (1024) in 'tpm2_key_rsa_query' kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox