From: kbuild test robot <fengguang.wu@intel.com>
To: unlisted-recipients:; (no To-header on input)
Cc: kbuild-all@01.org, linux-crypto@vger.kernel.org,
Herbert Xu <herbert@gondor.apana.org.au>
Subject: [cryptodev:master 87/87] crypto/ecc.c:1018:1: warning: 'crypto_ecdh_shared_secret' uses dynamic stack allocation
Date: Sat, 25 Jun 2016 10:37:02 +0800 [thread overview]
Message-ID: <201606251000.IQtM0p6E%fengguang.wu@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 11591 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
head: 8f44df154de79a61b0e86734f51737b8cccf8dfe
commit: 8f44df154de79a61b0e86734f51737b8cccf8dfe [87/87] crypto: ecdh - make ecdh_shared_secret unique
config: s390-allyesconfig (attached as .config)
compiler: s390x-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 8f44df154de79a61b0e86734f51737b8cccf8dfe
# save the attached .config to linux build tree
make.cross ARCH=s390
All warnings (new ones prefixed by >>):
crypto/ecc.c: In function 'vli_mmod_fast':
crypto/ecc.c:532:1: warning: 'vli_mmod_fast' uses dynamic stack allocation
}
^
crypto/ecc.c: In function 'vli_mod_square_fast':
crypto/ecc.c:552:1: warning: 'vli_mod_square_fast' uses dynamic stack allocation
}
^
crypto/ecc.c: In function 'vli_mod_mult_fast':
crypto/ecc.c:542:1: warning: 'vli_mod_mult_fast' uses dynamic stack allocation
}
^
crypto/ecc.c: In function 'xycz_add_c':
crypto/ecc.c:840:1: warning: 'xycz_add_c' uses dynamic stack allocation
}
^
crypto/ecc.c: In function 'xycz_add':
crypto/ecc.c:783:1: warning: 'xycz_add' uses dynamic stack allocation
}
^
crypto/ecc.c: In function 'apply_z':
crypto/ecc.c:719:1: warning: 'apply_z' uses dynamic stack allocation
}
^
crypto/ecc.c: In function 'ecc_point_mult.isra.0':
crypto/ecc.c:895:1: warning: 'ecc_point_mult.isra.0' uses dynamic stack allocation
}
^
crypto/ecc.c: In function 'ecdh_make_pub_key':
crypto/ecc.c:967:1: warning: 'ecdh_make_pub_key' uses dynamic stack allocation
}
^
crypto/ecc.c: In function 'crypto_ecdh_shared_secret':
>> crypto/ecc.c:1018:1: warning: 'crypto_ecdh_shared_secret' uses dynamic stack allocation
}
^
vim +/crypto_ecdh_shared_secret +1018 crypto/ecc.c
3c4b2390 Salvatore Benedetto 2016-06-22 889 xycz_add(rx[nb], ry[nb], rx[1 - nb], ry[1 - nb], curve_prime, ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 890
3c4b2390 Salvatore Benedetto 2016-06-22 891 apply_z(rx[0], ry[0], z, curve_prime, ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 892
3c4b2390 Salvatore Benedetto 2016-06-22 893 vli_set(result->x, rx[0], ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 894 vli_set(result->y, ry[0], ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 @895 }
3c4b2390 Salvatore Benedetto 2016-06-22 896
3c4b2390 Salvatore Benedetto 2016-06-22 897 static inline void ecc_swap_digits(const u64 *in, u64 *out,
3c4b2390 Salvatore Benedetto 2016-06-22 898 unsigned int ndigits)
3c4b2390 Salvatore Benedetto 2016-06-22 899 {
3c4b2390 Salvatore Benedetto 2016-06-22 900 int i;
3c4b2390 Salvatore Benedetto 2016-06-22 901
3c4b2390 Salvatore Benedetto 2016-06-22 902 for (i = 0; i < ndigits; i++)
3c4b2390 Salvatore Benedetto 2016-06-22 903 out[i] = __swab64(in[ndigits - 1 - i]);
3c4b2390 Salvatore Benedetto 2016-06-22 904 }
3c4b2390 Salvatore Benedetto 2016-06-22 905
3c4b2390 Salvatore Benedetto 2016-06-22 906 int ecc_is_key_valid(unsigned int curve_id, unsigned int ndigits,
3c4b2390 Salvatore Benedetto 2016-06-22 907 const u8 *private_key, unsigned int private_key_len)
3c4b2390 Salvatore Benedetto 2016-06-22 908 {
3c4b2390 Salvatore Benedetto 2016-06-22 909 int nbytes;
3c4b2390 Salvatore Benedetto 2016-06-22 910 const struct ecc_curve *curve = ecc_get_curve(curve_id);
3c4b2390 Salvatore Benedetto 2016-06-22 911
3c4b2390 Salvatore Benedetto 2016-06-22 912 if (!private_key)
3c4b2390 Salvatore Benedetto 2016-06-22 913 return -EINVAL;
3c4b2390 Salvatore Benedetto 2016-06-22 914
3c4b2390 Salvatore Benedetto 2016-06-22 915 nbytes = ndigits << ECC_DIGITS_TO_BYTES_SHIFT;
3c4b2390 Salvatore Benedetto 2016-06-22 916
3c4b2390 Salvatore Benedetto 2016-06-22 917 if (private_key_len != nbytes)
3c4b2390 Salvatore Benedetto 2016-06-22 918 return -EINVAL;
3c4b2390 Salvatore Benedetto 2016-06-22 919
3c4b2390 Salvatore Benedetto 2016-06-22 920 if (vli_is_zero((const u64 *)&private_key[0], ndigits))
3c4b2390 Salvatore Benedetto 2016-06-22 921 return -EINVAL;
3c4b2390 Salvatore Benedetto 2016-06-22 922
3c4b2390 Salvatore Benedetto 2016-06-22 923 /* Make sure the private key is in the range [1, n-1]. */
3c4b2390 Salvatore Benedetto 2016-06-22 924 if (vli_cmp(curve->n, (const u64 *)&private_key[0], ndigits) != 1)
3c4b2390 Salvatore Benedetto 2016-06-22 925 return -EINVAL;
3c4b2390 Salvatore Benedetto 2016-06-22 926
3c4b2390 Salvatore Benedetto 2016-06-22 927 return 0;
3c4b2390 Salvatore Benedetto 2016-06-22 928 }
3c4b2390 Salvatore Benedetto 2016-06-22 929
3c4b2390 Salvatore Benedetto 2016-06-22 930 int ecdh_make_pub_key(unsigned int curve_id, unsigned int ndigits,
3c4b2390 Salvatore Benedetto 2016-06-22 931 const u8 *private_key, unsigned int private_key_len,
3c4b2390 Salvatore Benedetto 2016-06-22 932 u8 *public_key, unsigned int public_key_len)
3c4b2390 Salvatore Benedetto 2016-06-22 933 {
3c4b2390 Salvatore Benedetto 2016-06-22 934 int ret = 0;
3c4b2390 Salvatore Benedetto 2016-06-22 935 struct ecc_point *pk;
3c4b2390 Salvatore Benedetto 2016-06-22 936 u64 priv[ndigits];
3c4b2390 Salvatore Benedetto 2016-06-22 937 unsigned int nbytes;
3c4b2390 Salvatore Benedetto 2016-06-22 938 const struct ecc_curve *curve = ecc_get_curve(curve_id);
3c4b2390 Salvatore Benedetto 2016-06-22 939
3c4b2390 Salvatore Benedetto 2016-06-22 940 if (!private_key || !curve) {
3c4b2390 Salvatore Benedetto 2016-06-22 941 ret = -EINVAL;
3c4b2390 Salvatore Benedetto 2016-06-22 942 goto out;
3c4b2390 Salvatore Benedetto 2016-06-22 943 }
3c4b2390 Salvatore Benedetto 2016-06-22 944
3c4b2390 Salvatore Benedetto 2016-06-22 945 ecc_swap_digits((const u64 *)private_key, priv, ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 946
3c4b2390 Salvatore Benedetto 2016-06-22 947 pk = ecc_alloc_point(ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 948 if (!pk) {
3c4b2390 Salvatore Benedetto 2016-06-22 949 ret = -ENOMEM;
3c4b2390 Salvatore Benedetto 2016-06-22 950 goto out;
3c4b2390 Salvatore Benedetto 2016-06-22 951 }
3c4b2390 Salvatore Benedetto 2016-06-22 952
3c4b2390 Salvatore Benedetto 2016-06-22 953 ecc_point_mult(pk, &curve->g, priv, NULL, curve->p, ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 954 if (ecc_point_is_zero(pk)) {
3c4b2390 Salvatore Benedetto 2016-06-22 955 ret = -EAGAIN;
3c4b2390 Salvatore Benedetto 2016-06-22 956 goto err_free_point;
3c4b2390 Salvatore Benedetto 2016-06-22 957 }
3c4b2390 Salvatore Benedetto 2016-06-22 958
3c4b2390 Salvatore Benedetto 2016-06-22 959 nbytes = ndigits << ECC_DIGITS_TO_BYTES_SHIFT;
3c4b2390 Salvatore Benedetto 2016-06-22 960 ecc_swap_digits(pk->x, (u64 *)public_key, ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 961 ecc_swap_digits(pk->y, (u64 *)&public_key[nbytes], ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 962
3c4b2390 Salvatore Benedetto 2016-06-22 963 err_free_point:
3c4b2390 Salvatore Benedetto 2016-06-22 964 ecc_free_point(pk);
3c4b2390 Salvatore Benedetto 2016-06-22 965 out:
3c4b2390 Salvatore Benedetto 2016-06-22 966 return ret;
3c4b2390 Salvatore Benedetto 2016-06-22 967 }
3c4b2390 Salvatore Benedetto 2016-06-22 968
8f44df15 Stephen Rothwell 2016-06-24 969 int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits,
3c4b2390 Salvatore Benedetto 2016-06-22 970 const u8 *private_key, unsigned int private_key_len,
3c4b2390 Salvatore Benedetto 2016-06-22 971 const u8 *public_key, unsigned int public_key_len,
3c4b2390 Salvatore Benedetto 2016-06-22 972 u8 *secret, unsigned int secret_len)
3c4b2390 Salvatore Benedetto 2016-06-22 973 {
3c4b2390 Salvatore Benedetto 2016-06-22 974 int ret = 0;
3c4b2390 Salvatore Benedetto 2016-06-22 975 struct ecc_point *product, *pk;
3c4b2390 Salvatore Benedetto 2016-06-22 976 u64 priv[ndigits];
3c4b2390 Salvatore Benedetto 2016-06-22 977 u64 rand_z[ndigits];
3c4b2390 Salvatore Benedetto 2016-06-22 978 unsigned int nbytes;
3c4b2390 Salvatore Benedetto 2016-06-22 979 const struct ecc_curve *curve = ecc_get_curve(curve_id);
3c4b2390 Salvatore Benedetto 2016-06-22 980
3c4b2390 Salvatore Benedetto 2016-06-22 981 if (!private_key || !public_key || !curve) {
3c4b2390 Salvatore Benedetto 2016-06-22 982 ret = -EINVAL;
3c4b2390 Salvatore Benedetto 2016-06-22 983 goto out;
3c4b2390 Salvatore Benedetto 2016-06-22 984 }
3c4b2390 Salvatore Benedetto 2016-06-22 985
3c4b2390 Salvatore Benedetto 2016-06-22 986 nbytes = ndigits << ECC_DIGITS_TO_BYTES_SHIFT;
3c4b2390 Salvatore Benedetto 2016-06-22 987
3c4b2390 Salvatore Benedetto 2016-06-22 988 get_random_bytes(rand_z, nbytes);
3c4b2390 Salvatore Benedetto 2016-06-22 989
3c4b2390 Salvatore Benedetto 2016-06-22 990 pk = ecc_alloc_point(ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 991 if (!pk) {
3c4b2390 Salvatore Benedetto 2016-06-22 992 ret = -ENOMEM;
3c4b2390 Salvatore Benedetto 2016-06-22 993 goto out;
3c4b2390 Salvatore Benedetto 2016-06-22 994 }
3c4b2390 Salvatore Benedetto 2016-06-22 995
3c4b2390 Salvatore Benedetto 2016-06-22 996 product = ecc_alloc_point(ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 997 if (!product) {
3c4b2390 Salvatore Benedetto 2016-06-22 998 ret = -ENOMEM;
3c4b2390 Salvatore Benedetto 2016-06-22 999 goto err_alloc_product;
3c4b2390 Salvatore Benedetto 2016-06-22 1000 }
3c4b2390 Salvatore Benedetto 2016-06-22 1001
3c4b2390 Salvatore Benedetto 2016-06-22 1002 ecc_swap_digits((const u64 *)public_key, pk->x, ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 1003 ecc_swap_digits((const u64 *)&public_key[nbytes], pk->y, ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 1004 ecc_swap_digits((const u64 *)private_key, priv, ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 1005
3c4b2390 Salvatore Benedetto 2016-06-22 1006 ecc_point_mult(product, pk, priv, rand_z, curve->p, ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 1007
3c4b2390 Salvatore Benedetto 2016-06-22 1008 ecc_swap_digits(product->x, (u64 *)secret, ndigits);
3c4b2390 Salvatore Benedetto 2016-06-22 1009
3c4b2390 Salvatore Benedetto 2016-06-22 1010 if (ecc_point_is_zero(product))
3c4b2390 Salvatore Benedetto 2016-06-22 1011 ret = -EFAULT;
3c4b2390 Salvatore Benedetto 2016-06-22 1012
3c4b2390 Salvatore Benedetto 2016-06-22 1013 ecc_free_point(product);
3c4b2390 Salvatore Benedetto 2016-06-22 1014 err_alloc_product:
3c4b2390 Salvatore Benedetto 2016-06-22 1015 ecc_free_point(pk);
3c4b2390 Salvatore Benedetto 2016-06-22 1016 out:
3c4b2390 Salvatore Benedetto 2016-06-22 1017 return ret;
3c4b2390 Salvatore Benedetto 2016-06-22 @1018 }
:::::: The code at line 1018 was first introduced by commit
:::::: 3c4b23901a0c766879dff680cd6bdab47bcdbbd2 crypto: ecdh - Add ECDH software support
:::::: TO: Salvatore Benedetto <salvatore.benedetto@intel.com>
:::::: CC: Herbert Xu <herbert@gondor.apana.org.au>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 41745 bytes --]
reply other threads:[~2016-06-25 2:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=201606251000.IQtM0p6E%fengguang.wu@intel.com \
--to=fengguang.wu@intel.com \
--cc=herbert@gondor.apana.org.au \
--cc=kbuild-all@01.org \
--cc=linux-crypto@vger.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