lkml.org 
[lkml]   [2018]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] crypto: ctr: avoid VLA use
Hi Salvatore,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.16-rc5 next-20180314]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Salvatore-Mesoraca/crypto-ctr-avoid-VLA-use/20180315-213008
config: x86_64-randconfig-x014-201810 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

crypto/ctr.c: In function 'crypto_ctr_crypt':
>> crypto/ctr.c:156:3: warning: 'tmp2' may be used uninitialized in this function [-Wmaybe-uninitialized]
kfree(tmp2);
^~~~~~~~~~~
crypto/ctr.c:133:18: note: 'tmp2' was declared here
u8 *keystream, *tmp2;
^~~~

vim +/tmp2 +156 crypto/ctr.c

121
122 static int crypto_ctr_crypt_inplace(struct blkcipher_walk *walk,
123 struct crypto_cipher *tfm)
124 {
125 void (*fn)(struct crypto_tfm *, u8 *, const u8 *) =
126 crypto_cipher_alg(tfm)->cia_encrypt;
127 unsigned int bsize = crypto_cipher_blocksize(tfm);
128 unsigned long alignmask = crypto_cipher_alignmask(tfm);
129 unsigned int nbytes = walk->nbytes;
130 u8 *ctrblk = walk->iv;
131 u8 *src = walk->src.virt.addr;
132 DECLARE_CIPHER_BUFFER(tmp);
133 u8 *keystream, *tmp2;
134
135 if (CHECK_CIPHER_BUFFER(tmp, bsize, alignmask))
136 keystream = tmp;
137 else {
138 tmp2 = kmalloc(bsize + alignmask, GFP_ATOMIC);
139 if (!tmp2)
140 return -ENOMEM;
141 keystream = PTR_ALIGN(tmp2 + 0, alignmask + 1);
142 }
143
144 do {
145 /* create keystream */
146 fn(crypto_cipher_tfm(tfm), keystream, ctrblk);
147 crypto_xor(src, keystream, bsize);
148
149 /* increment counter in counterblock */
150 crypto_inc(ctrblk, bsize);
151
152 src += bsize;
153 } while ((nbytes -= bsize) >= bsize);
154
155 if (unlikely(keystream != tmp))
> 156 kfree(tmp2);
157 return nbytes;
158 }
159

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[unhandled content-type:application/gzip]
\
 
 \ /
  Last update: 2018-03-15 15:41    [W:0.113 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site